#help-development
1 messages ยท Page 1800 of 1
well aint that code that is some lines ? i mean, i cant read the whole site\
You need to learn how to create a plugin first.
If you don;t know Java you need to learn that first
have you made a plugin before?
nope
then start there
intellij ๐
eclipse is good
yess
use whatever you prefer
welp i starteed coding with eclipse, ig im gonna continue with eclipse
eclipse bad intellij idea good
Yes, see ChatPaginatir
So there is no way to add things to the end of an existing config file w/o losing comments OR having a server owner delete their already existing config file?
How do plugin developers add functionality and items to their config files down the line as their projects grow? o.o
There must be some way around this issue?
Pick in a lowercase string?
theres also the looking for an uppercase char in an all lowercase string part
use .toLowerCase().contains("pick")
ye i changed that to see if that was maybe the problem
pog
the problem was
this
rip
about the plugin, how can i assosiate it with dispencer ? my idea is, the dispencer will drop 2 types of items (wets say oak wood and birch wood). How can i make the plugin to drop oak wood to 2 players only at 100% ?
only at 100% - guaranteed drop
Adding functionality or options to config.yml
Hey if i run "./makePatches.sh" in my changed craftbukkit the following error shows up:
line 5: $1: unbound variable
any fixes ?
help ?
I dont think it is possible to know who activated the dispenser 100% correct
ah ok thank you
how can i make plugin that makes 2 teams, 2 guaranteed players (wets say Player steve and player alex) will be playing on one of the team
or if a plugin exists that can do this do you know name
declaration: package: org.bukkit.scoreboard, interface: Team
how can i generate the 1.18 server with buildtools? It's generating 1.17 still
--rev 1.18
k thanks
@Override
public Map<String, Object> serialize() {
Map<String, Object> data = new HashMap<>();
HashMap<String, Map<String, Object>> serializedSkills = new HashMap<>();
for(Map.Entry<String, SkillObj> entry : skills.entrySet()) {
serializedSkills.put(entry.getKey(), entry.getValue().serialize());
}
data.put("skills", serializedSkills);
data.put("race", this.race);
data.put("lvl", this.level);
return data;
}```
```java
@Override
public Map<String, Object> serialize() {
Map<String, Object> skill = new HashMap<>();
skill.put("level", this.level);
skill.put("exp", this.exp);
skill.put("max", this.maxLevel);
skill.put("name", this.name);
return skill;
}```
How would I deserialize this?
Need to get the skills out of serializedSkills
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
int lvl = (int)map.get("level");
int exp = (int)map.get("exp");
int max = (int)map.get("max");
String name = String.valueOf(map.get("name"));
return new SkillObj(lvl, exp, max, name);
}``` here's the deserialize for SkillObj
Why are there two different methods here
Is the second one a "skill"?
Second one is a SkillObj, first is Playerdata containing a hashmap of SkillObjs
And the problem is?
Deserialize it the same way you do here
If you have a Map<String, Object>, you can cast the object to anything
So in this case I believe you want to get the serialized SkillObj from Playerdata
HashMap<String, Map<String, Object>> serializedSkills = new HashMap<>();``` the Object in question is another map
You can do
HashMap<Whatever, Whatever> anotherMap = map.get("Whatever");"```
And the cast itself so that your ide won't freak out
I'm so confused I'm sorry
I've been working at this for hours
Map<String, Map<String, Object>> skill = (Map<String, Map<String, Object>>)map.get("skills");```
Is this basically what you're saying?
Actually that worked!
Did somebody notice that the ClickEvent.Action is completely missing?
I cannot get it to work in 1.18 ๐ฆ
is there a cleaner, more graceful way to disable a plugin onEnable instead of this.getServer().getPluginManager().disablePlugin(this);
Whats wrong with this?
No not really
Technically could raise an exception ยฏ_(ใ)_/ยฏ
@ivory sleet do you know whats up with this?
its quite ugly in console and not very clean
ClickEvent.Action?
looking for a way to do it without all the spam
Yep not working at all
InventoryAction ?
ClickEvent is bungee ?
Yes sorry. I mean the chat api : import net.md_5.bungee.api.chat.ClickEvent;
Console spam?
well its what happens when you try to use that method of disabling the plugin on startup
nope its simply the console output when that method is fired, it disabled the plugin, just very sloppily
hmmm weird, because i can see this:
import net.md_5.bungee.api.chat.ClickEvent.Action => Cannot be resolved
import net.md_5.bungee.api.chat.ClickEvent$Action => Works fine. I dont get it
what dependency did you add? Can you show your pom.xml or whatever?
it's working fine for me too
btw your import should look like this usually:
import net.md_5.bungee.api.chat.ClickEvent;
For testing purposes, I just use a normal jar import.
I added the spigotmc-1.18-shaded.jar to my libraries
does it work when you directly import ClickEvent instead of the nested class, and then access it as shown above using ClickEvent.Action?
hm very strange. which .jar did you add as dependency? the one that buildtools created? Because I think in 1.18 it only contains some bootstrapping thingy
This is broken in 1.18 alot won't work.
well nothing's really broken. It's just different now
I have added the marked jar to my library
yeah but you can just add everything out of the "bundler" that is created when running the server
open that file with winrar and check whether it actually contains that class
Broken
I know. Or just let maven handle everything and forget about doing stuff manually
can you explain what you think is broken? because everything's working just fine for me
yeah, i refused to use maven until 1.18 changes ๐
Looks like it does
Think, no. What is broken. Alot. Read my convo about it above.
strange. no idea, sorry. maybe just switch to maven and see if it'll magically fix it ๐
can't find it, you got a link?
@stone sinew
Guess thats a plan xD Problem is that i am lazy. I have like 30 Dependencies and not every plugin does have a maven repo. I think thats a problem
search for it.
you can easily install those things to your local repo and then forget about them ๐
friendly as always lol
"stuff is broken" - "what stuff?" - "search for it. I won't tell you" lol
Playing a game. Can only talk in bursts ๐
lmao
Okay thanks. I will give it a try ๐
works for me, depending on the -shaded jar
maybe you just don't know how to do stuff because everything seems to be working for the majority of people @stone sinew
your ide just seems broken
try to invalidate caches
try restarting it, clearing caches, reloading project, etc
Weird. It just works for me if i import ClickEvent$Action
Tried all jars, tried maven etc... still get errors.
But thanks
I'm fairly certain thats illegal java
are you looking for help or do you only want to claim that stuff is broken? because if you're looking for help it would be useful if you could send the link to your previous conversation again
so your IDE even compiling that is wrong
yeah straight javac will not compile with a $ for me
is that eclipse?
yes
alright then I'm not surprised lol
I feel like reloading/clearing cache will fix it
java IDEs still havent figured out reliable caching
that is very very strange
you actually get it to compile with this?
import net.md_5.bungee.api.chat.ClickEvent$Action;
Yes
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/mfnal/IdeaProjects/Test/src/main/java/de/jeff_media/test/PDCCommand.java:[10,32] cannot find symbol
symbol: class ClickEvent$Action
location: package net.md_5.bungee.api.chat
Could it be a problem that 5 other plugins in my library implement that ClickEvent.Action?
that is what should actually happen when using the $ symbol lol
wdym implement
is that some kind of strange eclipse magic? that it just shows a $ sign there to show that it's a nested class, while it actually uses a normal . ? ๐
because as md_5 pointed out, that code should NOT be able to compile
It even tells me that the class is there
those do not "implement" ClickEvent, they just have a class with the same name
that's no problem because that's what packages are made for
I really dont want to leave it like that. But if its working, I guess its fine
somehow it seems to be normal that eclipse uses the $ sign but that makes no sense as it also doesn't do anything else than passing the whole stuff to javac when building
@tender shard with the amount of times you asked you could have searched it up.
yeah because I got nothing better to do than to search for the stuff you are looking help for, instead of you just sending it again
Huh
xD Oh man idk. I will try to switch to maven. Maybe that changes smth
only stuff I can see @stone sinew is you having trouble with Files.copy and that has nothing to do with spigotr / 1.18
eclipse doesnt compile with javac
oh it doesn't?
it has its own compiler, ecj
I just assumed that. Haven't used eclipse for years
yeah maybe it's indeed a weird eclipse thing then? idk
Hm maybe I am fine then
I'll just start eclipse and check whether it happens to me too
Alright thanks
...
what .jar did you use as dependency?
it would be way easier to just use maven. buildtools automatically installs the correct dependency to your local maven repository
otherwise, you can find the spigot server .jar inside BuildTools/Spigot/Spigot-Server/target
or something like that
Guys, how do I compile with the new Packets when it blocks out the 1.17 ones? Like GameProfile, EntityPlayer are not showing up, I'm using the Mojang & obf imports and all as said in the forum thread
GameProfile is in authlib
it's a separate library now
if you extract the spigot server .jar file, you can find it inside META-INF/libraries
read the convo
I'll just help people who are nicer instead, thanks
when you're using mojang mappings, it's not called EntityPlayer but simply Player IIRC
correction:
it should be ServerPlayer
import net.minecraft.server.level.ServerPlayer
e.g. like this:
final ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
Wait, how do you find the changelog from 1.17 to 1.18 packets?
That'd be super helpful
How am I not being nice. I already explained to you where to find the answers to questions you're asking. And that I can only talk in bursts
I don't think there is any. It's not part of the API
Oh then how did you know its been changed to ServerPlayer from EntityPlayer?
I am trying to help, and everytime I ask a question that's relevant to your problem you want me to "go look it up" somewhere instead of just answering, so I prefer to not waste my time and help other people instead who actually reply with answers
it has not changed. Mojang always used that name
if you want to use the "old" names, don't use the obfuscated mappings
but tbh you should use the mojang mappings for NMS
Yet instead you just respond with questions that are already answered.
that way you don't have to deal with fields and methods called "ai()", e, ae(), etc
yeah go ask other people then
But I don't get it, CraftPlayer doesn't show up in the new import
CraftPlayer is part of CraftBukkit, not NMS
what .jar did you add as dependency?
I'm using the remapped-mojang jar for NBT and the shaded-api for the API part
remapped mojang should contain CraftPlayer
here's the import, working fine for me with just spigot .jar
also remapped-mojang
Maybe its this error:
The type com.mojang.authlib.GameProfile cannot be resolved. It is indirectly referenced from required .class files
are you using maven?
No
Manually
go to your buildtools directory
open spigot .jar with winrar or sth similar
then go to META-INF/libraries
you have a authlib.jar inside there
extract it somewhere and add that as dependency, too
it'll work then
I had the same problem but I installed it to my maven repo instead. however adding it manually will work fine, too
@sullen marlin would it be possible for buildtools to automatically install all the libraries inside META-INF/libraries to the maven repo? I think I alraedy asked you something similar a few days ago but I have missed your reply
It's does....
or maybe I don't understand how it works in 1.18, but I had to manually mvn install:install-file the authlib
oh really?
hm
Thats why using maven works
are you sure it also installs all those libs when NOT using the mojang mappings?
Yes
strange, I must have been stupid then, thanks^^
is there any event for everytime a player gets hit?
i'm willing to aply a potion effect to a player everytime he gets hit by a specific sword
with "hitting" you mean taking damage?
If so: EntityDamageByEntityEvent or simply EntityDamageEvent
np
so basically
use EntityDamageByEntityEvent, then get the damager, check if it's a player, if yes: cast it to player and check their main hand item
ok, ty so much : )
Wait what happened to the Packet sending function?
why?
Now it becomes send(<Packet>)
I'm trying with:
connection.send(new PacketPlayOutNamedEntitySpawn(npc));
didnt you say you use mojang mappings?
PacketPlayOutNamedEntitySpawn is NOT the mojang name
here's how I'm sending packets
((CraftPlayer)player).getHandle().connection.connection.send(packet)
that's for 1.18. Are you on 1.18 or 1.17?
1.18
connection.connection ?
are you sure you using mojang mappings? because as said, PacketPlayOut... is not the mojang mapped name
yes, it changed in 1.18
the first "connection" refers to ServerPlayer's ServerGamePacketListenerImpl
and that also has a field called "connection" of the type "Connection"
Yes but I'm confused on how to use ServerGamePacketListenerImpl, do we declare the entire Packet inside like:
connection.send(PacketPlayOutNamedEntitySpawn(npc));
check out this:
it has some methods for spawning fake players etc
maybe it'll help you
PacketUtils.sendPacket is basically the same as the sendPacket method inside that class
oh nice
but I need it for fake entities
for holograms using area effect clouds
I assume that's not possible yet? I just send the packet for "yo there's an invisible entity called asdasdasd nearby" and then hide it again when I don't want to show it to the player anymore
I'd love to try to contribute something to the API sometime but I literally have no idea lol
@EventHandler
public void onHitByFluSword(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
Player damager = (Player)e.getDamager();
if(damager.getInventory().getItemInMainHand() == FluPotion.FLU_SWORD){
if(e.getEntity() instanceof LivingEntity) {
FluPotion.FLU_POTION_EFFECT.apply((LivingEntity)e.getEntity());
}
}
}
}
did I make it correctly?
there are some interesting things here that seem like they are 100% doable within the bukkit/spigot api
namely the Skull owner thing
The method sendPacket(Packet<capture#1-of ?>) is undefined for the type ServerGamePacketListenerImpl what..
if(damager.getInventory().getItemInMainHand() == FluPotion.FLU_SWORD){
should I use .equals or == in this case?
== because .equals is an old and should be obsolete and inefficient way of comparing variables.
ok
Omg the ServerGamePacketListenerImpl # sendPacket(Packet<packet>) is so hard to grasp
Wait what
What the hell are you saying
You are comparing two ItemStack objects, use equals or isSimilar
arrow type code is bad
I read on Spigot forums they said the .equals method is some obsolete way to replace the == which didn't work on some comparisons
They said the == method is more efficient
== has it's own use cases
ok, thanks
objects aswell
what could I do to improve my code?
Anyways how to handle the 1.18 Packet sending? That got me stumped
Sure, but that shouldn't be done unless you 100% know how the objects you're using act
how?
the skull owner thing
I really need help with the 1.18 packet sending please
thanks
np
the == part will probably not work
you should use equals instead
and also
it will break once the item lost durability
what? you should use it to make sure that object A is the same as object B
you should use a custom PDC tag to check for your custom item
true but in this case, this item will probably exist many times and so the itemstacks won't be ==, nor equals once it lost durability
^
Can someone give me an example of the 1.18 packet sending method? The one from the library still uses 1.17 NBT
Yeah that one uses 1.17 NBT
it does not use NBT at all
idc about the issue, i refer on his "not objects"
yeah you're right on that
I tried copying that over to my code to test it has import problems
because you are not using mojang mappings
I already said that 3 times
ok, ty
not sure, but im pretty sure? u can use SkullMeta for it
for offline players, yes
for custom base64 textures, no
oh right weve gone over skulls..
I had to change PlayerConnection to ServerGamePacketListenerImpl and the getHandle().c is still the old one, which is now getHandle().connection;
if it's possible to use base64 without NMS, let me know pls ๐ I don't think it's possible
An example of "you can do it, but that doesn't mean you should". What is an example where comparing an object using == is better than using the built-in equals.
I am using Mojang Mappings
depends on if u can make a fake player without nms.. bc if u can supply the GameProfile somehow thru api then it should work
That nearly all objects support, along with the ability of API's providing their own equals implementations
I'm not even using PlayerConnection anywhere in my 1.18 code, no idea what you are looking at
I have this in my external library: spigot-1.18-R0.1-SNAPSHOT-remapped-mojang.jar
That's the mojang mappings jar
It still shows import errors
but you still have the old packet names so something's not right in your dependency setup
e.g. packets are not called PacketPlayOut... but Clientbound...
in mojang mappings
e.g. PacketPlayOutEntitySpawn (or sth like that) is actually ClientboundAddEntityPacket in mojang mappings
How am I supposed to find that out?
There's no changelog like you said
you are not supposed to find it out, it's not part of the API
1 help guys
???
I simply looked through the packets and looked for it myself
there is no official changelog
because it's ondocumented
because it's not part of the API
it's internal MC stuff
ask your question
You said CraftPlayer has changed to ServerPlayer, stuff like that. I looked through the new 1.18 classes with a decompiler, it doesn't mention the new ones
the "built-in" equals is by default ==. the usecase of == at objects is to make sure, that both pointers point to the same adress. thats not an example of "you can do it, but that doesn't mean you should", thats an example for "use it, if you need it."
no
I said EntityPlayer changed to ServerPlayer
I installed znpcs plugin and economy shop
CraftPlayer is still CraftPlayer
wrong channel
My bad I meant EntityPlayer
this is for plugin DEVELOPMENT
yeah there's no docs about that too. NMS is not documented. It is internal stuff
Then where i will ask
You said it doesn't use NBT..?
@next fossil Yes. My lib does NOT use NBT ANYWHERE
Very few use cases, but sure.
I use == on objects quite often. But you should only use when you know that it'll work, otherwise stick to equals
Then you said the NMS is in the internal MC and you looked through it yourself
exactly
So it DOES have NBT
starting with enums/constants, which aren't just a few cases.
Yeah, absolutely
oh no
let me explain
NBT are something like "data storage" on itemstacks, entities etc. NBT is part of NMS, but there are many other NMS stuff things, like e.g. sending packets
As long as its packets I assume its NBT/NMS (Different Names)
Comparing enums and other basic types with == is more encouraged than equals. That is ture
#help-server see here
Ohh okay I get it now
NMS is everything that's internal Minecraft stuff. NBT is just a small part of all the NMS things^^
yeah well, "overall packets", not really. NMS is short for everything inside "net.minecraft.server", so basically everything that mojang coded themselves
NMS is simply said minecraft multiplayer based
Okay so what I meant to say just now was the JeffLib github repo you sent still uses the old NMS from 1.17
I'm just trying to figure out how to use the new ServerGamePacketListenerImpl to send packets
nooo it doesn't. check the package name. check the imports
obviously that's 1.18
to send a packet:
I tried but it keeps giving me this error:
The method sendPacket(Packet<capture#1-of ?>) is undefined for the type ServerGamePacketListenerImpl
ClientboundAddEntityPacket packet = new ClientboundAddEntityPacket(someNMSEntity);
((CraftPlayer)player).getHandle().connection.connection.send(packet)
where "player" is a normal org.bukkit.entity.Player
as said: you have to get the Connection instead of the ServerGamePacketListenerImpl
which is why there is ".connection" twice in the code above
trust me, my code is indeed 1.18 and it's working fine. Otherwise I would have gotten 50 bug reports already lol
if you got a problem, show your code pls
including your imports
Does the new Spigot 1.18 NMS use the lettering convention still btw?
lettering convention?
Like .getHandler().a.b.c?
no
it has real names
well
mojang remapped has real names
the "normal" obfuscated code, the one the server actually runs, still has obfuscated names like getHandle().a.b.c
is it possible to code with mojang mappings and then while maven run obfuscate it to spigot using ?
in short:
The server you run has obfuscated names. However, since mojang released the mappings, you can get yourself a .jar that contains mojang's original names. So the variables have meaningful names. However, to run your plugin, you have to "reobfuscate" your plugin again. It can be easily done with maven.
sure!
One sec
check out my pom for 1.18
the interesting part is the <plugin> section with net.md-5
also be sure to use the correct dependency:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-pre8-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
obviously you can remove the pre8 part
you now have the mojang mappings inside your IDE, but when you compile it, it will be "reversed" to the obfuscated names so it runs fine on the server
Is it mandatory to reobfuscate the code again in order for the plugin to work? Or optional? Cause Maven caused me a lot of issues in the past and I really don't want to turn back to it again
if you use mojang mappings: it is mandatory
maven will make your life much much easier
in the beginning, it's hard. I also raged at maven the first time I tried but I never wanna miss it again
just go through the hassle once and you never wanna miss it again
I promise
Okay
You can see silly mfnalex 2 years ago here: https://github.com/JEFF-Media-GbR/ChestSort/pull/7
I was also like "wtf is this shit, maven makes my life more complicated" lol. But meanwhile I know better
TL;DR: Use IntelliJ instead of eclipse if you want to use maven. I never got eclipse to properly load maven projects when the project was originally created in eclipse without maven
i just have to find out where those classes are and how they are named ... uff
got any specific questions? ^^ I also had to go through this, maybe I can help a bit ๐
help
i added plugins to my server, but when i do /pl it sends "skript, vault" and when i try /skript it sends "/skript help"
I'm trying to convert System#currentTimeMilis to second, but I failed and I don't know what to do now. https://paste.md-5.net/vojovoxusa.java
The output of the debug:
[18:51:12 INFO]: milisToSecond() = 1638445865
[18:51:12 INFO]: milisToSecond() > 30 = true
just divide it by 1000
int seconds = System.currentTimeMillis / 1000;
you probably gotta cast it or store as long instead
I have do that before using TimeUnit, the result still the same.
what are you actually trying to do?
you must check the difference between both times
you just check whether the current time since 1 jan 1970 is greater than 30
Oh
basically
I know I think
public boolean isTimeRanOut() {
return milisToSecond() > 30 + (time/1000);
}
int timeCreated = System.currentTimeMilis();
int now = System.currentTimeMilis();
timeCreated - now / 1000;
btw I wouldn't care about converting to seconds
just check whether the difference is greater than 30000
it's easier than converting it everytime imho
Or use TimeUnit 
they already use timeunit ๐
I just think it's easier to not convert back and forth, it's just another place where a bug could somehow occur
Conclure why you left me ๐ฆ
Why are some packet listeners not able to be resolved? The imports are correct and all
The import net.minecraft.network.protocol.game.PacketListenerPlayOut cannot be resolved
because
you still try to use the normal names
although you have to use the mojang mapped ones
this is the fourth time I tell you this
I looked through the implementation it has those too
public static void OnShift(PlayerToggleSneakEvent event){
if(event.isSneaking()){
PlayerInventory inv = event.getPlayer().getInventory();
if (inv.getHelmet() == ItemManager.warriorHelmet){
if (inv.getChestplate() == ItemManager.warriorChestplate){
if (inv.getLeggings() == ItemManager.warriorLeggings){
if (inv.getBoots() == ItemManager.warriorBoots){
Player player = event.getPlayer();
player.getWorld().createExplosion(player.getLocation(), 4);
}
}
}
}
}
} ``` Can someone help me I dont get why my plugin isn't working? it seems to be te right code and I get 0 errors.
hm lemme see
add debug information
and also
avoid the arrow pattern
as a short debug thing: add a print statement inside every if
so you can see where your code stops
You're comparing Object with ==
oh yes
Maybe try to use ItemStack#isSimiliar instead?
^
tnx guys
don't do stuff that crashes the server
Bukkit.getScheduler().runTaskTimer(yourPlugin, () -> {
// Your code
}, 1, 1);
it won't crash unless you do things that are really really bad
Nvm fixed it
Do you know the replacement for DataWatchers btw?
Like the external skin for a Player used to be DataWatcher
Oh nvm found it: SynchedEntityData
what can i type in yourplugins?
a reference to your class that extends JavaPlugin
e.g. if you are inside that class, use this
ok thx
if you are outside of your main class: use a static getter to get your instance, or use dependency injection
both is fine. some people claim one thing is better than the other, but in the end it doesn't matter which of those you use.
๐ฅด
hi i need help with reading data from a config file into a HashMap<String, String> does anyone know how that works?
hello this my first time using this how to fix this errors
i cant see which one it should have else
Reading data form an config file into a HashMap
Read the error.
i have fixed it
You want to have every node inside that hashmap?
try opening the exported jar in recaf https://github.com/Col-E/Recaf
and seeing if the plugin.yml is correct
ill do that
HashMap<String,String> map = new HashMap<>();
for(String key : getConfig().getKeys(false)) { // Use true to also get all subkeys, e.g. "test.subkey"
map.put(key,getConfig().getString(key));
}
Yeah, so i have a claim command that is using a HashMap with <String, String>
I got it to save the data but i don't know how to read it and put it back in
saving Code:
for(Map.Entry<String, String> entry : chunks.entrySet()) {
hash.getHash().set("claims."+ entry.getKey(), entry.getValue());
}
hash.saveHash();
}```
oh thanks
i am slow at typing sorry XD
no problem ๐
what I sent will work with every FileConfiguration. Obviously you'll have to change "getConfig()" to the FileConfiguration object you want to use
how da hell do i open that jar file
yes that is the problem
that is not working
open a terminal and type java -jar Recaf.jar
yeah, i saw some scetchy thing online and it didn't work, but thank you i'll try it right away XD
nice java install? try running it from cli like mfnalex suggested
if you just want to check if your exported jar has your plugin.yml, you could use winrar/7zip to open the jar.
oh yeah, that is possible
AHH FUCK FOR SAKE
WHY DOES WINDOWS HATE ME
lets take theones route
hm one sec
u got winrar or 7zip?
i got something that can open it yes
jd-gui best
what does it look like
i get this
oh wait @hoary pawn
you got the wrong jar
you need the recaf-<version>-jar-with-dependencies.jar
then you can easily start it
Sorry one last question, i do need to put it to true, right xD? Like with how i saved it?
i found it under target
yeah use true if you want every config option
oh
okay
just dont undetstand where it gets it from
wait target is just a compiled output tho..
yes
i guess i could've just tested xD
e.g. this:
key1:
subkey1: test
key2: test
Will turn into this hashmap:
key1.subkey1 -> test
key2 -> test
i just dont understand where target gets it from
WAIIIIIIIIIII
okay thank you, now i understand it ๐
its because plugin.yml was in the wrong place
target generates it whenever u run the Build task in maven i think (target is mvn rite?)
oh rip
well it might work now soooo
oh yeah u can delete recaf if u want, u probably dont need to be decompiling or editing jars any time soon
how to fix it , it happend when i try to add plugins after the implements Listener for Bukkit getScheduler working
not like its taking any space xd
every bit matters ๐
Why are you implementing Plugin?
you would not like to look at my hard drive then
but if ur gonna keep recaf u should probably get the right one lol
like 2 tbs of random video files xd
i lived on a 100ish gb storage limit on my macbook so even on a 2tb drive i only use around 100gb lol
Anyone know if there is a feature w/ placeholderapi for plurals? i.e.
MY_MESSAGE: 'You have %player_wins% wins' # <-- make "wins" -> "win" if %player_wins% == 1
I know I can just add my own check, but I'm wondering if placeholderapi can do it for me ๐
xd, how?
only had what i needed... deleted what could be sacrificed...
isnt that the amount of space windows uses on a install xd
Nope
Does someone know a translation file between Bukkit-Names and the mojang-names ?
For example:
Bukkit-Name is NBTTagCompound and in Mojang they called it CompoundTag
pretty much ๐, especially win11
Because that is inconsistent in regards to localizations Nicbo
Ah okay, thanks
AYYYYYY
wahoo
I donโt know if you solved your problem but else have a look at
?scheduling
someone help please
?paste
On phone so discord sucks

stop instantiating your plugin twice
if you have, at ANY point, something like "YourPluginName plugin = new YourPluginName()": you did sth wrong
I donโt think he understands the notion of instantiation
Maybe he does "new Main()" ๐คก
show your main class and highlight line 14 pls @orchid cove
did someone say main
I also still ahve plugins where the Main class is called Main lol
By looking at his error, he named it "Main" ๐คก
meanwhile I know better but
can someone explain to me how to make this? (clarification: i do not want spoonfeeding, i want someone to explain to me how i can achieve this and maybe even add some resources if you can - if you tell me to learn java i will just ignore you since i do find it annoying and rude)
never change a running system
I usually just use PluginName for the main class
and, don't kill me, I'm using static getters to get the main instance
<PluginName>Plugin is imo the best as its actually a derivative of Plugin, PluginBase and JavaPlugin
show your EventClass source code pls
That's how I got started
wait ur not supposed 2..? o.o
It's ok, JavaPlugin is in a singleton pattern
some people will tell you that it's bad OOP and you should use dependency injection instead
I think it's bs
๐ฅด
Well, when you can you should instead of using the static way
but I don't care because it doesn't matter in this case
not somehow. it does violate lol
just slap in a good old public static PluginMain INSTANCE; and a good old onEnable INSTANCE = this;
๐ฅด
i am so bad lmao
yeah but there's no problem with it. noone will ever instantiate a ChestSort listener without having ChestSort installed, for example
Then you have all the reason to get better (:
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.
Anyways
your event class MUST NOT extend JavaPlugin!
Start by removing extends JavaPlugin ^
only exactly ONE CLASS may extend javaplugin
must
yes
perhaps
whoevers behind the discord server development should remove learnjava command
I added it ftr
the problem is that 99% of people don't read it
it's rude
What is the best way to check if a player interacted with a custom ItemStack?
No itโs unarguably the most helpful command
not rude, useful
it's like saying "ugh I need a drivers license to drive a car? that's rude"
i can argue otherwise
it's not rude, it's just neccessary
So are you familiar with NBT?
noone is mocking someone for not knowing java. it's a hint to help people understand that spigot is not a language, but just something you can use after you already know at least basic java
i disagree, some people want to learn in other ways
In that case, compare nbt data (for instance an entryโs value and check if it matches another value.
oh no i am 100% undermining their ability to write Java rn
but you need the basics first
e.g. yesterday
i ran it so they can take a look at how java works to aid them in finding out their issues
you see the problem? people use it to be rude, and even if you're not, you're still being rude
there was a guy (or girl, idk) who wanted to something like this:
player.setMaxHealth("20");
I know what NBTs are but I never used them, if you know a great documentation that would help please let me know
i am simply a good person, maybe not a nice one..
if people don't even know the difference between ints/doubles and strings, they MUST ?learnjava beforehand
The PersistentDataContainer and PersistentDataHolder api
?pdc
or you can just explain to them what they're doing incorrectly in a nice way
yeah PDC is heaven sent
they are telling them the issue exactly
I am doing that. I will still tell them to learn the basics
i am providing sources so that they can avoid the mistake again
yes, it will take them longer to learn but some people prefer it (or just me, idk)
Sweet thank you guys
Hard to explain when they don't know the basics ^^'
Have a good one
@quaint mantle just to clarify: PDC is NOT nbt
Sort of is
it's however something that's better and that you can use instead, 99% of the time
proving you wrong: strings are text and are surrounded by quoutation marks, integers are full numbers that are just by themselves
well internally, of course the PDC gets saved as NBT. but it's still something different^^
yess thank @tender shard , @ivory sleet i got fixed that errors
basics of java covers a bit more than that...
Yeye
Pog
and you can explain it along the way
you don't need to go all "oh you don't know java here's some stuff to teach you"
sure, but instead of us repeating the same advices again and again, people could just read the text at ?learnjava
but it's rude
Well, imagine if any rando comes here and we start to learn him java
tough love? idk..
bro it is not rude to give people links to helpful information
if you don't want to teach them stuff then don't, you don't have to be rude about it
This wouldn't be a Serious spigot and bung prog/dev help channel
maybe you get offended when someone tells you that you don't know everything, but most people are not offended by that
i sent the command so that i dont have to teach them it myself...
after all this is a channel for help, and someone who already knows everything won't ask questions here
or so that mfnalex and conclure woukdnt have to
It's like on Stackoverflow
I'm doing spigot plugins since 2011 and I still need some help from time to time
no, actually this is also for java help in general
if you ask for basic things, they'll just lead you to the javadoc
spigot should not have to teach some1 java, java should teach some1 java
iDerpyOfficial yes I have seen you getting greeted by some rude encounters long time ago but just because someone tells you to learn java doesnโt inherently mean they had a rude and insulting intention
good intention or bad intention, it's rude
learnjava is a totally fine command and it doesnt offend anyone. its simply a link to some basics, to help people understand stuff
the only one rude here is you, asking for help and then getting offended like a small child when you actually get some help
I'm out
have a nice day @lean gull
Then our definition of rude must be very different from each other
i like how i'm the rude one while in the same sentence you're calling me a child
well no, i was being a little offensive by undermining the OPs ability in java
couldnt tell if they didnt understand java or the spigot api so i did a ?learnjava
alerithe your intention was rude but telling people to learn java is rude by itself
so that's double the rude!
wow
im like a disney villain
Is there a way to check if a player equipped armor in PlayerInteractEvent instead of opening a furnace, for example, without using a list of such type of blocks?
If it was an API lack, I think we would notice it and redirect him directly to the API Doc instead of the learnjava
he couldve just not understood with JavaPlugin was so idk
I'm not calling you a child, I said you behave like one
@ivory sleet
i actually thought thats what the issue was judging by attempting to implement Plugin in his event class
That's the first thing you learn while doing an actual plugin
that's not that different
well then just don't learn java and keep not getting stuff done. Feel free to do so
Believe so altho itโs bug prone
i mean if u copy the spigot tutorial.. it should work out of the box
welp i guess that argument is done
Maybe checkout something like armor equip event lib
yeah sorry but I really don't get your point
Noone meant to be rude. People wanted to help you by providing useful links @lean gull
๐
Well, c/p without understanding or even reading the tutorial isn't smart imo ๐
you were meant to be rude, alerithe meant to be rude, and that's just in the past like 10 min
If you don't want to read them and instead say you don't need to read it, that's okay, but then noone here can help you
i meant to be a little rude, but also tried to help
I didn't mean to be rude, but I admit I got a bit pissed
it was a hey im not sure if u understand java, read these
"small child"
yeah as said, sorry, didn't mean to be rude, I just got pissed because you ask for help and then don't take our advice
anyways i actually have motivation to work on my plugin so cya
so I wonder why do we even try to help and waste our time if you don't listen anyway
can you understand that, at least a bit?
i can understand that you got mad because i wasn't seeing things your way, but it's also kinda irrational to think that everyone would see everything in your way and if not you get mad
I can understand, but as said: giving someone linkes to basic java tutorials is not rude
?1.18
You can build 1.18 using BuildTools https://www.spigotmc.org/wiki/buildtools/
java -jar BuildTools.jar --rev 1.18
it's just a link with information
i think the oppisite
Install 1.17 with BuildTools: https://www.spigotmc.org/wiki/buildtools/
?1.19
can you stop that pls
maybe i'm biased because of the past, idk
I was testing.
Literally being rude
โI was testing.โ
noone here meant to be rude. It's just that when we see beginner mistakes, we think that people didn't understand some basic java concepts, so we want to show people on how to do it better. And that's what this command is for
uh huh
lol
well but anyway. you should check at least one of those links out
they ARE helpful
its always good to (re)learn the basics
this aswell
even i still go on javadoc for stuff that i should know by now well after 6 years
i didn't learn all the basics and i'm doing completly fine with trying and getting help from nice people here
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
whoops sorry wrong chat
well in that case...
?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.
i was about to say "don't-"
heh
I love this emoji
i dont even know what smug means lol
weewooweewoo mods they swore BAN EM
everyone's swearing here
its the best word u can ever learn
Smirk
german native lang

german has the best words
a smirk but better
antibabypillen
Abseilen, Kindergarten, Rindfleischetikettierungsรผberwachungsaufgabenรผbertragungsgesetz
that's the only 3 german words you will ever need to know
isnt that last one a law
yes
yeah
it's about how beef products must be labelled
can someone help me w/ this? (link to what im talking about below that message)
tbh I totally forgot what your actual question was
erm that doesn't mean anything lol
i don't think u even read it when i sent it
No i saw it in some video about cats
Like calling cats with that name or something
der Kek
Isnโt actually a real word, Americans say itโs german for cat.
it's bullshit, the word is made up
๐
no I didn't, because I got some other things to do as well
today on god i hope i said cookie and not something else
but I read it now and all I see is that you're asking for help without actually explaining what's your problem
you ask on "how to make this" without specifying what "this" is
no i did
look at the video 2 messages below that message
i even said it in the reply
ah didnt see the video because it had no preview
iDerpy in short you need to know the spots/places which are able to randomly generate a structure selected from a pool of said structures.
huh
yeah but what do you actually mean with "this"? making the GUI? Creating the structures? ...
Then pick a random structure from your pool of structures, and generate it where ever you desire.
basically i want to make like a grid, and in that grid you can spawn randomly selected dungeon rooms
Wait what is the best way of getting the main class? I canโt just make every constructor of my plugin has every other class just to use the function ngl
Leaky abstraction!
well
I suggest you to use a static getter. many people will say it's wrong and to use dependency injection, which is fine too
Just donโt make every other class depend on your main plugin instance
Hey folks, working on porting my NMS work to 1.18, I'm looking for the new name of isDebugWorld() and isFlatWorld() defined in net.minecraft.world.level.World and WorldServer, what are the new names for these? I cannot find the World class on Mini's mappings viewer to try and find it myself ๐
wait what why
Yeah and in every class i use has a constructor contains the main class
Use design patterns and other methods to avoid class hierarchy abuse or whatever weโd call that
Like why every of them need to contains the main classโฆ
Well, the class gets tightly coupled to the main class type
Welp why is it wrong?
That is why im asking to change the way i use to get the main classโฆ
Maybe the were removed
I basically do it this like this most of the time:
public final class MyPlugin extends JavaPlugin {
@Getter private static MyPlugin instance;
{
instance = this;
}
or, without lombok:
public final class MyPlugin extends JavaPlugin {
private static MyPlugin instance;
public static MyPlugin getInstance() { return instance; }
{
instance = this;
}
now you can always access your main instancve using MyPlugin.getInstance()
RPG, to me it sounds like you need to split your logic into more middle-leveled classes
and YES, it's true that this violates some OOP principles, but tbh I would not worry over that
i mean, decompose your main class into multiple components and pass them
Iโd mainly be concerned if weโre unit testing with mfnalexโs code
Which probably isnโt the case
yeah I never got into unit testing
but I'd love to do so
I didnt study CS or something similar
Yeah just donโt do them too much lol
i need the main class instance for a lot of stuff tho
Such as?
i had real time protection while gradle building
1 sec
and i was blaming my pc for being slow on building
Lol
use the approach I sent above, or use dependency injection
tbh I even agree that dependency injection is better but I hate it
why
DI looks cleaner imo
Yeah at least youโre depending on the type and not an instance
because it's redundant
persistent data containers, using a class other than main but with the same instance, and more idk
I have to change the constructor for EVERY single class that needs the instance
it takes literally 20 seconds if ur slow
Every class iโve made until 2 months ago has this
Main class {
@override
public void onEnable() {
Classhere here = new ClassHere(this);
OtherClass classhere = new OtherClass(this, here);
}
}
Like why?
not if your plugin consists of 100+ classes
Bro Guice exists!
I hate Guice
just do it whenever u create a class
Yeah a bit problematic with namespacedkeys, bukkitrunnables/BukkitScheduler, registration of certain things maybe iDerpy but you can create middle classes for it and then pass those
I don*t understand it well enough to use it
but if ur that lazy ig do ur thing
I also hate guice altho itโs necessary sometimes
dunno how u can be that lazy
I tried to use it many times
Guice saves you from statically typed constructors
but I feel like it creates a new instance everytime
pay me 1$ and ill spend my time doing it for you :)
Bois i do this on every new classโฆ i find it kindaโฆ hmmmโฆ idk
gimme paypal link lol
so like have a field variable in another class that is set to an instance of the main class and then in that class have a method to get the main class?
KEK
Let me write an example
I'll be back in a few minutes, gotta call a doctor for my bf
then just do it
It requires a plugin
I always do it like this:
@Getter private static final NamespacedKey SOME_NAME = new NamespacedKey(this,"something");
lombok :(
lombok is not bad
You cant use this keyword in static context
of course, that's their purpose
oh right lol
lemme check how I'm actually doing it
so can anyone help me with the dungeon rng thing?
You can parse them now without a plugin
That is an api abuse tbh
@Getter private final NamespacedKey keyCraftingRecipe = new NamespacedKey(this,"craftingrecipe");
@Getter private final NamespacedKey keyIsWarpBook = new NamespacedKey(this, "iswarpbook");
@Getter private final NamespacedKey keyGuiFunction = new NamespacedKey(this, "guifunction");
@Getter private final NamespacedKey keyOwner = new NamespacedKey(this, "owner");
@Getter private final NamespacedKey keyWarp = new NamespacedKey(this,"warp");
declaration: package: org.bukkit, class: NamespacedKey
Ikr
namepsace will be minecraft default tho
But still, thats for parsing, not for creating a brand new key
there's a good reason why a NamespacedKey normally requires a plugin instance
Yes so that peeps that don't understand the concept and importance of namespaces don't mess this up
but like eh
I also wonder why that would ever be a problem. When you code a plugin, you always ahve an instance of your plugin
you usually want to cache your namespaced keys
and make them static
or smthing
and you wont always have ur instance then
the only other way is to use JavaPlugin.getPlugin
or singleton, but yea no i prefer the first
I mean if you believe your DI to be "just pass my main class everywhere" then sure you have your plugin instance everywhere
when making them static, the code becomes twice as long and I'm too lazy for that
Specially naming conventions are pain in the ass
why?
I want X, Y, Z instead of xKey, zKey and yKey
then just go for it, noone will stop you
however your vars should be lowerCamelCase
so x, y,z instead of X, Y, Z
Conflicts
conflicts with what?
I already have local variables with those names
then you can probably understand why people prefer "descriptive" names
the this.x is too hard
Wait so you guys often get the instance of other class through constructor, singleton or static getters?
confusing โน๏ธ
I mean of course I also use x, y, z as variables sometimes, but tbh only in for loops where I'm running over some coords
singleton and static getters are tied
unless you are talking about making your plugin instance public static
and not using even a getter
๐คก
Oh i forgot
I use static getters for all my recent plugins
class ConclurePlugin extends JavaPlugin {
@Override public void onEnable() {
this.getServer().getPluginManager().registerEvents(new EpigListener(this),this);
}
}
class EpigListener implements Listener {
final Plugin plugin;
EpigListener(Plugin plugin) {
this.plugin = plugin;
}
@EventHandler
void onChat(AsyncPlayerChatEvent event) {
this.plugin.getServer().getScheduler().runTask(this.plugin, () -> {
event.getPlayer().getWorld().spawnEntity(EntityType.LLAMA);
});
}
}```
^ average spigot dev
```java
class DerpyPlugin extends JavaPlugin {
@Override public void onEnable(){
DerpyScheduler scheduler = new DerpyScheduler(this);
this.getServer().getPluginManager(new LigindaryListener(scheduler),this);
}
}
class DerpyScheduler {
final Plugin plugin;
DerpyScheduler(Plugin plugin) {
this.plugin = plugin;
}
BukkitTask runTask(Runnable r) {
return this.plugin.getServer().getScheduler().runTask(this.plugin,r);
}
}
class LigindaryListener implements Listener {
final DerpyScheduler scheduler;
LigindaryListener(DerpyScheduler scheduler) {
this.scheduler = scheduler;
}
@EventHandler void onChat(AsyncPlayerChatEvent e) {
this.scheduler.runTask(() -> {
e.getPlayer().getWorld().spawnEntity(EntityType.LLAMA);
});
}
}```
^ average code architect
Okay derpy so yeah the latter is somewhat more engineered in the way that its reusable, in reality adding a high level layer of interfaces would be ideal.
Also yes wrote it on phone
I know it violates the OOP principle a bit but I don't see any downside in doing so
This starts sucking at cross platform projects
I prefer to assign my variable in the constructor so i can just refer it as plugin rather then keep calling getInstance(). Even if you could assign your plugin value in the constructor the first place, I feel like its wasted
And it is really not scalable tbh
Yeah i guess im gonna stuck to ?di
spigot plugis are not cross platform projects
I don't do that, I just have
private static final MyPlugin main = MyPlugin.getInstance;
inside the classes where I need the main instance
thats fucking gross
that's your opinion