#help-development
1 messages · Page 928 of 1
@solar musk is SystemInfo your api library?
/CMarcoo/SystemInfo
I'm not seeing SystemInfo class in your code
That's not really it
Nevermind lol, I see you've used oshi-core API
I though you coded everything yourself
so it's basically a wrapper plugin
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
ok
i have this maven - https://paste.md-5.net/fiposugeko.xml - but if i try compile this i get error - https://paste.md-5.net/ipiharurag.sql
i dont undestand why?
i mean what with artifact
unrelated to spigot or minecraft in general
i need small help
when i had my code in a command which puts a image on a map it had very good quality but now i made it a method it has very bad quality
Hello I wanted to do a plugin that link a discord acc to a minecraft one with a code. What is the more efficient between hosting a bot in a minecraft plugin or the self projects which are communicating through a websocket server ?
Looks like the variable isn't working
it's up to you how you want it setup
both are valid options
Hosting the bot on the server is usually easier for users
is it a possibility that it gives me the map before all the pixels are coloured?
there isn't a method more efficient than th other ? (if we remove the fact that the bot will be offline when the server is)
here exists some general channels for dev ?
depends on what you mean by efficient
is it possible that Bukkit's map coloring gives me the map before its fully colored?
^^
try adding
<plugin>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>detect</goal>
</goals>
</execution>
</executions>
</plugin>
because when the exact same code was under a command it was looking very good but now i just made a method and used the method to give map it looks ugly
for a big network which one you suggest ?
honestly both are fine
is there any guide or tutorial for using net.minecraft.server in 1.20 mojang remapped?
?nms
can someone help me with uhh increasing quality of image put on the minecraft map?
this not send errors but code not ganarated
It works ! Thanks a lot !
hi! im trying to use this import: import net.minecraft.server.v1_18_R1.PathfinderGoalFloat; this is the error: Cannot resolve symbol 'v1_18_R1' my defenencies: java <dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies>
is there a way to temporarily register a chatListener?
why are you importing both spigot-api and spigot?
you only need spigot, spigot-api is included in spigot
oh okey
check if it resolves the error
I do recommend using Mojang mappings
yes also
If you need to access NMS classes from inside your Spigot plugin, it is a very good idea to use the so called Mojang mappings. Disclaimer: This post is written for 1.20.4. If you use another version, you of course have to replace every occurance of “1.20.4” with the version you actually use. What are...
thenks
now its saysing: Cannot resolve symbol 'minecraft' ```
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier> <!-- Important! -->
</dependency>
</dependencies>
</project>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>```
is there a way to make a new MapView without a world name?
It needs to belong to a world
you can just take the players current world
it doesn't matter much
someone can help me?
if i reload maven says this: org.spigotmc:spigot🫙remapped-mojang:1.18.2-R0.1-SNAPSHOT was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigot-repo has elapsed or updates are forced
Try to run Maven import with -U flag (force update snapshots)
Did you forget to run BuildTools
i downloaded but how i can run?
double click it
what?
BuildTools.jar?
yes
noting happends
It should open a GUI for you
it dont oppend
Did you download the latest version of BuildTools?
oh it oppends
I bet it’s the web requests that slow it down.
it oppend and?
Should make that a priority fix.
@vestal mountain
I am making a plugin that detects if a player is afk, but I have no idea how to do it. Maybe with an enum or hashmap or so?
so a hashmap with a boolean?
if you want a hash map with a boolean you can use a set
wat da fuck is an actual way to return a value from a thread using a callback
like just deadass invoking the callback method at the end of the thread ?! on god?!
Are you using completeable futures
im actually in bed contemplating but id probably use futures yeah
what do you mean by set?
alr but what if I wanted to count the time somebody is online but not afk?
Remember the date he logged in. When he starts being afk count the difference between those two dates (login and now). When he's not afk set the loggin date to now. And when he disconnects count the difference too
what i have do it installed all files?
okey
ok. But how could I do that using a database like mySql?
is there a way to register listener temporarily?
like register it for the while my event is running
then unregister it?
You can use a database, or just config files, or even persistant data on the player directly. Depends on what you want
You can, but why would you do that?
its like you know chat games
only check for answer while event is active
i mean i guess i could use a boolean too
Can u help me 1 thing i am a bit of afriad of doing it myself i dont wanna cause dupes
Ahahah sure
for a duration of 30 seconds i want to set 0 of player to a map
but i want to give their item back when event is done or if they decide to leave
Set 0 of players?
slot 0*
i am thinking of adding them to hashmap
What key and what value ?
public void giveMap(ItemStack map){
HashMap<UUID, ItemStack> itemofPlayers = new HashMap<>();
Bukkit.getOnlinePlayers().forEach(p -> {
ItemStack item = p.getInventory().getItem(0);
if(!item.getType().isAir()){
itemofPlayers.put(p.getUniqueId(), item);
}
p.getInventory().setItem(0, map);
});
}```
probably uuid
and value = itemstack
if its air i wont add
? like
Why did you put the map inside your method? (Variable scope)
What if a player join after the starting of the game ?
oh i will fix the 1 thing
well i have a list of players who will join it
you can register for the game if u want 30 seconds before it starts
Okay
item.getType().isAir() why can this produce nullpointerexception?
item is null probably
^^
So what I would do is having your Map accessible outside your method. The map is well defined.
You can have one method to launch the game after 30 seconds, which means putting the participants slot 0 in the HashMap and removing their first item.
Then you have a timer again if I well understood to stop the game. Once you stop you just have to get all the players from the map one by one and give them their item back (be careful of concurrent modifications).
If the player leave the server, just check if it is in the map, and if it is the case give its item back and remove it from the map
Just one thing:
If you give items in the 0 slot for the game, be careful of the players that had nothing in slot 0 before the game start (they won't be in the map) and be sure to remove the given item from them
item null check is required but not sure if you can get rid of AIR checking
well if item is not null then it has to be something right
Most of the time air is null
which is only for legacy isnt it ? lol
pretty sure in newer mc an empty slot is AIR, old used to be null or something
wait 1 i have small question
regarding how itemstacks work
What if the item is from a mod
It's always null, I think last time I checked was like 1.19
i think i gotta test things for that one
Then you or the server owner are doing something wrong
x(
Never mix plugins and mods
an item is an item no matter what tho 
all items stem from itemstack
Unless there is some fucked up mod that, just as all mods like to, decides to do shit the exact wrong way
in my mods i recode the entire creative gui and item system so i dont have to register them as item stacks
🤯
nah that mod is fairly well coded ig i will just code this plugin as i intended
why mix mods and plugins
dont ask me , ask the owner
Then tell the owner that you should never mix mods and plugins

Especially if it's any bigger than a lil rofl server for a few homies
imma just finish this plugin how i intended it duh
uh i have a really stupid question
I mean mixing mods and plugins isn't a bad idea once you know what you're doing
is there a way to add wait in ticks?
?schudling
Using Bukkit Schedulings
oh
?scheduler
If you coded all of them yourself and have a deep enough understanding on how the specific hybrid works, ig
?scheduling
?scheduling
Gotcha
Hush
chill guys
That's what I meant ahah
But at that point just code mods
And I have a thicc feeling this is the opposite case
EXACTLY
You can do everything bukkit plugins do with forge or fabric mods
its fine x) i am only doing this cause i liked this idea
and mods will also make some stuff easier such as custom items or mixins
mods also finally allow ppl to assign buttons to certain actions
which plugins cant cuz its client side 😔
Lol
and sneak
Bet ya spigot guys can't do this
yes but F also kinda meh cuz its used for other things
i guess you can disable item swapping
1.8 moment
i mean technically we can its just harder
Won't be as sexy tho
someon can help me with this import error: import net.minecraft.server.v1_18_R1.PathfinderGoalFloat; error: Cannot resolve symbol 'minecraft' pom.xml: <dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> <classifier>remapped-mojang</classifier> <!-- Important! --> </dependency> </dependencies>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
what?
someon can help me with this import error: import net.minecraft.server.v1_18_R1.PathfinderGoalFloat; error: Cannot resolve symbol 'minecraft' pom.xml: <dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> <classifier>remapped-mojang</classifier> <!-- Important! --> </dependency> </dependencies>
you dont have to ask twice
.
yeah that's not what the class is called anymore
?
should i use AsyncPlayerChatEvent for when player sends a message?
if using paper, yes
so what import?
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
i am using spigot
Hello again !
I'm trying to display player heads in menus.
But there are problems : offline players head are not good and I know why.
The reason : textures' URL, in PlayerProfile, are null. So I have to update this profile in order to get the correct URL.
The problem : its toooo long, to do that each time I want to display heads !
I've tryed to set this URL for all players one time but this URL doesn't stay and go back to null after few times.
Someone knows if a plugin reset the PlayerProfile or PlayerProfile texture ? Or if it's a Spigot's bug ?
PlayerChatEvent deprecated in paper for this reason:
Listening to this event forces chat to wait for the main thread, delaying chat messages. It is recommended to use AsyncChatEvent instead, wherever possible.
so yes
(i know its spigot but still)
This appears when kick a player with a command (custom one) handleDisconnection() called twice
?switchmappings
but it sasy cannot resolve symbol minecraft
did you run buildtools with --remapped?
no how i can run that?
?buildtools
okey thenks
That sounds like the (non-async) PlayerChatEvent, AsyncPlayerChatEvent is on spigot as well lmao and PlayerChatEvent is deprecated too
why this code sasy this error? public void initPathfinder() { this.goalSelctor.a(0, new PathfinderGoalFloat(this)); this.goalSelctor.a(2, new PathfinderGoalLookAtPlayer(this, EntityHuman.class , 8.0F)); }˛ error: Cannot resolve symbol 'goalSelctor'
do you mean this.goalSelector?
yes
Selctor != Selector
i have this import: import net.minecraft.world.entity.ai.goal.PathfinderGoalFloat;
The code above is obfuscated and you're using mapped
how i can code this?
org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.```
?
FileConfiguration config = WhosThatPixelmon.getInstance().getConfig(); Bukkit.broadcastMessage(TextUtils.getFancyText(config.getString("starting-message")));
Pixelmon...
its a name
you can help me with the code?
wait shtt i think i found whhat i did wrong
bruh
starting-message = "§f starting rn."
💀
I'm here if you're willing to learn
If you're just here to get things done then no I'm not going to bother
i never thought i would be soo down bad
You can send me a video or ayting?
No when working with NMS you're mostly on your own
did he not compile using buildtools?
You spend most of the time reading the decompiled code from Mojang
You can ctrl click the class the open it (in Intellij)
https://pastes.dev/UlwtkSrE4e can anyone help with correcting this code to achieve the replacement of a flying snowball with a flying sword
org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:61) ~[server.jar:3096a-Spigot-9fb885e-af1a232]```
wait why
it did send me the message from config
maybe try starting-message: instead of starting-message = ? idk
not too keen on how yaml formatting is
it was like that before lmao
o
Hey, could someone give me an advice on how to save a list of itemstack to config?
I've tried different ways but I don't get it
This says that configurationsection is null
you need to serialize and deserialize thenm
My guess is that there isn't a section called Rewards
Yea, but is configurationsection is null
I mean, there is but with no values
just
Rewards:
that is not a configurationsection
then it's not a section
that is just null
^
That makes sense
can u check my config file too
prefix: "§c[WHOS THAT PIXELMON?" starting-message: "§f starting rn." success-added: "you have been successfully added to game" title-message: "Starting New Pokemon Game Shortly" fancy-text: "true"
org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:61) ~[server.jar:3096a-Spigot-9fb885e-af1a232]``` i dunno why it gives this error
So just #CreateSection right?
just add a default value to the section
should i remove " "
you probably have an invisible character in the file
color codes character?
lemme fix it rq
org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.
at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:61) ~[server.jar:3096a-Spigot-9fb885e-af1a232]```
still
damn "true"
yea i removed the " " from true
also
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) [server.jar:3096a-Spigot-9fb885e-af1a232]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) [server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.chat(PlayerConnection.java:1858) [server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1796) [server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1734) [server.jar:3096a-Spigot-9fb885e-af1a232]
at net.minecraft.server.v1_16_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:43) [server.jar:3096a-Spigot-9fb885e-af1a232]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.IllegalStateException: MapInitializeEvent cannot be triggered asynchronously from another thread.```
1 more thing
these stuff soo annoying i cant lie
Someone can help me with PathFinderGoal?
should i use non async eventt
Async event is fine
you just need to jump back to the main thread
You can use the scheduler
how do i jump
?scheduling
runTaskLater
so i just run it 1 tick later?
yeah
?
i can just do runTask then
Decompile the class you're trying to get it from and see how it's used
should work
do u know anything about issues from my config file?
Could you send it as a file
Sure give me a second
oh wait
i think i know the issue
you know how to you need to remove the old config?....
yea lemme try w new config
i am soo stupid
i want to my bee follow me: ``` private void spawnBee(Location location, Player owner) {
Bee bee = (Bee) location.getWorld().spawnEntity(location, EntityType.BEE);
String customName = "§6Méhecske Pet §8(§7" + owner.getName() + "§8)";
bee.setCustomName(customName);
bee.setCustomNameVisible(true);
bee.setAI(true);
bee.setSilent(true);
bee.setCanPickupItems(false);
bee.setInvulnerable(true);
bee.setMetadata("owner", new FixedMetadataValue(this, owner.getUniqueId().toString()));
}```
Use PDC instead of metadata
okey but how my bee follow me?
also when spawning entities and modifying them you should use the spawn method that accepts a consumer
In this case you need to use NMS to create and spawn your entity
and not the method above
okey sure, but how my bee following me?
You make a goal
i know but how?
you can send me a link?
is player.sendMessage alr async or do i need to make it async myself?
please
why would you make it async
cuz chat is async
you don't have to do anything
thats why i asked
Premature optimization is bad
You'll only make things more complex and harder to maintain
this.goalSelector.addGoal(1, new PathfinderGoalFollowOwner(this, Player.class, 0.8F));? Expected 5 arguments but found 3,Cannot resolve symbol 'goalSelector'
what called?
I'm not going to repeat my self anymore
but i dont find anyting
We've given you multiple ways
send me a website please
?switchmappings
but there is noting that can help me
it can
this is only the import https://nms.screamingsandals.org/1.18.2/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.html
im trying PathFinder 5 hours but i dont find anyting working
someone can help me?
Do you have a custom nms implementation for your Bee?
You extend the NMS class, and override methods which you want to be changed.
There is one method responsible for initializing AI goals. This should be overridden.
PS: This comes with quite a bit of additional work. And also make sure to use mojangs mappings.
If i use protocollib to send a packet, will that function on all minecraft versions where that packet exists? Despite the nms packet structure being changed with different versions?
Protocollib checks the server version on startup and constructs packets based on that.
If the packet existed and PLib is supported for that version, then it will be sent. The problem is that
plib simply uses reflections to look for fields with a certain type. So if the packet structure changed fundamentally, then
it might lead to problems.
So wiki.vg could potentially be incorrect for certain versions then?
Looking at the nms packets is the way to go. Wiki.vg only tells you more specific infos for each field.
By looking at the nms packet how would i determine how to write to the plib packet? Is a structure modifier of the same type always used
Id imagine sometimes enums could be represented by a byte
Nope, remember, you dont write into the byte buffer, you write into fields.
So for enums there is an enum wrapper from Plib
how can i do that it sends you will be teleported in 5 seconds and not 5.0 "tp" is an double variable
plr.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§a You will be teleported in " + tp + " seconds"));
Try Math.round(tp)
okay ty
Gotchaa thanks
https://pastes.dev/eFmVpbapYY sorry for the ping, but could you please take a look at my current code, maybe you can tell why the sword stops in one place and does not follow the snowball)
it always makes me sad when people refer to wiki.vg when working with protocollib 🥲
I even changed it to an arrow, but it didn't do anything.
Anyone knows how the if statements worked with the ??
on return for example?
return condition ? ifTrue : ifFalse ?
is there a way to remove WhosThatPokemon:WhosThatPokemon from tabcompletions?
Hi. Im having this error where when I send "/pauseclock", "/resumeclock" and "/final" nothing happens. The console has no errors when I issue it.
I'm also having another error where after the first is created, any more clocks will automatically result in "End of Quarter" and the progress refuses to go down. This even happens if the clock has ended/I rejoin and it doesn't work anymore.
This script is using net.kyori.adventure for the bossbars
Here is the script:
https://paste.md-5.net/nucodabamo.java
youve been asking the same question 3 times now
and you havent implemented any of the changes we talked about
yeah bc i need help with it, and all i get is learn oop, which isnt really helpful at the moment
i am learning it i just need help with this right now
and i am still learning java
and the help is to learn OOP
that is the help
-dont take up that offer
I gave you an example to go off of here #1216833626898039005 message
i dont get what you mean by "the command shouldn't know about the bossbar"
learning java implies also learning OOP
the command and the bossbar are separate
the bossbar is part of the clock
the command can know about the clock
but the bossbar is implementation detail
for example - you may want to later choose to use an actionbar instead
or chat
Dont use packets. Just mount the item on your projectile.
so then how do i make it so that i can make the commands edit the bossbar, as in what i want would be pausing it
the commands dont edit the bossbar
the commands talk to the clock
and the clock edits the bossbar
the bossbar is just a front-end for your time
I tried addPassenger and without packets with the player it worked, but not with entityitem
Then packets wont change that
Mount an armorstand on your projectile and set its head to your item.
Might meed to use a slime with negative size to offset the item first.
Man working with old versions is just pure jank
Alternatively create your own custom projectile. I would probably go for that at this point.
With custom projectile i mean: A new object which has a tick method and gets moved every tick.
is there a way to remove WhosThatPokemon:WhosThatPokemon from tabcompletions?
Might be an event for that
PlayerCommandSendEvent
EntityArmorStand as = new EntityArmorStand(nmsSnowball.getWorld(), nmsSnowball.getBukkitEntity().getLocation().getX(), nmsSnowball.getBukkitEntity().getLocation().getY(), nmsSnowball.getBukkitEntity().getLocation().getZ());
as.getBukkitEntity().setGravity(false);
as.setInvisible(true);
as.setInvulnerable(true);
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(as);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
PacketPlayOutEntityEquipment p2 = new PacketPlayOutEntityEquipment(as.getId(), EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_SWORD)));
((CraftPlayer) p).getHandle().playerConnection.sendPacket(p2);``` can you tell me how to hide parts of the armor stand except the head?
I am trying to store an Object in a yaml file but am getting an exception regarding global tags not being allowed when loading the file. The object I am storing is relatively simple only containing integers, strings and also a Date object.
A section of the yaml:
daily-rewards: !!me.oak.rewards.module.DailyModule$UserData
dayNum: 1
lastCollectedDate: null
streakLength: 1
how can i link my crate keys to voting rewards?
EntitySnowball nmsSnowball = ((CraftSnowball) e.getEntity()).getHandle();
nmsSnowball.setInvisible(true);
nmsSnowball.shooter = ((CraftPlayer) p).getHandle();
nmsSnowball.getBukkitEntity().setMetadata("ballType", new FixedMetadataValue(SumeruRpg.plugin, "custom"));
nmsSnowball.setLocation(p.getEyeLocation().getX(), p.getEyeLocation().getY(), p.getEyeLocation().getZ(), 0.0F, 0.0F);;
EntityItem item = new EntityItem(
((CraftWorld) p.getWorld()).getHandle(),
p.getPlayer().getEyeLocation().getX(),
p.getPlayer().getEyeLocation().getY(),
p.getPlayer().getEyeLocation().getZ(),
CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.DIAMOND_SWORD)));
item.setNoGravity(true);
nmsSnowball.getBukkitEntity().setVelocity(p.getLocation().getDirection().multiply(1));
EntityArmorStand as = new EntityArmorStand(nmsSnowball.getWorld(), nmsSnowball.getBukkitEntity().getLocation().getX(), nmsSnowball.getBukkitEntity().getLocation().getY(), nmsSnowball.getBukkitEntity().getLocation().getZ());
as.getBukkitEntity().setGravity(false);
as.setInvisible(true);
as.setInvulnerable(true);
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(as);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
PacketPlayOutEntityEquipment p2 = new PacketPlayOutEntityEquipment(as.getId(), EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_SWORD)));
((CraftPlayer) p).getHandle().playerConnection.sendPacket(p2);
nmsSnowball.getBukkitEntity().addPassenger(as.getBukkitEntity());
what could be wrong, this somehow leads to the sword getting stuck somewhere in the middle?
the snowball stops hitting an invisible armor stand
how can i link my crate keys to my voting rewards
Are you making a plugin?
no i have a voting plugin already in my files and now i need toe get it working with crates
@EventHandler
public void onBossDamaged(EntityDamageEvent damageEvent){
if(damageEvent.getEntity() == entity){
Bukkit.broadcastMessage(damageEvent.getEntity().getLastDamageCause() + " dealt " + damageEvent.getDamage() + " damage!");
}
}
so i have a small problem
how can I get damager name from damage event?
or player even better
thats the entity that GETS damaged
i need the damager
omg im dumbo
thanks so much
fucking life saver i would have never figured this out (im lazy)
now only to get top damager list
agchem
i miss c++ where i could arr.push_back(x) :(
ill figure this out myself tho
list.add?
doin a little project with mythicmobs
exactly
but if many ppl hit the entity
then you can add up their damages
right?
because its still a damage event its not restricted to one player hitting it
it will proc if someone else damages it right?
cmarco check general
first of all, what the hell is a wrapper, second of all why cant i just make a list in my class because these are gonna need hard resetty after mob killed
i dont need damage list tho
You want to sum up the damage each play has done over the kill?
yesh
A simple Map<UUID, Double> would be enough then.
you got pranked. buy a bible or system32 bye bye
glad ion have that
<3 linux
so its fine if i just make two lists
and reset when i need to
right?
all i really need these for is printing highest numbers
with player names
Then a map would work just fine.
right
Unless you want the full damage history.
can i get player name frm uuid?
Yes
nope just the sum of damage
and if not?
some ppls might get 2 hits on the mob and leave
You can still get the name if they are offline
cuz bored
Just use OfflinePlayer#getName() if the player isn’t online.
right how do i make that map then
no its the right channel <3
wow
what do i do with that
Use it to instantiate your map.
:p
i only know maps in c++ :(
im sorry for being dumb and slow im still learning
mallnutrition
will do tomorrow
its getting late
eepy time for me
it's same data structure
Is there an updated post on this for later versions since they changed to using mojang mappings.
As a lot of the methods in here uses spigot mappings and some methods no longer even exists anymore.
?workdistro
Run ?cc list in #bot-commands
Hi, I'm wondering how to code an inventory animation. I'm thinking of using 'Bukkit.getScheduler().runTaskLater' and a loop to have several per second (10) and then assign it to the inventory. However, I think it's not really optimized, so if you have any suggestions, I'm all ears.
Oo smile is typing
You go
Use a single repeating task and then something to track the current animation frame
When working with menus I like to have a layer system so I can have the "base layer" which does all the regular logic and any sort of layers above that
Given that, I'd probably make an "AnimatedLayer" which wraps a list of pre-calculated animation frames
And that layer just increments and renders the current frame on the menu
go away
shoo
why does everyone treat marco like this?
yes why not
But yeah your animation frame is just a fancy Map<Integer, ItemStack> containing the items that changed
or the whole frame itself, depends on your renderer
Anyways back to working on fake blocks for the 5th time
xmaterial
cool I'm not using ProtocolLib
uh
well the problem is supporting 1.6.4
The ItemMeta is always a clone
Alright
Those are all the heads that exist in minecraft as Material?
Can't find any more
it's best if you try to reduce the number of call of new item metas @umbral ridge
Wasn't there a witch head as well
you get a clone of the itemmeta and work on that
I never ever created a new ItemMeta
if you need to modify it, you get it, keep it, and set it back
I got it from ItemStack
that's when you get a new item meta
Yeah but it's from ItemStack
I'm not saying ItemMeta itemMeta = new ItemMeta... idk if you even can do this, I dont have time for this right now
well when you do itemstack.getitemmeta you basically get a clone
which is a new item meta
as you can see
I call it like n times within the same second once per day, shouldn't affect performance
n could be around 250
well it could easily explode
actually, 9 times 3 times chests
and then you trust your garbage collector to not stall your code
its nothing to worry about
i'm not as paranoid as some people
a few bytes or kb don't hurt my 64gb of ram
the thing is the garbage collector will most likely have to do multiple passes to clean it up
because there are references
and those objects will also add up
It's nothing to worry about, happens once a day, every 24 hours
cool do I really want to write all of this from scratch
thanks for the paranoid tip XD
Hello, can someone gelp me with one problem with my server?
public static void assignTexture(ItemStack head, String url, String profileName, UUID profileID) {
SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
GameProfile profile = new GameProfile(profileID, profileName);
profile.getProperties().put("textures", new Property("textures", url));
try {
Field profileField = skullMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(skullMeta, profile);
} catch (IllegalArgumentException | SecurityException | NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
head.setItemMeta(skullMeta);
}```
I can't post images, but it says "inconsistent skull meta, you shouldn't use reflection anymore" - Bukiit server logs
you miss an extra field
Yeah bukkit has a player profile thing
And you can set profiles directly on the skull meta
skullMeta.setOwnerProfile
Do I need a real player profile then?
or set owner profile
Don't encourage more reflection,use the api
reflection is theBad
hm I need to work on a surface api
Method handles > Reflection
There used to be GameProfile, I think it still is, which had a method getProperties().put("textures", "skin-value")
skin-value is a 64chars long value that is basically a texture
Yeah I think that's all deprecated now lol
dang it
it's no biggie, for me, for now
anyone know how I can impl my own event which detects when a zombie hits a door
I don’t think there is anything that detects that in the api
dan
damn
well I knew that already
but how would I make my own event like that
alr nvm i aint doing allat
Well at least you have NMS
ZombieKnockKnockEvent
ZombieOpenUpTheDoorEvent
Hardcore
Check the wiki
They need to spawn with a certain NBT tag
They can knock on any difficulty but only break the door on hard
Could probably try entity interact event. There is also this event but it doesnt work to tell if the zombie is hitting the door, only if they broke it
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityBreakDoorEvent.html
declaration: package: org.bukkit.event.entity, class: EntityBreakDoorEvent
Do you guys have any idea how I can make this string look better?
colour
5 danger doesnt really tell us anything
maybe something easier to read
Pretty sure that top left button gives you the clone url
I have a disability. I absolutely SUCK at making things look good. If I send you the string, could you help me out in making it cleaner?
you can just send the string here
1. Player1 7 Danger. { X:871, Y:58, Z:-205 } - world_nether
2. Player2 2 Danger. { X:14635, Y:110, Z:14619 } - world
3. Player3 1 Danger. { X:9275, Y:110, Z:-1175 } - world
1. Player1 [close, armor] at X n Y n Z n in world```
I don't know what you base danger off
but if you can, try giving short hints
close to you, armored, hp, incoming
if they're in the same world omit that part
The entire concept is that players with more danger deserved to be hunted down
I'm personally more of a streams guy myself,
I gave a format
its up to them how they implement it
theyre for box drawing
also its just Unicode
guys
Hey all, any advice on where to start looking at this issue? https://imgur.com/a/c5RBCIR
It's only on some servers with my plugin on it.
where do you think is the best place to display stuff like a thirst bar and heat bar
all at once
encoding
your plugin is not r/w in UTF-8
that only supports one bar at a time tho right
You can fit a ton with custom font magic :p
You can make it a bar at the bottom that switches between the two. But if it was me i would make a score board to hold these that the player can open to look.
Do I fix it server side or plugin base?
How do i fix this?
hm
ill prob just use a scoreboard
I dont understand
show us
Like the code?
yes
@Override
public ItemStack render() {
String minBetFormatted = DecimalFormat.getCurrencyInstance(Locale.US).format(minBet);
String maxBetFormatted = DecimalFormat.getCurrencyInstance(Locale.US).format(maxBet);
ItemStack item = new ItemStack(Material.REDSTONE_LAMP);
ItemMeta meta = Objects.requireNonNull(item.getItemMeta());
meta.addEnchant(Enchantment.DURABILITY, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.setDisplayName("§c§lWheel of Fortune");
meta.setLore(List.of(
"§7Spin the wheel to try out your fortune!",
"",
"§7Minimum Bet: §a%s §7– Maximum Bet: §a%s".formatted(minBetFormatted, maxBetFormatted),
"",
"§eClick to play!"
));
item.setItemMeta(meta);
return item;
}
Example of GUI Item
Dont specify the color codes directly. Use the api to color the text instead
Translatealternatecolorcodes()
Is that the source of the problem?
no
Most likely since the section symbol is unicode and java is weird when you use unicode characters directly
declaration: package: org.bukkit, enum: ChatColor
Part of development. Besides switching to this api lets your text stuff be more configurable in terms of color later on
Also you should look into not hard coding your stuff and make use of config files
Can I open this Inventory for a Player?
Makes future changes easier
It is possible that may not be their issue, but given how many people have had issues with unicode characters probably best to start with that first lol
The donkey doesn't matter, it can also be completely black
true
if playes leaves server (PlayerQuitEvent) and I kill him at this moment, would the PlayerDeathEvent be called before player actually leaves or not?
So,
PlayerQuitEvent
// do some 1
player.damage(10000);
// do some 3
PlayerDeathEvent
// do some 2
The code will be executed sync in way
do some 1
do some 2
do some 3?
damage will trigger before quit happens
quit event is happening before the actual code
well yea, as well as the playerdeathevent right? I am trying to udnerstand if it's guaranteed if the playerdeathevent will be executed before playerquitevent
I will try this thanks :D
of course
Can i DM you?
death happens before as well
alr thanks
You were right. Did a test to check by replacing one, and you are absolutely correct 🙂
this is very clean, but can you send me the [ character in the same unicode family you used for these? ┏┣┗
There doesn't appear to be a left bracket one for a single unicode
nice
don't use latest or release as version xd
my plugin version?
jetbrains annotations dependencie
ohh but what do I put then
alright that fixed it
yea
what abt that? xD
btw this is the 1st time I'm compiling a plugin after codign it for about 1 week
its safe to ignore
not much you can do about it, other then manually exclude
as warning suggests
I mean im using org.jetbrains because otherwise I can't use @NotNull and stuff
If I use @NotNull or any of that stuff it FORCES me to use org.jetbrains
because it's not inbuilt??
in jdk
you shoudl not be shading annotations
it's done that by default
set annotations to compile scope
provided *
or that
So if I use provided then it should still work?
thanks
Xd
I have no idea about kotlin
but I do wanna learn it, just don't have time for new stuff right now
If you learn it now, you will have plenty more time for new stuff later since you won’t have to type the extra 5000 lines for access flags, getter, setters, delegates, singleton access etc
It adds up very quickly
I already know so much stuff
I went through web and desktop apps, logo design, ui/ux design
Kotlin will be pretty helpful then
i heard kotlin is for cross platform apps?
You can use JetPack Compose to build mobile, web & desktop apps
yea I heard about it
Java... not many styling frameworks and it's probably harder to build one (GUI)
can someone help me here quick nobody is responding in help-server
a lot of not-so-good stuff abt java
didnt you know 3 billion devices run java
Yes, the figure of which miraculously hasn’t changed in the course of 15 years
And the 3billion includes SIM & Credit cards
does Material#valueOf return null if item isnt found?
It creates a lookup table to find the enum constant by name
I'll look at jd
It can use the exact material name
The compiler*
It can also handle minecraft:name
I guess that's legacyName?
ahh
how about iron ingot
so matchMaterial returns null if it isnt found
or still exception
I can't look at the class because my intellij keeps freezing when i want to
?jd-s
null yes
Bills
Sadly does not return Bill
Hey quick question I am having some gson issues and currently the fix I have found for it is adding --add-opens java.base/java.util=ALL-UNNAMED to the start script for the server is there a way I can like do it within the library? (Its a public ones meaning yknow not everyone will be able to add --add-opens java.base/java.util=ALL-UNNAMED to the JVM args
Without it it throws illegal access because it cant access java.utils in java 17
Make custom adapters
Im not making a custom adapter for all java utils classes
And don’t rely on the native reflection system GSON uses
What on earth are you serializing
Its for storing custom NBT data so it needs to store various things and I have no control over what they try store because again its public
Explain further
the one I am testing with it throws issues just trying to store random even though its literally just
"random": {
"seed": 102919196753037,
"nextNextGaussian": 0.0,
"haveNextNextGaussian": false
}
``` cant even access seed
Thats not the issue though thats just an example because its part of a class that needs to be stored
If I don't have the JVM arg it cant access literally anything
Well yeah, because you shouldn’t be trying to store these kinds of things
How about you write type adapters for what users will actually be able to change
then you can extrapolate what you dont need
and save yourself some time and sanity
I dont think you are understanding it wont let me access almost anything its being really fucken stupid this stuff worked when I did it a while ago for I think it was 1.8
Theres just so much stuff not working that use to work fine
is BlockFormEvent the right event to be using when trying to detect copper block changing
no because again it stores a class that the user creates so I have no way of knowing what the user "wants to store"
It stores custom classes?
Ever heard of
Interfaces perhaps
Generally you only let the user store simple types and go from there
void serialize(JsonObject obj)
Numbers, strings
that defeats the whole idea of it
you'll be happy to know Random implements java.io.Serializable :kappa:
/**
* Used internally to serialize the nbt data
* @param content The class you want to serialize
* @return The now serialized json string
*/
private static String serializeContent(Object content) {
return gson.toJson(content);
}
/**
* Used to convert the stored json into a populated class
* @param cls The class you want to populate
* @param json The NBT json compound
* @return The now populated class
* @param <T> The type of the class you want to populate
*/
private static <T> T deserializeContent(Class<T> cls, String json) {
return gson.fromJson(json, cls);
}
/**
* Stores custom NBT content
* @param compoundTag The Compound tag you want to store in, usually use your plugins one
* @see LuaCore#getCompountName()
* @param content The value of the data you want to store
* @param nameSpaceKey where you should get the data from later
*/
public static void storeNBTContent(NBTCompound compoundTag, Object content, String nameSpaceKey) {
LuaMessageUtils.json_dump(content);
String json = serializeContent(content);
compoundTag.setString(nameSpaceKey, json);
}
/**
* Stores custom NBT content for entity
* @param readWriteNBT The ReadWriteNBT tag you want to store in, usually use your plugins one
* @see LuaCore#getCompountName()
* @param content The value of the data you want to store
* @param nameSpaceKey where you should get the data from later
*/
public static void storeEntityNBTContent(ReadWriteNBT readWriteNBT, Object content, String nameSpaceKey) {
LuaMessageUtils.json_dump(content);
String json = serializeContent(content);
readWriteNBT.setString(nameSpaceKey, json);
}
/**
* Gets custom NBT data
* @param cls The class you want to map to
* @param nameSpaceKey The key you set in {@link #storeNBTContent(NBTCompound, Object, String)}
* @param compoundTag The NBTCompound you are storing the custom NBT in
* @return Fully mapped class
* @param <T> The class type
*/
public static <T> T getNBTContent(Class<T> cls, String nameSpaceKey, NBTCompound compoundTag) {
if (compoundTag.hasTag(nameSpaceKey)) {
String json = compoundTag.getString(nameSpaceKey);
LuaMessageUtils.verboseMessage("Deserializing " + json);
return deserializeContent(cls, json);
}
return null;
}
/**
* Gets custom NBT data
* @param cls The class you want to map to
* @param nameSpaceKey The key you set in {@link #storeNBTContent(NBTCompound, Object, String)}
* @param readWriteNBT The NBTCompound you are storing the custom NBT in
* @return Fully mapped class
* @param <T> The class type
*/
public static <T> T getEntityNBTContent(Class<T> cls, String nameSpaceKey, ReadWriteNBT readWriteNBT) {
if (readWriteNBT.hasTag(nameSpaceKey)) {
String json = readWriteNBT.getString(nameSpaceKey);
LuaMessageUtils.verboseMessage("Deserializing " + json);
return deserializeContent(cls, json);
}
return null;
}
EntityBuilder entityBuilder = new EntityBuilder(EntityType.DROWNED);
// Entity builder stuff between here because I cba doing it all here
NBTUtils.storeNBTContent(compound, entityBuilder, nameSpace);
example would be something like this.
where say block place even you want to get the nbt from it to spawn the entity. once again it worked in previous projects with 1.8 and 1.12
why would you be paying google?
it does and guess what I still get illegal access for java.io too.
Seems like you got something funky going on with gson
nope latest gson
yes very sure
Yeah spigot ships with it
import dev.selena.libs.gson.Gson;
openjdk 17.0.10 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-120.04.1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Ubuntu-120.04.1, mixed mode, sharing)
exact same one its being compiled with too only windows version
And what is the trace you get when trying to de/serialize
for that specific one https://sourceb.in/XEt4L8Yrim
but others get various different ones some being java.utils some being java.io
all saying module java.base does not "opens PACKAGE_WITH_ISSUE" to unnamed module
Unable to make field private final
it serializes private final fine
That one seems sensible since Random doesnt have an official type adapter for it
i mean yeah, if the module isn't open to reflection for its inaccessible fields and types then you won't be able to access
I have had it complain about java.lang.String but as said adding --add-opens java.base/java.util=ALL-UNNAMED to the jvm args makes it run fine and again I can't rely on the end user to do that as not all will be able to
it certainly will work fine with j.l.String
but that's just how it is for the things it does not have an adapter for
usully ye but idfk why its doing that
Strongly coupled internal and public API modules my beloved
words dreamed by Ron Pressler
Nobody else
bump
I just need a way to not need to add --add-opens java.base/java.util=ALL-UNNAMED but have the same outcome
You shouldnt need to do that anyways
with that arg it gets the outcome I want
Remove serialisation of stuff you dont have adapters for
why do you want to serialize a random instance anyway lol
And it will magically work again

