diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityResurrectScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityResurrectScriptEvent.java index 35bb5df059..d08d748698 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityResurrectScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityResurrectScriptEvent.java @@ -1,9 +1,12 @@ package com.denizenscript.denizen.events.entity; +import com.denizenscript.denizen.events.BukkitScriptEvent; +import com.denizenscript.denizen.nms.NMSHandler; +import com.denizenscript.denizen.nms.NMSVersion; import com.denizenscript.denizen.objects.EntityTag; import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; -import com.denizenscript.denizen.events.BukkitScriptEvent; import com.denizenscript.denizencore.objects.ObjectTag; +import com.denizenscript.denizencore.objects.core.ElementTag; import com.denizenscript.denizencore.scripts.ScriptEntryData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -25,6 +28,7 @@ public class EntityResurrectScriptEvent extends BukkitScriptEvent implements Lis // // @Context // returns the EntityTag being resurrected. + // returns which hand the totem was in during resurrection, if any. Can be either HAND or OFF_HAND. Available only on MC 1.19+. // // @Player when the entity being resurrected is a player. // @@ -55,10 +59,17 @@ public ScriptEntryData getScriptEntryData() { @Override public ObjectTag getContext(String name) { - if (name.equals("entity")) { - return entity; - } - return super.getContext(name); + return switch (name) { + case "entity" -> entity; + case "hand" -> { + if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { + yield event.getHand() != null ? new ElementTag(event.getHand()) : null; + } + yield null; + } + default -> super.getContext(name); + }; + } @EventHandler