Avec ce petit plugin, les objets qui sont stockés dans la liste de tableaux "FLOATING" ne devraient pas se désempiler, mais ils le font quand même ?
J'ai essayé d'utiliser à la fois ItemDespawnEvent et EntityDeathEvent et les deux n'ont pas fonctionné.
public void itemVanish2(ItemDespawnEvent e) {
if(e.getEntity().getType() == EntityType.DROPPED_ITEM) {
ItemStack i = (ItemStack) e.getEntity();
if(i.getItemMeta().getLore().contains("FLOATING"))
e.getEntity().getWorld().dropItem(e.getEntity().getLocation(), i);
} else {
return;
}
}
public void itemVanish(EntityDeathEvent e) {
if (e.getEntity().getType() == EntityType.DROPPED_ITEM) {
ItemStack i = (ItemStack) e.getEntity();
if (i.getItemMeta().getLore().contains("FLOATING"))
e.getEntity().getWorld().dropItem(e.getEntity().getLocation(), i);
} else {
return;
}
}
Je cherche à ce que les objets ne se désintègrent pas, mais dans la console, il y a une erreur, puis l'objet se désintègrera.
Voici l'erreur qui se produit :
[06:49:03] [Server thread/ERROR]: Could not pass event ItemDespawnEvent to FloatingShopItems v1.0.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:520) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:505) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory.callItemDespawnEvent(CraftEventFactory.java:621) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.EntityItem.tick(EntityItem.java:129) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.WorldServer.entityJoinedWorld(WorldServer.java:570) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.World.a(World.java:745) [spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.WorldServer.doTick(WorldServer.java:346) [spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1057) [spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396) [spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:956) [spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:801) [spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212]
Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_14_R1.entity.CraftItem cannot be cast to org.bukkit.inventory.ItemStack
at mad.madster.floatingitems.FloatingItems.itemVanish2(FloatingItems.java:138) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.14.2.jar:git-Spigot-093165d-ba575a5]