From b69ca946a74a4c65f52f2dab9a9268e4d85b7cf9 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 20 Jul 2018 23:43:26 +1200 Subject: [PATCH] Add ability to make item disguises glow #291 --- pom.xml | 2 +- .../disguise/utilities/DisguiseParser.java | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 104c6344..da7a14b1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 LibsDisguises LibsDisguises - 9.5.2 + 9.5.2-SNAPSHOT src diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseParser.java b/src/me/libraryaddict/disguise/utilities/DisguiseParser.java index f2111fbf..1ea3bf31 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseParser.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseParser.java @@ -9,6 +9,7 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; import org.bukkit.inventory.ItemStack; import org.bukkit.permissions.PermissionAttachmentInfo; @@ -994,16 +995,33 @@ public class DisguiseParser { if (itemId != -1) { short itemDura = 0; + int amount = 1; + boolean enchanted = false; - if (split.length > 1) { - if (isInteger(split[1])) { - itemDura = Short.parseShort(split[1]); + for (int i = 1; i < split.length; i++) { + String s = split[i]; + + if (!enchanted && + (s.equalsIgnoreCase("glow") || s.equalsIgnoreCase("glowing") || s.equalsIgnoreCase("enchant") || + s.equalsIgnoreCase("enchanted"))) { + enchanted = true; + } else if (isInteger(s)) { + if (i == (enchanted ? 2 : 1)) { + itemDura = Short.parseShort(s); + } else if (i == (enchanted ? 3 : 2)) { + amount = Integer.parseInt(s); + } else { + throw parseToException(param, string, "%s"); + } } else { throw parseToException(param, string, "%s"); } } - return new ItemStack(itemId, 1, itemDura); + ItemStack itemStack = new ItemStack(itemId, amount, itemDura); + itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + + return itemStack; } else { if (split.length == 1) { throw parseToException(param, string, "%s");