thats just this case its something that is in a class and the seed needs to be kept like yes I could store the seed only but thats not the point this is a single case where it could happen the rest are cases that I have 0 control over
just expose serialization and serialization methods in a base type 🙄
I know its not ideal
But the world isnt all sunshine and rainbows
You have to put in some work if you wish to hack stuff together like this
Especially with new Java
alternatively you can use annotations to expose the fields
You will still have to write custom serialization logic for that though
you do have control over the things you serialize, what
So either way you are going to have to write adapters
that I do yes not that the end users use
what you want is some magical solution that with no effort you can just serialize everything
that does not exist lol
xDD
Minimalists when they are encountered with a scenario that requires writing code
again, --add-opens java.base/java.util=ALL-UNNAMED this makes it work.
yes but this is not java 8 anymore, which is why you "need" that
you don't need that, you need to stop relying on gson's reflective serializer
^
↓
and add adapters of your own
jshell> new com.google.gson.Gson().toJson("hello", String.class)
$3 ==> "\"hello\""
it sure works fine for String
He probably miss-read the trace
ye thats not at all what happened
does String RANDOM_DURABILITY not match regex [A-Z_]? xD
Add a "+" if you want [1, inf[ chars
It's matching each characters individually
kinda new to regex
It takes time to learn but once you clearly get the logic you'll rekt every regex ahah
Yeah yeah we'll see
Glad you figured out the issue and i was of help 
I am currently at work so dm'ing still wouldnt be effective. Best to just comment here in case i dont answer and allowing someone else to possibly do so
I think the only downside to learning regex is to learn when not to use it since it is so easy to use lol
^ That's really true
how's work?
Going alright. Turns out they are not replacing my squeeze lift which is annoying. So now i have to wait for it to get repaired so it can break again
Squeeze lift is a fork lift. But instead of forks it has paddles to squeeze at the sides instead
Its so i can stack tires and move the stacks
No its not, but the one i have is old and constantly breaking. We bought new fork lifts but for whatever reason replacing this one is for whatever reason difficult. This last repair is because the wiring harness melted and it took out a few components with the harness lol
lol
The next thing to break is either going to be the oil pump or the hydraulic pump
they want you to have the old stuff xD
Everyone else is using newer ones and you're stuck with old
XD
Well, its a surprise they are fixing this instead of buying a new one. The repairs for this right now costs almost the same as if they just bought a new one
I am hoping if the hydraulic pump goes out they might just buy a new one lol
loll
Old machinery is always more robust than new one
But at somepoint people need to change still ahah
How can I send a player an actionbar message
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
Player#spigot().sendMessage(ChatMessageType, TextComponent);
that notation makes no sense lol
What notation
using a mixture of # and .
now they'll ask "what's TextManipulator?" :p
somePlayer.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacy("hewwo"));
it's an example
quickly pulled up one of my plugins where I use action bar messages
then they will ask about getColorizedString method
good strat
How can I make the player drop a specific armor item?
I'm making a thing where it picks a random armor piece that matches a predicate, and I want them to drop it
I am having a critical issue where (I think) seemingly randomly it picks an armor piece and drops it but doesn't remove it
If there is a way to remove an item based on the itemstack
that would fix all my problems
Can you show us the code where you pick the random item ?
You can't check equality between ItemStack since each item is unique. You have to check on the Material level
event.setCancelled(true);
player.sendMessage("You stay.");
xd not really canceling it but
adding item to player if they leave
how to cancel drop of items
using Q
PlayerDropEvent
ALT F4 is also considered as a leaving so I bet it can't work
Same goes for connection timed out
So theorically you can't unplug internet
wait u cant cancel leave event right
image if bukkit made a way to cancel it
wait but then if u alt f4 u close game but u still in server
but then u try joining again u get kicked for joining from same account but u cant get kicked
xDDD
damn that's.... not explicit ahah
So your problem is that the item from the inventory is not removed ?
What if you change
p.getEquipnent().setItem(getArmorIndex(armorIndex), new ItenStack(Material.AIR));
By ```java
p.getEquipnent().setItem(armorIndex, new ItenStack(Material.AIR));
So what's the method getArmorIndex?
Did you try to add some debbuging messages to check which armor should be removed
Which armorIndex, what is the resulting of getarmorIndex etc ?
It's quite literally random
Add debugging message to check
How can I check a random thing