Skip to content

Commit

Permalink
map command meta, equips event debork
Browse files Browse the repository at this point in the history
an item changing to itself is not an equip nor an unequip
  • Loading branch information
mcmonkey4eva committed Nov 19, 2019
1 parent b3ef48f commit 6e71aab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Expand Up @@ -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:<location>' 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
Expand Down

0 comments on commit 6e71aab

Please sign in to comment.