CommandHelper

CommandHelper

46.5k Downloads

Carrying enchanted items causes player_death event to not trigger

LadyCailinBot opened this issue ยท 2 comments

commented

CMDHELPER-3120 - Reported by bunnies1230

I have a script bound to player_death that takes the player's inventory upon death and stores it. It is functional in every instance except when any enchanted item is included in their inventory upon death. When an enchanted item is included, the player_death event is not even triggered. Removing that item causes it to trigger successfully.

=Script in main.ms=

bind(player_death,null,null,@event,
	@p = player()
	@tag = concat(color(white),'[',color(yellow),'RPG',color(white),'] ')
	msg('Whoops, Something went wrong')
	modify_event('drops', null)
	
	include('includes/rpg_functions.ms')
	@kingdoms = _kingdoms()
	@governments = _governments()
	
	@kingdom = _pinfo(@p,'kingdom')
	@title = _pinfo(@p,'title')
	@killer = @event['killer']
	@kTitle = _pinfo(@killer,'title')
	if(@title != null){
		@name = concat(color(aqua),@title,' ',@p)
	}else{
		@position = _pinfo(@p,'position')
		if(@position == 'Leader' || @position == 'Advisor'){
			@name = concat(color(aqua),@position,' ',@p)
		}else{
			@name = concat(color(aqua),@p)
		}
	}
	if(string_position(string(@event),'killer: null') != -1){
		@cause = concat(' was killed')
	}else{
		if(@kTitle != null){
			@data = concat(@kTitle,' ',@killer)
		}else{
			@position = _pinfo(@killer,'position')
			if(@position == 'Leader' || @position == 'Advisor'){
				@data = concat(color(aqua),@position,' ',@killer)
			}else{
				@data = concat(color(aqua),@killer)
			}
		}
		@cause = concat(' was slain by ',color(green),@data)
	}
	
	@msg = concat(' ',@name,color(red),@cause)
	modify_event('death_message', @msg)
	
	@uuid = puuid(player(),True)
	@deathLoc = ploc()
	@deathInv = pinv()
	store_value('players.' . @uuid . '.deathloc.data', @deathLoc)
	store_value('players.' . @uuid . '.deathinv.data', @deathInv)
	@xDeath = round(@deathLoc[0])
	@yDeath = round(@deathLoc[1])
	@zDeath = round(@deathLoc[2])
	
	@keys = array_keys(@deathInv)
	@array = array()
	foreach(@slot in @keys){
		if(@deathInv[@slot] != null){
			array_push(@array,@slot)
		}
	}
	if(@array != array()){#if inventory is not empty
		msg(@tag,color(red),'A percentage of your items have been dropped!')
	}
		msg(@tag,color(red),'Death Location: ',color(aqua),@xDeath,', ',@yDeath,', ',@zDeath)
		die()
	
)

=Console Error=

[05:48:08] [Server thread/ERROR]: Could not pass event PlayerDeathEvent to CommandHelper v3.3.1-SNAPSHOT.3015-
org.bukkit.event.EventException
at com.laytonsmith.commandhelper.CommandHelperPlugin$7.execute(CommandHelperPlugin.java:501) ~[?:?]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerDeathEvent(CraftEventFactory.java:381) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.EntityPlayer.die(EntityPlayer.java:407) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.EntityLiving.damageEntity(EntityLiving.java:778) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.EntityHuman.damageEntity(EntityHuman.java:801) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.EntityPlayer.damageEntity(EntityPlayer.java:486) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.EntityLiving.G(EntityLiving.java:98) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.CommandKill.execute(SourceFile:29) [spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.craftbukkit.v1_8_R1.command.VanillaCommandWrapper.dispatchVanillaCommand(VanillaCommandWrapper.java:91) [spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.craftbukkit.v1_8_R1.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:42) [spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-899f5ee-1092acb]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:645) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot.jar:git-Spigot-899f5ee-1092acb]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_31]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_31]
at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:683) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot.jar:git-Spigot-899f5ee-1092acb]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigot.jar:git-Spigot-899f5ee-1092acb]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_31]
Caused by: java.lang.NoSuchMethodError: org.bukkit.inventory.meta.ItemMeta.getItemFlags()Ljava/util/Set;
at com.laytonsmith.abstraction.bukkit.BukkitMCItemMeta.getItemFlags(BukkitMCItemMeta.java:139) ~[?:?]
at com.laytonsmith.core.ObjectGenerator.itemMeta(ObjectGenerator.java:484) ~[?:?]
at com.laytonsmith.core.ObjectGenerator.item(ObjectGenerator.java:246) ~[?:?]
at com.laytonsmith.core.events.drivers.EntityEvents$entity_death.evaluate(EntityEvents.java:584) ~[?:?]
at com.laytonsmith.core.events.drivers.PlayerEvents$player_death.evaluate(PlayerEvents.java:1266) ~[?:?]
at com.laytonsmith.core.events.EventUtils.FireListeners(EventUtils.java:251) ~[?:?]
at com.laytonsmith.core.events.EventUtils.TriggerListener(EventUtils.java:239) ~[?:?]
at com.laytonsmith.abstraction.bukkit.events.drivers.BukkitEntityListener.onEntityDeath(BukkitEntityListener.java:79) ~[?:?]
at sun.reflect.GeneratedMethodAccessor309.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31]
at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31]
at com.laytonsmith.commandhelper.CommandHelperPlugin$7.execute(CommandHelperPlugin.java:499) ~[?:?]
... 26 more

commented

Comment by PseudoKnight

You are on a 1.8.0 build of Spigot that's over a year old. That method was added just a few weeks later. You should update, especially considering there were some security fixes in 1.8.3 - 1.8.4 that I would consider fairly critical.

commented

Comment by bunnies1230

Updated to a 1.8.8 build of spigot and it was resolved. Thank you!