From 6e71aabca3d2cb55d462d420e42ce23a0e9d3418 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Tue, 19 Nov 2019 08:18:29 -0800 Subject: [PATCH] map command meta, equips event debork an item changing to itself is not an equip nor an unequip --- .../events/PlayerEquipsArmorScriptEvent.java | 15 +++++++++++++++ .../denizen/scripts/commands/item/MapCommand.java | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/events/PlayerEquipsArmorScriptEvent.java b/paper/src/main/java/com/denizenscript/denizen/paper/events/PlayerEquipsArmorScriptEvent.java index 4f2ab5c9d3..dd5616e752 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/events/PlayerEquipsArmorScriptEvent.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/events/PlayerEquipsArmorScriptEvent.java @@ -7,10 +7,12 @@ import com.denizenscript.denizencore.objects.ObjectTag; import com.denizenscript.denizencore.objects.core.ElementTag; import com.denizenscript.denizencore.scripts.ScriptEntryData; +import com.denizenscript.denizencore.utilities.CoreUtilities; import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; import java.util.HashMap; @@ -119,8 +121,21 @@ else if (name.equals("slot")) { return super.getContext(name); } + public String simpleComparisonString(ItemStack stack) { + if (stack == null) { + return "null"; + } + stack = stack.clone(); + stack.setAmount(1); + stack.setDurability((short) 0); + return CoreUtilities.toLowerCase(new ItemTag(stack).identify()); + } + @EventHandler public void armorChangeEvent(PlayerArmorChangeEvent event) { + if (simpleComparisonString(event.getOldItem()).equals(simpleComparisonString(event.getNewItem()))) { + return; + } newItem = new ItemTag(event.getNewItem()); oldItem = new ItemTag(event.getOldItem()); slot = event.getSlotType(); diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/MapCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/MapCommand.java index 5165d91b91..0ac528eacb 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/MapCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/MapCommand.java @@ -34,11 +34,18 @@ public class MapCommand extends AbstractCommand { // @Description // This command modifies an existing map, or creates a new one. Using this will override existing // non-Denizen map renderers with Denizen's custom map renderer. + // // You can reset this at any time by using the 'reset:' argument, which will remove all // images and texts on the map and show the default world map at the specified location. + // // Note that all maps have a size of 128x128. + // // The file path is relative to the 'plugins/Denizen/images/' folder. + // Instead of a local file path, an http(s) URL can be used, which will automatically download the image from the URL given. + // If the file path points to a .gif, the map will automatically be animated. + // // Use escaping to let the image and text arguments have tags based on the player viewing the map. + // // Custom maps will persist over restarts using the 'maps.yml' save file in the Denizen plugins folder. // // @Tags