#help-development
1 messages Β· Page 2025 of 1
now it dropped this WilloCore-1.0-SNAPSHOT-shaded.jar
anyone know if the protocol was changed in 1.18.2?
when was Tag.ITEMS_MUSIC_DISCS added? what spigot version, etc helps
so it's like v1_18_R2?
Yes 1.18.2 is a new NMS version
appreciate it
okey, thx
.
;
{}
!!!
fun fact:
if(true) {
System.out.println(";");;;;;;;;;;;;;
;;;;;
} ;;;
``` is valid, but
```java
return true;;
is not
"whole number"
its latin
string in englisch
it means whole number
numerus integer = "number of integrity" = not just a fraction or sth π
pretty sure string is because it is an ordered set of characters
dont quote me on that
And why Foo?
ive got no clue actually
ugh FML, I am wondering since hours why my base64 decode isnt working
then I found this somewhere in the class
baseXX = baseXX.substring(4);
Heya guys, question. I need to patch a plugin but it requires as dependency spigot-src how do I install that? Using some sort of buildtools'flag? https://i.imgur.com/3DTW2XD.png
It's the pom
any1 any ideas?
no idea what that is, it definitely doesn't get built by buildtools
Hum okay. ty.
I'm using a HttpUrlConnection with a URL like "https://1.2.3.4/". of course that throws an exception since I only got certificates for domain names, any idea on how to ignore the SAN mismatch?
erm wtf a I stupid or blind?
enum WhitelistHostnameVerifier implements HostnameVerifier {
// these hosts get whitelisted
INSTANCE("localhost", "sub.domain.com");
private Set whitelist = new HashSet<>();
private HostnameVerifier defaultHostnameVerifier =
HttpsURLConnection.getDefaultHostnameVerifier();
WhitelistHostnameVerifier(String... hostnames) {
for (String hostname : hostnames) {
whitelist.add(hostname);
}
}
@Override
public boolean verify(String host, SSLSession session) {
if (whitelist.contains(host)) {
return true;
}
// important: use default verifier for all other hosts
return defaultHostnameVerifier.verify(host, session);
}
}
HOw is the INSTANCE(String, String) line supposed to work? shoudln't it be something like WhitelistHostnameVerifier INSTANCE = new WHielistHostnameVerifier(String, String) instead? o0
shoudln't it be something like WhitelistHostnameVerifier INSTANCE = new WHielistHostnameVerifier(String, String)
thats exactly how an enum is built
?jd-s itemstack
This isn't working π
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:spigot-1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot-1.18.1-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
Could not find artifact org.spigotmc:minecraft-server:txt:maps-mojang:spigot-1.18.2-R0.1-SNAPSHOT in spigot-repo
i forgot how to do mapping and remapping
can someone help me with 1.18.2
Did you Run buildtools yet?
ye
java -jar BuildTools.jar --rev 1.18.2 --remapped ?
<configuration>
<srgIn>org.spigotmc:minecraft-server:spigot-1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:spigot-1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
this is the other part of it
oh I am stupid
I have changed the code to a normal class
and totally forgot that the code I orignilly copied was an enum
ill try this one ty
Here you go. Disgusting but 100% all natural https://github.com/MikeTheShadow/ComplexMMOStats/blob/1.16.5/src/main/java/com/miketheshadow/complexmmostats/utils/LoaderTool.java.
whats better to get the majn class instance?
private final Main plugin;
public className(Main plugin) { this.plugin = plugin; }```
or ``Main.getInstance();`` with the main class being
```java
static Main instance;
public static Main getInstance() { return instance }
@Override
public void onEnable() { instance = this } ```
the former
Hey is there an existing method to simply run the chorus fruit "effect" (the random teleportation) ?
probably not in the api
but its pretty easy to recreate
you can read how it works here https://www.reddit.com/r/Minecraft/comments/3f9vj8/how_chorus_fruit_teleporting_works/
?
your first example
Yes ty, just want to be sure that there is not an existing method in the API π
alr
thanks
What about Main plugin = Main.getPlugin(Main.class);
that has the same issues (if not more) than the 2nd one
How I can update libraries in spigot? I should use BuildTools?
experienced plugin dev, dm me if you are available for a job :))
are you asking people here or are you the experienced dev
also ask on the forums not here
99% chance It's not a job worth working
iirc theres a thread collection called hiring developers on the main forums page
i think most do it for experience
does someone know how the "Nag author of XYZ for using stdout" message works?
wht
idk ive never seen that lol
if i just create a new logger in my application using java.util.logger.Logger logger = Logger.getLogger("some name"), and i call logger.info("test") will that log something to the stdout or do i need to add a handler?
seems to work without console handler
It's a paper feature and you just throw a custom sout stream at the System class which walks the stack
oh okay, thx!
RIP
π³
is SSS the millis?
HH:mm:ss.SSS
:o
ye, i thought it was just me
When I choose a mod platform (Spigot or Bukkit) does that mean that it will only work on the specific server type?
For example if I choose bukkit will it only work on bukkit servers?
do people put their public static void main above the constructor or are there no rules for it?
doesn't matter at all where it is
I usually put it into a new class
package com.jeff_media.discordspigotupdatebot;
public final class Main {
public static void main(final String[] args) {
new DiscordSpigotUpdateBot(args);
}
}
oh ye
and then I let maven generate the manifest so one can just use java -jar ...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<finalName>discord-spigot-update-bot</finalName>
<archive>
<manifest>
<mainClass>com.jeff_media.discordspigotupdatebot.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
dunno what that is
when you put your staff into a .jar, you normally have to pass the class name containing a main method
so it can find the main class?
e.g.
java -jar discord-bot.jar com.jeff_Media.discordspigotupdatebot.Main
ah doesnt intellij automatically do that when you made a main method?
if you add a MANIFEST.MF file, that's not needed
oh
maybe intelliJ does it, but I hope that you're using maven to build, instead of intellij π
is there any way to check if jukebox is done playing a music disc
ye
no
a jukebox is never "done" playing
it only has two states: disc inserted, and no disc inserted
well thats unfortunate
what are you trying to do?
its a jukebox player, it can loop disc in the slots after playing the current disc
ah like my JukeboxPlus plugin
Mojang API stop working?
yeah but as said, you can't check if it's done playing. the jukebox doesn't know anything about the inserted disc
logger doing crazy things
thanks though, I guess the player has to click the arrow manually
namemc work for me but mojang api don't work
there's also a simple reason why the jukebox simply can't know when a song is finished: every player could use a different resource pack, so they could have different songs
while one might have normal stal sound for stal disc, another player might have that sound replaced with a 6 hour opera song lol
Apis crash or get restarted at times
Just wait
yeah fair, would be dope if #getCurrentDuration method exist
a oke ':D
does someone know a good IDE for iOS apps that also runs on windows? I'm paying >60β¬ per month for a mac mini server and I'd like to stop having to pay that lmao
yeah but as said, the song duration could be different for every player
aight thanks i'll just make it manual
seems like the backend server is down
lol Logger#setUseParentHandlers fixed my issue
I don't even load it
it took me a minute to load lol
maybe they're trying to disable mojang accounts and failing bad lol
?userinfo @tender shard
they said you'd be forced to migrate from march 10th but you've still been able to use mojang accounts for days
Uuuugh it says I joined today >.< my userinfo is broken
joined this server 12 hours ago
yeah I was perma banned

aa π
ban evasion wtf
I got unbanned after 45 minutes lol
we all know you hacked md_5 to unban yourself
what did you do?
nothing, it was a mistake lol
kekw
Someone mistyped a >ban again
someone reported my messages and the mod who banned me didnt read the entire context of the messages lol
it's up again
oh wait, now it's offline again lmao
hey alex, how do u loop the disc just like in ur jukeboxplus plugin, very dope plugin
Honestly you might as well just invest if a Mac if you're gonna be spending that per month π
they are doing maintenance on the APIs
most likely fixing bugs or adding/removing features
mojang servers are down
Some Minecraft services are unavailable at the moment. We are looking into the issue. - Martin
832
258
I have a macbook but
don't wanna connect it to my monitors everytime I wanna work on an app
I usually only need the server for 2-3 weeks and then I cancel the server until I do a new app
unfortunately the setup fee is also one month's fee lol
so I usually pay ~120β¬ every other month. maybe I should really get my own mac mini and a keyboard/hdmi switch etc
Yeah definitely should.
Gotta love how Apple basically forces the use of their hardware
they got defeated on that
really depends on the language you are working in, but most should have cross compiler or remote compiler support
Apple says Xcode
in a VM?
Make your own ide
oh look looks good
i recently tried to make an intellij plugin
I am still upset
Uh oh
about?
Lol what happened
I'll let the real pros create IDEs lol
about how complicated and how badly documented intellij plugin API is
setting up a crosscompiler?
Intellij π
Plain text file π
yeah that too
btw does Dreamweaver still exist?
I remember how I used Dreamweaver for all my websites but now I've switched to PhpStorm
dreamweaver was awesome
but it got too expensive
think adobe rolled it into one of their other programs
For my websites I use Nano text editor
ruby, rails, asp, rust , etc etc
no thinks, I'll rather stick with PHP
also did you just tell people to use ASP?!
propriatory microsoft shit?
although PHP was a huge mess, PHP8 is a lot better
i did not tell anyone to use anything, just that they exists
I mean PHP is totally fine, the only bad thing about PHP is the weird method names
yeah well and bitcoin is at 30k although it actually has no real value
you can buy stuff with BTC
True
sure you can but there's no guarantee it will be worth anything in the future
Also true
most real currencies are bound to some "real" values like hundreds of tons of gold the issuing bank has laying in a safe somewhere
@tender shard https://codewithchris.com/xcode-for-windows/ looks like MacInCloud or XcodeClub are your best temporary/mobile options
Thanks, yeah I'll check it out π for now I'll just stick to my current rented mac mini until I have enough money or find a good mac mini on ebay lol
my next ios app will be a blood alcohol calculator lol
for 0.99$
whitebox
there is no decent one so I hope some people will buy it
should i save up for a mac laptop or get one from like dell or smt
do you have money to waste?
Dell laptops π
depends whether you want to use mac
no i don't have money to waste lmao
mac is really awesome, if you have the money
if you don't have so much money, obviously it's not worth it
then business/game class laptop - avoid retail/consumer
it's like a normal car vs a mercedes. ofc mercedes is way more pricy but it's also more comfortable. if you only have 50kβ¬, you probably don't wanna spend 45kβ¬ on a car, but if you have half a million, you'd probably get the mercedes lol
wdym with retail/consumer
I got two macbooks and I used to have an iMac and it's really a way better experience than windows
they are mass produced and disposable in large
but yeah, can't deny that they also cost much more
oh
a low-end business class is better than any high-end retail
you will easily get 5+ years out of a business/game class device. retail, maybe 3 years
I can actually almost buy the left one lmao, but i probs won't
o
game class like gaming laptop or what
business is like
the one ppl carry in briefcases?
when you go to a site you will see the different categories
business and game will have higher class of cpu, ram speed, graphics, etc
a bit, they also tend to have longer warranties and upgrade support
since consumer is probs the chromebook shit that schools get right?
consumer is usually what you see in stores with a few game systems sprinkled in
ohhh
so they usually have low performing components where the manufacturer cut costs
macs are awesome for many stuff including coding, music production, video editing, photoshop, ...
yes/no
show me another laptop with builtin ASIO
the cult is strong and delopers like the cult because they spend money
i mostly code or play games
sometimes i stream on twitch but i gotta check if my new internet can handle it (old internet couldn't)
yeah for gaming you can forget them
write down what you need it use it for (specific applications etc), then match components to your use
since you said programming, i'd suggest a builtin+extra graphics support
I've looked for a way to get Http requests from websites directly using the IP, so without valid certificate, and it turns out it was way easier than I though - just create a new HostnameVerifier that returns true:
public final class WhitelistHostnameVerifier implements HostnameVerifier {
private Set<String> whitelist = new HashSet<>();
private HostnameVerifier defaultHostnameVerifier =
HttpsURLConnection.getDefaultHostnameVerifier();
WhitelistHostnameVerifier(String... hostnames) {
whitelist.addAll(Arrays.asList(hostnames));
}
@Override
public boolean verify(String host, SSLSession session) {
if (whitelist.contains(host)) {
return true;
}
// important: use default verifier for all other hosts
return defaultHostnameVerifier.verify(host, session);
}
}
mmm will that work on IPv6?
IPv6 rarely resolves to a hostname
that's not what it's about
it works like this:
- Request file from http://mywebsite.com/file.html
- mywebsite.com gets resolved to an IP
- It does the request
I however wanted to do https://IP/file.html
that of course resulted in SSL errors because the webserver only has a certificate for mywebsite.com but not for IP
so that's what my above class is for
to make java think that a certificate for "mywebsite.com" also works out for https://IP/
aside from the security problem, yeah that works and makes sense
security problem being that you just whitelisted every account on that IP if its a host
not a big issue if the host is decent
how can i make a static variable for every class that extends my class
why static? you can make an enum if it never changes
Okay so
static variables are not inherited
because obviously static means part of THIS class
what are you actually trying to do?
I need to store a hashmap
i need it static cuz i want that hashmap to be unique only for that type of class
RIP, my java book doesn't cover reflection
Yeah so you're going to need a new Map for each sub type
which should really be avoided if possible
of course, I just wanted to read something about it because I'm bored
if you can avoid reflection, you should avoid it
but sometimes it's just needed
e.g. to create a generic array
nah I actually mean arrays lol
like a <T> method(T something) that returns a T[]
also fuck java 9, RIP this is no longer possible
Function<String, String> function = __ -> "Test";
Why not?
Generally you should just let callers pass an IntFunction<T[]>
String[]::new
I don't know, let me check the reason
hmm, perhaps that is why 1.17+ broke reflections with java 16
"Usage of underscores for identifiers is forbidden since java 9"
no idea why
Ah, right
I always used __ if I didn't actually need the lambda variable
but I still use java 8 anyway for most stuff so I'm fine lol
to avoid one star reviews saying "why plugin no workings"
yeah sure java 17 is better, of course
"because you are using a dead version"
but also the changes they added aren't that important for me that I'd actually see the need to update
well
java 8 is longer supported than java 17
java 8 is in no way dead
They intend on using the underscore for language features in the future so they're discouraging its use
the _ might have to do with preprocessor or linker changes
makes sense, it's just weird to be forced to use a variable name if you don't need it
I tend to name it "ignore"
my java books tells people to name it like the class if it's unused
Consumer<String> stuff = String -> System.out.println("I don't need the variable");
or __ when using java 8
yeah ignored is better lol
Yeah that's a bit clearer than naming it a class name
I do wish we could use underscores though as I thought that was going to be a feature, nameless functional interface parameters
e.g. (_, _, _, something) -> System.out.println(something) being valid
yeah well lambdas don't even allow to "overwrite" existing local var names so this will probably never be allowed
I think JS does allow that though
The lambda feature I mentioned, that is
Or maybe I had always done (_, __, ___)
that might be true, I only know the veeery basics of js lol
I can't remember
like I can make a browser copy a text if you click on some text, that's about all I can do lmao
js is demonspawn
someone please suggest me some java features on which I could read stuff about
If two people eat at the same time, that's parallel, but when someone eats and breathes, that's what it looks like from the outside at the same time, but it's not, but swallowing and breathing are sequential
lol
alrighty!
hello
i want something similar to ray trace
but i dont want to use the rayTrace method
because it would loop in all entities in the world
and i am using the EntityDamageByEntityEvent so i already have the entities i want
how could i do something like the rayTrace?
?jd
i was reading https://hub.spigotmc.org/javadocs/spigot/org/bukkit/util/BoundingBox.html#rayTrace(org.bukkit.util.Vector,org.bukkit.util.Vector,double) but i did not understand
declaration: package: org.bukkit.util, class: BoundingBox
will that method do this
or this
It can do both
Hi, i have question about how to make search system with gui.
So this what i mean:
You click a slot, inventory closes, you are name a player that you're searching for in chat, and then it opens the GUI to the page of that player with details for example health.
Is there a code or something : )
You give it a start, direction, and distance. If it intersects with the bounding box you'll see it in the result
me when document.execCommand("copy")
Do you know how to add a custom texture to a custom item in a plugin?
and how can i specify it?
You give it a start, direction, and distance.
(x, y, z) -> (dx, dy, dz), distance in blocks
If you give it 0, 0, 0, and a direction of 0, 1, 0, it's going to go from 0, 0, 0 upwards to whatever distance you give it
- it does not work
Imagine shooting a bow in Minecraft. It starts from your player's eye location (roughly), and uses the direction you're looking. The arrow is pretty much your ray trace, only it doesn't arc like an arrow does. It just goes straight
if it does not work, it would not be in the api
what lib is that o.O
are you using a plugin that manipulates packets?
yeah, then you are doing what it says
my guess is whatever your listener is doing it does not like
your packet adapter
you need to overwrite the onPacketReceiving and onPacketSending method
welp find out which one you failed to setup
and is one not overwriting the onPacketSending method
Watch the youtube video "Coding a Custom Textures Plugin" by codedred. (I'm not sure if I'm allowed to send a link in here)
What java version do i use when creating plugins to do a multi-version plugin between 1.8 - 1.18
they all HAVE to have that method
i think you need to use java 8
if you register them for outgoing packets
1.17 and 1.18 arent only java 11+?
16 and 17
if you register a PacketAdepater for packets send from server to client then your adapter needs to overwrite onPacketSending
ye, im kinda dumb
anyways
does anyone here (choco cough cough) know how to get the (visual) hitbox of a raised shield?
imo it usually a waste to try and support 1.8
If i create a plugin with java 17, 1.8 - 1.18 will can run it?
no
i thought yes?
well I shouldnt say that. as long as you use java 8 conventions taht still exist in 17 and do not force requirement it might work
Class version would still error
java is forwards compatible but not backwards compatible.
thats a lot of broken stuff to try and emulate
since when is java forwards compatible π
java 17 plugins works on java 8.
java 16 still has compatibility but 1.18 won't run the code
they literally don't
they mean java 8 plugins also run on java 9+
it just turned midnight sorry if I make no sense rn.
java 17 compiled plugins will fail on java 8 runtimes
yes, java 8 compiled plugins will run in java 17 jvms
I only want to create a multi-version plugin for 1.8 - 1.18 and idk what java version to use ,_,
not the other way around
java 8
if you dont mind missing out on the new features like records then use java 8
if you want your plugin to run on java 8 runtimes (which most 1.8 servers use) you will have to use java 8
although records are nice, they are no reason to not support java 8 since you can easily replicate records with normal data classes
yeah it can be replicated manually
and I don't like how record's getter methods are not prefixed with get anyways
I just use lombok's @ Data whenever I would normally use a record
Ty
I think I'll switch to kotlin at some point and it'll have built in data classes :)
best reason not to support that old is teh code duplication and lack of api features
have you tried kotlin alex?
code duplication? wdym?
yes but I don't like it
it doesn't add anything that's useful for me
materials vs blockData etc
I'm not saying it's bad, I just don't like it because it has no advantages for me
that's MC not java right
makes sense
yeah
we're talking about java version
e.g. java 8 vs java 17 for a plugin that wants to be compatible with 1.8+
is there any disadvantage with using api-version: '1.13' btw?
newer 1.18+ support is going to get messier
why
look at the api and note all the depreciated
you should always prioritise new versions over old imo, use something like XMaterial if you really must
boats and minecarts are now vehicles, water and lava now have a new level/flow class
etc etc
only a small subset of plugins would be affected by that right
awesome article on GPL by the way!
wait what article
cool
If a server has multiple versions, for examle 1.8 - 1.15 or something like that
What version my plugin should be at?
a server can only have one version
but it can support multiple client versions
so your plugin should be built for the server's version
Ah, I see, thank you!
plugins like viaversion will handle any differences for the clients :)
viaversion messes up packet order a lot :(
packets dont arrive in order
lol I don't know if you're serious or not π
many people hate me for that opinion but yeah it's just my opinion on how the laws work
I'm not saying people should ignore the GPL
no no I'm serious, it was good to see your opinion on the matter.
I just say that in 99% of cases it's just not valid to plugin devs
...
minecraft uses TCP
this guarantees a packet order
lol
correct, that is why it doesnt show up in order
It assures that packets arrive. But the order is unspecified.
As long as the two messages were sent on the same TCP connection, order will be maintained. If multiple connections are opened between the same pair of processes, you may be in trouble.
1.8 sends swing packet then attack, 1.9 sends attack then swing, but viaversion messes this up and makes 1.8 clients have the 1.9 packet order instead
part of the TCP protocol is that it knows where to put the packets in the receive buffer when they arrive and dumps all the duplicates
That is Mojangs IPC
IPC?
Inter-process communication
how and what order processes/systems/components talk to each other - thats a pretty generalized explaination
anyway it seems viaversion determined that 1.9 rules are good enough for 1.8 and do not justify a different handling , or the latency was too great in conversion
they work better for finding things in one spot
well you can, but if you do, noone will answer your question
well unless they immediately joined the thread
nice
but in general you could say, threads are only useful here if many people are asking different questions at once
if you're the only one, / chat is currently idle just directly ask without a thread
.
How would I smoothly rotate an entity? Just teleporting it a little every tick sounds a bit disgusting if done too multiple entities at once
?jd-s
My PlayerInteractEvent which executes when a player steps on a pressureplate is spam-called, that means it gets called very often as long as the player stays on the pressureplate. is there a solution to this?
you need to remember that spigot and nms does a lot of stuff each tick and it does not lag
so why would your for that just teleports each entity each tick lag the server?
Last time I used teleportation for smooth movement, the server crashed at one entity, that's why I'm trying to avoid this as much as possible
bro
bro
1 entity crashed the server
fuck spigot π‘
could you show the code?
or just an idea of what you did
Runnable maybe? Lerp Location.setDirection(vector)
i do a lot of things each tick
ideas?
Well, maybe the teleportation was just a bit too excessive π€
Will try again with bigger numbers and see if it's still smooth.
Also, this time I only want smooth rotation, not movement, so that might be another plus π€·
entity.setVelocity maybe
could you leverage setVelocity
Not for rotations though? π€
i never saw this π€
It actually is being spammed though
basically the event calls every tick a player is standing on the pressure plate. I want it to call only everytime you get on it, until you step away and step on it again
good idea, but how do I detect if they step away?
without PlayerMoveEvent if possible
hmm do you get a playerLevelChangeEvent when you stop off teh plate?
Well, I guess you'd have to use a Scheduler then, but I personally think that would be worse than the PlayerMoveEvent
plates would be so much easier if they were part of switch
what if 2 entities where on the same plate though. don't know if that matters for your use case.
you're right.. it would matter, the pressure plate represents a checkpoint
how do I use this?
still an issue if more then one entity
depending on how the press event is handled on the server yeah
would have to test if each player is independent or not
for saving my code should i use github or gitlabs?
so how do I use this?
you would should still be able to know who is on the sensor, if it changes press state for that entity or player is the question
with a single person you would just have a quick test to see if the sensor is pressed
where would I test for this (in which event etc)
myself, i would test as soon as I could when I expect the earliest activation could be identified from other actions using the same event - you want to skip processing and exit if they did not get off the sensor
Personal preference as far as I am concerned it's all GIT. Depends on what you are looking for as far as collaboration and potentials of future support.
driving again ..
Player player = (Player) sender;
Pig pig = (Pig) player.getWorld().spawnEntity(player.getLocation(), EntityType.PIG);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this.mobRush, () -> {
Location location = pig.getLocation();
if (location.getYaw() >= 360)
location.setY(0);
location.setYaw(location.getYaw() + 0.1F);
pig.teleport(location);
}, 1L, 1L);
This does literally nothing, nice π
could you give a code example? i dont really understand what you mean
location.setY(0);
Imagine
Ops, but still, that's not the critical part of the code π€
location.setYaw(location.getYaw() + 0.1F);
Any idea as to why my events aren't firing? here is my code:
public final class Ranks extends JavaPlugin {
@Override
public void onEnable() {
this.saveDefaultConfig();
getServer().getPluginManager().registerEvents(new MyListener(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
event.getPlayer().sendMessage("Welcome!");
}
Actually it's stupid because you need methods like this to get a proper velocity which will rotate
@NotNull
private static Vector getVelocityVector(@NotNull Vector vector, Player player, float side, float forw) {
vector.setX(0.0D);
vector.setZ(0.0D);
Vector mot = new Vector((double) forw * -1.0D, 0.0D, (double) side);
if (mot.length() > 0.0D) {
mot.rotateAroundY(Math.toRadians((double) (player.getLocation().getYaw() * -1.0F + 90.0F)));
mot.normalize().multiply(0.25F);
}
return mot.add(vector);
}
So... There is velocity which can also rotate you?
considering the code shown is correct the issue has to be somewhere else. Did you build and move the plugin.jar into the server plugins folder?
Yhm
I had the same problem (still happens on 1.16.x version) so that's what I used to fix it
Whatever this method does, it does not rotate these pigs π (Or I'm using it wrong)
Yes, I event added a 'hello world' command to test the plugin and it works
Try removing teleport method - it COULD mess up something - not entirely sure though
?paste
Maybe you have also set somethinv with entity settings
That is my full code:
package com.shalev.ranks;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class MyListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
Bukkit.broadcastMessage("Welcome to the server!");
}
}
package com.shalev.ranks;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public final class Ranks extends JavaPlugin {
@Override
public void onEnable() {
this.saveDefaultConfig();
getServer().getPluginManager().registerEvents(new MyListener(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (label.equalsIgnoreCase("HelloWorld")){
sender.sendMessage("Hello World!");
}
return true;
}
}
Might be doing something wrong, but this is the result
wait lemme lookup the javadoc for bukkit rq
so um
it sys that Bukkit::broadcastMessage() sends a message to all players
I've worked with events extensively
i know that your code is correct
A command is not an event?
the only thing i can think of is that you forgot to upload your plugin or reload said plugin
@sage dragon afaik its an internal one
What-
I created the event just to test the plugin , for some reason this.saveDefaultConfig(); messes the plugin , any idea why?
do you have a config.yml in the resources folder
Oh, sorry, should've read everything π€
on the server?
no in the plugin
Any way to prevent a user from joining if they dont have texture packs for the server set to enabled>
public ItemStack glass(){
ItemStack glass = new ItemStack(Material.RED_STAINED_GLASS_PANE);
ItemMeta glassmeta = glass.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("Only hot bar challenge");
glassmeta.setLore(lore);
glassmeta.setDisplayName("Challenge");
return glass;
}
saveDefaultConfig only saves something to drive if you include a config.yml in the resources tab of your plugin
how can i accses the glass from anywhere?
save it to a class
as a list
Well, only if you don't have a config.yml file in your jar file, I guess π€
No, I only have plugin.yml there
yea
Caching
???
There is for sure a method to check that
Isn't this the command to create the config.yml file? Or do I need to manually create it?
it saves the preset config file to the server
if you want to make an empty config file
Got it https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerResourcePackStatusEvent.html
declaration: package: org.bukkit.event.player, class: PlayerResourcePackStatusEvent
File.mkdirs(); File.create()
Ah, I see, thanks!
how?
First of all, how do you want to access it?
Do you want to save it with a key or as a key
Or maybe just save it to have it later on
i have no clue
For what do you need it?
ok so i want to make a glass item stack in the main class
and accsess it from 4 different events
Then you can use hashmap
HashMap<K, ItemStack> hashMap = new HashMap<>();
and then access it by using own getters
and setters to the hashmap
Thanks!
@EventHandler
public void ResourcePack(PlayerResourcePackStatusEvent event){
if(event.getStatus().equals(PlayerResourcePackStatusEvent.Status.DECLINED) || event.getStatus().equals(PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD)){
event.getPlayer().kickPlayer(ChatColor.RED + "You need to have resource packs enabled, and download the resource pack to play on this server!");
}
}
does it need to be in its own class?
No
so where do i put HashMap<K, ItemStack> hashMap = new HashMap<>()
How I can update libraries in spigot? I should use BuildTools?
Wherever you want
Key
This can be any parameter which you will use to recognize the value (item stack) from others
It is mostly replaced with String / uuid
Not entirely sure if you want this but you could also use pdc
?pdc
i can help you with it
i have alot of questions can i ask them here?
go ahead
Why does kicking sometimes result in an Internal Exception: java.net.SocketException: Connection reset?
How do I make it ALWAYS leave a kick message?
event.getPlayer().kickPlayer(ChatColor.RED + "You need to have resource packs enabled, and download the resource pack to play on this server!");
Cause this doesnt seem to work sometimes
u should be able to have resouse packs enabled
you can set a server to Disabled
ok so i followed a youtube tutorial to make a spigot world, well i made the server and i can start it by using the .bat file, but my reason was so i could transfer my solo world to a server so i could use worldedit, but im not even op and i cant get the world to transfer idk how
is that a question?
im very new
uhm yes i guess
#help-server pls
i guess
#help-server because #help-development (channel you are currently in ) is only for plugins / java question related
As zacken02 said, you would use a set and the isPressed() to see if they are new or if its the same, if they are new you would run all your normal stuff, if the same, skip everything until the next call. You want to leave as quick as possible if the pressureplate spams events. - I suspect that you will also receive an event when they leave. The big question is if each player will have separate pressureplate states or not. - If not, then you will need to check the players movement to the blocks surrounding the plate
How I can update libraries in spigot? I should use BuildTools?
they just join and use the bar at the bottom of teh thread
kk
update as in change version?
update libraries inside spigot (no version minecraft)
In entitiydamagebyentity Event Does getEntity means the entity who got damaged?
clean and build again
?
Then yes you could create a fork and update things
In entitiydamagebyentity Event Does getEntity means the entity who got damaged?
ah yeah, i misunderstood
or maybe an option without creating a new project on github? π
Have patience and check javadocs
I meant that the libraries inside are not always updated
?jd s
Spigot isn't on github. Anyways you don't need a git repo. You can update things with out one
hmm oke how I do this?
it only says about the getdamager
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
How i can get the MainHandItem of an entity
wondering if they would produce something usefull
PlayerInventory#getItemInMainHand()
I can't its an entity
okay then get the EntityEquipment
then do EntityEquipment#getItemInMainHand
LivingEntity has a method getEquipment()
might want to avoid seconds - or handle your TPS variance
Oh It worked thx
avoiding seconds heh what
well seconds will be affected first , if your TPS goes to 19.5 how many are in a second?
20 ticks are 1 second if you have 20 tps
if you only have 19.5 tps, then 19.5 ticks are 1 second
How can i get the entity which got damged in EntityDamgeByEntity event?
at 19.5, your minutes will still be close to valid
event.getEntity()
the input basically comes from a calculation between two earlier saved epoch times
that is a good method
also you could make a method to add the plural for you, could make this a bit cleaner
thx
this is what i do for example
/**
* If the count is 0 or over 1, adds an "s" to the given string
*
* @param count
* @param ofWhat
* @return
*/
public static String plural(final long count, final String ofWhat) {
final String exception = getException(count, ofWhat);
return exception != null ? exception : count + " " + ofWhat + (count == 0 || count > 1 && !ofWhat.endsWith("s") ? "s" : "");
}
how to add potion effect to an entity
?jd go to javadocs, open the Player class, then look for "potion effect"
How do I check if a path in a config file exists?
Use contains
exception?
How so?
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
or that
Oh ok , thanks :D
i can send that to you if you want it, it accounts for stuff like cactus, the plural being cacti
you want the whole piece ?
alright :)
?pdc
pdc yourself, bruh
Oki :3
Why is literally any mob which is not a player immune to rotation teleportation π
Well, for some reason they are on my localhost server...
Trying to make a mob spin
Player player = (Player) sender;
Zombie zombie = (Zombie) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this.mobRush, () -> {
Location zombieLocation = zombie.getLocation();
Location location = new Location(zombieLocation.getWorld(), zombieLocation.getX(), zombieLocation.getY(), zombieLocation.getZ(), zombieLocation.getYaw() + .1F, zombieLocation.getPitch());
zombie.teleport(location);
}, 1L, 1L);
Right now it's this
setRotation? That didn't work either
Thanks, that seems to be working...
But why didn't it work with good old yaw and pitch?
it seems that this would do exactly the same https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Location.html#setDirection(org.bukkit.util.Vector)
declaration: package: org.bukkit, class: Location
lol
@tardy flame what is group id again
So I am made plugin for a customer and I want they don't redistribute it, so they can only use it for there server.
Now question is there any licence I can use for that?
your limitations depends if you included others code
Do you mean a licensing system or a legal licence?
legal
what should my group id be, and what should my artifact id be?
probably just ARR
the group id should usually be your reverse domain name. I.e. example.org becomes org.example
so
me.CyberWolfie?
if you own the domain, yes
Even though many do it anyways
just note that it should be lowercase
I think just the thing that companies use for their games. Copyright <YEAR> <COPYRIGHT HOLDER>
Something something BSD i think
BSD allows redestribution
It does?
Yeah, it's about as lax as MIT
So that would be like file in jar
with info about it
You just cannot use it for advertisements
Some people use their email addresses for this
oh, and if i dont own a domain?
However some time ago it used to be convention to use have groupId and artifactId be identical if I look back at very old maven artifacts
This might have reasons that are no longer valid however
how do you call an entities main hand?
?jd-s
do you have your code in a vcs?
what is a vcs
version control system
Github
oh, i can
or gitlab
so myplugin\username\com.github?
how?
like long lat
or zip?
com.github.username.myplugin
io.github.exampleuser
oh
io.github.thestorm?
anyone know how to place a block in a specific x, y and z location
yeah
kk
if when you visit that url it takes you to the correct spot, yes
Get the Location on that position and set the Block
Or use World#setBlockData(int, int, int, BlockData)
thx
thanks
its actually one of the features of java that I appreciate, saves searching for a lot of stuff
what?
reversing the id and ending up in or near the code
also does anyone know how to make a specific location for a Player unbreakable
Sure. There are several ways. But this highly depends on the scale and what you are trying to achieve.
how would I go about making a specific block unbreakable
or even a large selected area unbreakable
Those are 2 completely different requirements
how would I go about doing one of them
Which one?
https://github.com/TheStorm135
i dont have a .io
the one without doing anything is to use your spawn protection
But there are several ways if doing either
which do u recomend
github.io is valid as that is github pages, so if you set it up you have a small web-page you can use
you can follow the instructions an create a project page
should i?
Depends on what you are trying to do.
Do you want protect areas or do you want to
protect random blocks which have no correlation to each other
protect areas
Then i would recommend using BoundingBoxes
You can span a BoundingBox with 2 corner Blocks
quick question, can 1.18.1 plugins work on 1.18.2 servers?
lol
also, how would I transfer a plugin to an updated version
what
what licens should i use on github so people can use my stuff, but they can share it with other people
If only the API is used then it should run on at least the upcoming 3 versions.
cool, but dont bounding boxes just select a large area. or wait, is that what allows u to change the area
yes just the api
GPL? But you should probably search the net for that.
do you want attribution or not ?
no
It doesnt change the area at all. It just defines a virtual area. And you can check if a Block was broken in this area or not.
net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:120)
net.minecraft.server.v1_16_R3.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:536)
net.minecraft.server.v1_16_R3.World.getType(World.java:745)
org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.getNMS(CraftBlock.java:79)
org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.getBlockData(CraftBlock.java:162)
com.welcome234.infgenerator.OreVein.generate(OreVein.java:42)
com.welcome234.infgenerator.BetaPopulator.populate(BetaPopulator.java:157)
net.minecraft.server.v1_16_R3.Chunk.loadCallback(Chunk.java:891)
net.minecraft.server.v1_16_R3.PlayerChunk.lambda$a$15(PlayerChunk.java:775)
net.minecraft.server.v1_16_R3.PlayerChunk$$Lambda$4034/559373399.run(Unknown Source)
net.minecraft.server.v1_16_R3.PlayerChunkMap$CallbackExecutor.run(PlayerChunkMap.java:204)
net.minecraft.server.v1_16_R3.ChunkProviderServer$a.executeNext(ChunkProviderServer.java:1080)
net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119)
net.minecraft.server.v1_16_R3.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:536)
net.minecraft.server.v1_16_R3.World.getType(World.java:745)
org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.getNMS(CraftBlock.java:79)
org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.getBlockData(CraftBlock.java:162)```
My generator causes the server to crash on load
only if they use it in a yt vid
oh i see
Full stack trace pls
Then you have a recursion problem
then look at the differences , you narrowed down your options a lot by what you want and answering that question
thanks
This is inside the BlockPopulator for my generator
public void populate(final World world, final Random random, final Chunk chunk)
It's inside this
if (var26 * var26 + var27 * var27 + var28 * var28 < 1.0 && world.getBlockAt(x, y, z).getBlockData().getMaterial() == Material.STONE) {
world.getBlockAt(baseX, baseY, baseZ).setType(minableBlock, false);
}```
This part is crashing it
On the getBlockData part
Looks like you decompiled the code and are trying to edit it
Likely because the getBlockData call requires the chunk to be generated first
But I have no further idea without further context
The long stack trace is from a for loop thing
how can i create yml file for each player?
Use their UUID as file name
<uuid>.yml
ok
if you were to show the whole stacktrace (or at least the looping bit) and the relevant code it would help much more
Wait I did world.getBlockAt(x, y, z).getType() instead
Since it will return the same result
Still causes a crash
what do i put in artifact iD?
On same line again
Because it still requires the chunk to already be generated
get the data from the generation context
the world doesnt know about the chunk yet because you are still generating it
how can i use FileConfiguration outside of main folder?
its just showing error when i use it in another class
what error specifically?
Cannot resolve method 'getDataFolder' in 'JoinLeaveListener'
it works in main class
probably a learnJava moment
Because you are in an instance of JavaPlugin and getDataFolder is a method of JavaPlugin
^
i smell a learn java coming
eek, still having difficulty with boudingboxes, not sure how to disable the players ability to break blocks with BoundingBox(0.0, 0.0, 0.0, 100.0, 100.0, 100.0)
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
public boolean generate(final Material minableBlock, final int numberOfBlocks, final World world, final Random random, final int baseX, final int baseY, final int baseZ) {
for (int var13 = 0; var13 <= numberOfBlocks; ++var13) {
for (int x = var20; x <= var23; ++x) {
final double var26 = (x + 0.5 - var14) / (var18 / 2.0);
if (var26 * var26 < 1.0) {
for (int y = var21; y <= var24; ++y) {
final double var27 = (y + 0.5 - var15) / (var19 / 2.0);
if (var26 * var26 + var27 * var27 < 1.0) {
for (int z = var22; z <= var25; ++z) {
final double var28 = (z + 0.5 - var16) / (var18 / 2.0);
if (var26 * var26 + var27 * var27 + var28 * var28 < 1.0 && world.getBlockAt(x, y, z).getType() == Material.STONE) {
world.getBlockAt(baseX, baseY, baseZ).setType(minableBlock, false);
}
}
}
}
}
}
}
return true;
}```
I truncated all variables since it's too large
Hadoken
public void populate(final World world, final Random random, final Chunk chunk)
I am using the world variable from this
decompile much? π₯±
You simply maintain a collection of BoundingBoxes per World and if a player breaks a Block you check if its inside one of the Boxes.
basically, the main class extends JavaPlugin which has its own methods. one of its own methods include that, so only classes extending the javaplugin can use it. but only your main can extend javaplugin, so you can include a static instance of the main class within your main and access it from everywhere with public static PluginName plugin; and plugin = this; in the onEnable
you should see hierarchy and access modifiers
thanks
is that really your code? - how your ide let you use preincrement is curious
what is artifact id?
basically project name but not
ok if im wroking on a particles plugin what should it be calledf
This how i was supposed to make it?
Yes
@quaint mantle making events in the main class isent recommanded
ik just removed it
now whenever you need to do something specific to your plugin, say getting data folder, you can just use it from your main TestPlugin.plugin....
Usually you would:
Not let your JavaPlugin class implement Listener
Make a getter for your plugin field instead of making it public
How can I get a player who clicked a certain item in a inventory
InventoryClickEvent -> getWhoClicked()
yeah but on a certain item
is there a way to get the itemstack of a Projectile on 1.8?
Get the clicked item and check its properties.
alr
Use a real version that is still supported. 1.8 support was dropped years ago and only a minority still uses it.
Just some info. For fromX -> and use Y
when i declare Supplier<String> sup = obj::getName the getName method wont be called until i call Supplier#get right?
yes
its lazy
great
fail
no
?jd-s
declaration: package: org.bukkit.command, interface: TabExecutor
ee
see
it worked for me
just an interface which extends both CommandExecutor and TabCompleter
heresy, cant extend more than 1 class
no
TabExecutor
its one class
but has all the funcs of CommandExecutor and TabCompleter
I ported from Minecraft Beta 1.7.3 since I am making an old world generator
interface can
interface extends other interfaces lol
yes they can
theoritcally it should be implements Otherinterface but as the current class is already an interface it is 'extends' π€·ββοΈ
I cant find a way to get who clicked on a certain item
What do you want to do?
I thought "interfaces cant be extended but can be implemented" but then wondered how an interface would implement another
what themes do we use?
something like getWhoClicked(); except I wanna check if they clicked on a certain item instead of the entire inventory
themes?
darcula, a monokai, one something, xcode dark, light, etc
For what purpose? Do you want to create a GUI?
one dark vivid
Get the item
check the InventoryClickEvent#getSlot
monokai filter spectrum π―
Is it not getCirrentItem?
Current*
getClickedItem()?
Doesnβt exist
ye forgot about that method
Itβs current
getCurrentItem()
7smile
Is there a bot in this server to show documentation for a method?
yes
We are not at the part where we solve the problem. I feel like this is an xy problem
what does getCurrentItem do?
?
Then you should not check the clicked item but rather the clicked slot.
Yeah
that's what I wanna do
Oh ok
anyways if im listening for console input (not in the context of spigot), do i need to do that on another thread than the thread when the other code runs on?
Got it
Good question. I would assume yes, but idk
I think only for receiving a link to the full documentation
Alr
what does getCurrentItem do btw
why am i getting an error message with "Non-static method 'openTeleporterGUI(org.bukkit.entity.Player)' cannot be referenced from a static context" in this code ?
gui = Bukkit.createInventory(null, 9, "Lobby Teleporter");
gui.setItem(0, new ItemCreator(ChatColor.RED + "Bedwars", Material.RED_BED).build());
gui.setItem(2, new ItemCreator(ChatColor.RED + "PVP", Material.DIAMOND_SWORD).build());
gui.setItem(4, new ItemCreator(ChatColor.GOLD + "Spawn", Material.COMPASS).build());
gui.setItem(6, new ItemCreator(ChatColor.RED + "Survival Server", Material.GRASS_BLOCK).build());
gui.setItem(8, new ItemCreator(ChatColor.RED + "Events", Material.CAKE).build());
player.openInventory(gui);
}```
```public void OnKeyClick(PlayerInteractEvent event) {
if(event.getItem() != null) {
if(event.getItem().getType().equals(Material.COMPASS)) {
TeleporterGUI.openTeleporterGUI(event.getPlayer());
}
}
}```
there should be like ?jd-s Command#getName command
What does that mean? It depends how you listen for this. You can also inject a listener on the stdout print thread.
Ik
Cause your not instantiating the class
Your trying to use it like TeleporterGUI.method
Because you are trying to call an instance method in a class context.
thats not it i believe
You need to create an instance
Strike two π
So if its a stateless utility method then you should make it static. Otherwise you should instantiate the class
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
cmd.exe
which is also the place for the outputstream i guess
Look up how object oriented programming works if you donβt know how to instantiate @signal meteor
ty