From 2bb57a42f50dbb4a147f30a41dd22880af62a42e Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Mon, 27 Sep 2021 16:51:29 +1000 Subject: [PATCH] 3.17.1.3 --- ...{MMOItems_6_6_0.xml => MMOItems_6_6_1.xml} | 4 +- ...ythicLib_1_1_1.xml => MythicLib_1_1_3.xml} | 4 +- Command Panels.iml | 4 +- resource/plugin.yml | 2 +- .../commandpanels/CommandPanels.java | 6 +++ .../classresources/ItemCreation.java | 39 +++++++++++++++++-- 6 files changed, 48 insertions(+), 11 deletions(-) rename .idea/libraries/{MMOItems_6_6_0.xml => MMOItems_6_6_1.xml} (72%) rename .idea/libraries/{MythicLib_1_1_1.xml => MythicLib_1_1_3.xml} (71%) diff --git a/.idea/libraries/MMOItems_6_6_0.xml b/.idea/libraries/MMOItems_6_6_1.xml similarity index 72% rename from .idea/libraries/MMOItems_6_6_0.xml rename to .idea/libraries/MMOItems_6_6_1.xml index 192dd6a..25d2ca1 100644 --- a/.idea/libraries/MMOItems_6_6_0.xml +++ b/.idea/libraries/MMOItems_6_6_1.xml @@ -1,7 +1,7 @@ - + - + diff --git a/.idea/libraries/MythicLib_1_1_1.xml b/.idea/libraries/MythicLib_1_1_3.xml similarity index 71% rename from .idea/libraries/MythicLib_1_1_1.xml rename to .idea/libraries/MythicLib_1_1_3.xml index 8baa9a2..749f244 100644 --- a/.idea/libraries/MythicLib_1_1_1.xml +++ b/.idea/libraries/MythicLib_1_1_3.xml @@ -1,7 +1,7 @@ - + - + diff --git a/Command Panels.iml b/Command Panels.iml index a35a8bf..6937f0e 100644 --- a/Command Panels.iml +++ b/Command Panels.iml @@ -17,7 +17,7 @@ - - + + \ No newline at end of file diff --git a/resource/plugin.yml b/resource/plugin.yml index 5539139..243aa5e 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.17.1.2 +version: 3.17.1.3 main: me.rockyhawk.commandpanels.CommandPanels name: CommandPanels author: RockyHawk diff --git a/src/me/rockyhawk/commandpanels/CommandPanels.java b/src/me/rockyhawk/commandpanels/CommandPanels.java index 927cc6d..5c28918 100644 --- a/src/me/rockyhawk/commandpanels/CommandPanels.java +++ b/src/me/rockyhawk/commandpanels/CommandPanels.java @@ -311,6 +311,12 @@ public class CommandPanels extends JavaPlugin{ //hiding attributes will add an NBT tag if(hideAttributes) { renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + renamedMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + renamedMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + //HIDE_DYE was added into 1.17 api + if(legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){ + renamedMeta.addItemFlags(ItemFlag.HIDE_DYE); + } } if (customName != null) { renamedMeta.setDisplayName(customName); diff --git a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java index 450a491..349c78e 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java +++ b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java @@ -319,10 +319,24 @@ public class ItemCreation { //if the item is a potion, give it an effect try { PotionMeta potionMeta = (PotionMeta)s.getItemMeta(); - String effectType = itemSection.getString("potion"); + String[] effectType = itemSection.getString("potion").split("\\s"); assert potionMeta != null; - assert effectType != null; - potionMeta.setBasePotionData(new PotionData(PotionType.valueOf(effectType.toUpperCase()))); + boolean extended = false; + boolean upgraded = false; + //create data + if(effectType.length >= 2){ + if(effectType[1].equalsIgnoreCase("true")){ + extended = true; + } + if(effectType.length == 3){ + if(effectType[2].equalsIgnoreCase("true")){ + upgraded = true; + } + } + } + PotionData newData = new PotionData(PotionType.valueOf(effectType[0].toUpperCase()),extended,upgraded); + //set meta + potionMeta.setBasePotionData(newData); potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); s.setItemMeta(potionMeta); } catch (Exception er) { @@ -459,7 +473,7 @@ public class ItemCreation { /* The ItemStack 'one' will be used, if it doesn't have a lore for example, it won't check to see if the other does have one The isIdentical() function will check for the following - Material, Name, Lore, Enchanted + Material, Name, Lore, Enchanted, Potion */ @SuppressWarnings("deprecation") public boolean isIdentical(ItemStack one, ItemStack two){ @@ -497,6 +511,23 @@ public class ItemCreation { } } } catch (Exception ignore) {} + //check for potions + try { + PotionMeta meta1 = (PotionMeta) one.getItemMeta(); + PotionMeta meta2 = (PotionMeta) two.getItemMeta(); + //different duration + if(meta1.getBasePotionData().isExtended() != meta2.getBasePotionData().isExtended()){ + return false; + } + //different upgrade + if(meta1.getBasePotionData().isUpgraded() != meta2.getBasePotionData().isUpgraded()){ + return false; + } + //different potion type + if (meta1.getBasePotionData().getType().compareTo(meta2.getBasePotionData().getType()) != 0){ + return false; + } + }catch(Exception ignore){} //check for enchantments if(one.getEnchantments() == two.getEnchantments()){ if(!one.getEnchantments().isEmpty()) {