From b2fd40eb1c8a82226a8cce8e4031ff2b7ae4c970 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 21 Jan 2019 00:14:31 +0800 Subject: [PATCH] 1.0.0-SNAPSHOT-U203c + Finished implementing the Legacy version --- TODO | 8 ----- .../Core/resources-json/droptables.json | 9 ++++-- plugin-modules/Core/resources-json/items.json | 8 ++--- plugin-modules/Core/resources-yml/editor.yml | 2 +- .../panel/EntityTypeEditorPanel.java | 21 ++++--------- .../DropTableRewardsListEditorPanel.java | 2 ++ .../epicbosses/utils/EnchantFinder.java | 10 +++---- .../utils/itemstack/ItemStackConverter.java | 8 ++++- .../utils/itemstack/ItemStackUtils.java | 30 +++++++++---------- .../converters/MaterialConverter.java | 4 +++ 10 files changed, 50 insertions(+), 52 deletions(-) diff --git a/TODO b/TODO index d16441a..5f1fc67 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,3 @@ -00:30 -> Add HolographicDisplay/PlaceholderAPI support for custom placeholders on AutoSpawnInterval times -01:00 -> Add a new branch for the plugin and add support for Legacy version - ------------ -1:30 hrs - - - ------------------------------------- TO DO AFTER RELEASE --------------------------------------------------- 02:00 -> Randomly in the wilderness, bosses will spawn with x chance within coords as a player is loading chunks 00:45 -> Randomly from a spawner, bosses will spawn with x chance within coords when a spawner is spawning mobs of the same type diff --git a/plugin-modules/Core/resources-json/droptables.json b/plugin-modules/Core/resources-json/droptables.json index db2b8da..8624a8b 100644 --- a/plugin-modules/Core/resources-json/droptables.json +++ b/plugin-modules/Core/resources-json/droptables.json @@ -6,9 +6,12 @@ "1": { "1": { "items": { - "SKEco500": 30.0, - "SKEco2500": 50.0, - "SKEco5000": 10.0 + "SKMainHand": 15.0, + "SKOffHand": 15.0, + "SKHelmet": 15.0, + "SKLeggings": 30.0, + "SKChestplate": 30.0, + "SKBoots": 30.0 }, "commands": { "SKEco500": 30.0, diff --git a/plugin-modules/Core/resources-json/items.json b/plugin-modules/Core/resources-json/items.json index c333d7b..be7ea63 100644 --- a/plugin-modules/Core/resources-json/items.json +++ b/plugin-modules/Core/resources-json/items.json @@ -61,15 +61,15 @@ ] }, "SKHelmet": { - "type": "GOLDEN_HELMET", + "type": "GOLD_HELMET", "enchants": [ "protection:4", "unbreaking:3" ] }, "SKChestplate": { - "type": "GOLDEN_CHESTPLATE", + "type": "GOLD_CHESTPLATE", "enchants": [ "protection:4", "unbreaking:3" ] }, "SKLeggings": { - "type": "GOLDEN_LEGGINGS", + "type": "GOLD_LEGGINGS", "enchants": [ "protection:4", "unbreaking:3" ] }, "SKBoots": { @@ -81,7 +81,7 @@ "enchants": [ "sharpness:4", "unbreaking:3" ] }, "SKOffHand": { - "type": "SHIELD" + "type": "STICK" }, "SKCustomDrop1": { "type": "STONE", diff --git a/plugin-modules/Core/resources-yml/editor.yml b/plugin-modules/Core/resources-yml/editor.yml index aab84b4..50d9944 100644 --- a/plugin-modules/Core/resources-yml/editor.yml +++ b/plugin-modules/Core/resources-yml/editor.yml @@ -18,7 +18,7 @@ MainMenu: Settings: emptySpaceFiller: true EmptySpaceFiller: - type: STAINED_THIN_GLASS + type: STAINED_GLASS_PANE name: '&7' Items: '2': diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/EntityTypeEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/EntityTypeEditorPanel.java index 8b62e6d..1122cb0 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/EntityTypeEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/EntityTypeEditorPanel.java @@ -36,7 +36,7 @@ public class EntityTypeEditorPanel extends SubVariablePanelHandler list = Arrays.stream(EntityType.values()).filter(EntityType::isSpawnable).collect(Collectors.toList()); - Map filteredMap = getFilteredMap(list); + Map filteredMap = getFilteredMap(list); List filteredList = new ArrayList<>(filteredMap.keySet()); int maxPage = panel.getMaxPage(filteredMap); @@ -74,22 +74,15 @@ public class EntityTypeEditorPanel extends SubVariablePanelHandler getFilteredMap(List entityTypes) { - Map filteredMap = new HashMap<>(); + private Map getFilteredMap(List entityTypes) { + Map filteredMap = new HashMap<>(); - entityTypes.forEach(entityType -> { - String materialName = entityType + "_SPAWN_EGG"; - Material material = Material.matchMaterial(materialName); - - if(material == null) return; - - filteredMap.put(entityType, material); - }); + entityTypes.forEach(entityType -> filteredMap.put(entityType, entityType.getTypeId())); return filteredMap; } - private void loadPage(Panel panel, int requestedPage, Map filteredMap, List filteredList, BossEntity bossEntity, EntityStatsElement entityStatsElement) { + private void loadPage(Panel panel, int requestedPage, Map filteredMap, List filteredList, BossEntity bossEntity, EntityStatsElement entityStatsElement) { String entityTypeValue = entityStatsElement.getMainStats().getEntityType(); ServerUtils.get().runTaskAsync(() -> panel.loadPage(requestedPage, ((slot, realisticSlot) -> { @@ -97,9 +90,7 @@ public class EntityTypeEditorPanel extends SubVariablePanelHandler {}); } else { EntityType entityType = filteredList.get(slot); - Material material = filteredMap.get(entityType); - ItemStack itemStack = new ItemStack(material); - + ItemStack itemStack = new ItemStack(Material.MONSTER_EGG, filteredMap.get(entityType)); Map replaceMap = new HashMap<>(); boolean found = false; diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java index fbdd8cf..b366a8d 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java @@ -96,6 +96,8 @@ public abstract class DropTableRewardsListEditorPanel extends SubVa ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(this.itemsFileManager.getItemStackHolder(name)); + if(itemStack == null || itemStack.getType() == Material.AIR) return; + ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.RewardList.name"), replaceMap); ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.RewardList.lore"), replaceMap); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/EnchantFinder.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/EnchantFinder.java index 76e8a56..e4e191b 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/EnchantFinder.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/EnchantFinder.java @@ -23,15 +23,15 @@ public enum EnchantFinder { aqua_affinity("Aqua Affinity", Enchantment.WATER_WORKER, "water_worker", "water worker", "aquaaffinity", "aqua_affinity", "aqua affinity"), thorns("Thorns", Enchantment.THORNS, "thorns"), depth_strider("Depth Strider", Enchantment.DEPTH_STRIDER, "depth_strider", "depth strider"), - frost_walker("Frost Walker", Enchantment.FROST_WALKER, "frost_walker", "frost walker"), - binding_curse("Curse of Binding", Enchantment.BINDING_CURSE, "binding_curse", "binding curse", "curse"), + frost_walker("Frost Walker", Enchantment.getByName("FROST_WALKER"), "frost_walker", "frost walker"), + binding_curse("Curse of Binding", Enchantment.getByName("BINDING_CURSE"), "binding_curse", "binding curse", "curse"), sharpness("Sharpness", Enchantment.DAMAGE_ALL, "sharpness", "damage", "damage all", "damage_all"), smite("Smite", Enchantment.DAMAGE_UNDEAD, "smite", "damage_undead", "damage undead"), bane_of_arthropods("Bane of Arthropods", Enchantment.DAMAGE_ARTHROPODS, "damage_arthropods", "arthropods", "bane_of_arthropods", "bane of arthropods"), knockback("Knockback", Enchantment.KNOCKBACK, "knockback"), fire_aspect("Fire Aspect", Enchantment.FIRE_ASPECT, "fire aspect", "fire_aspect", "fireaspect"), looting("Looting", Enchantment.LOOT_BONUS_MOBS, "looting", "loot bonus mobs", "loot_bonus_mobs"), - sweeping_edge("Sweeping Edge", Enchantment.SWEEPING_EDGE, "sweeping edge", "sweeping_edge"), + sweeping_edge("Sweeping Edge", Enchantment.getByName("SWEEPING_EDGE"), "sweeping edge", "sweeping_edge"), efficiency("Efficiency", Enchantment.DIG_SPEED, "efficiency", "dig speed", "dig_speed", "digspeed"), silk_touch("Silk Touch", Enchantment.SILK_TOUCH, "silk touch", "silk_touch", "silktouch", "silk"), unbreaking("Unbreaking", Enchantment.DURABILITY, "durability", "unbreaking"), @@ -42,8 +42,8 @@ public enum EnchantFinder { infinite("Infinite", Enchantment.ARROW_INFINITE, "infinite", "arrow_infinite", "arrow infinite"), luck("Luck", Enchantment.LUCK, "luck"), lure("Lure", Enchantment.LURE, "lure"), - mending("Mending", Enchantment.MENDING, "mending"), - curse_of_vanishing("Curse of Vanishing", Enchantment.VANISHING_CURSE, "vanishing", "vanishing curse", "vanishing_curse", "curseofvanishing", "vanishingcurse", "curse of vanishing", "curse_of_vanishing"); + mending("Mending", Enchantment.getByName("MENDING"), "mending"), + curse_of_vanishing("Curse of Vanishing", Enchantment.getByName("VANISHING_CURSE"), "vanishing", "vanishing curse", "vanishing_curse", "curseofvanishing", "vanishingcurse", "curse of vanishing", "curse_of_vanishing"); @Getter private List names = new ArrayList<>(); @Getter private Enchantment enchantment; diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackConverter.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackConverter.java index 5c66165..4f1d71d 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackConverter.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackConverter.java @@ -106,9 +106,11 @@ public class ItemStackConverter implements IReplaceableConverter replaceMap) { ItemStack itemStack = new ItemStack(Material.AIR); + if(itemStackHolder == null) return itemStack; if(itemStackHolder.getType() == null) return itemStack; - Material material = this.materialConverter.from(itemStackHolder.getType()); + String type = itemStackHolder.getType(); + Material material = this.materialConverter.from(type); if(material == null) return itemStack; @@ -120,6 +122,10 @@ public class ItemStackConverter implements IReplaceableConverter lore = itemStackHolder.getLore(), enchants = itemStackHolder.getEnchants(); Boolean isGlowing = itemStackHolder.getIsGlowing(); + if(type.contains(":")) { + durability = Short.valueOf(type.split(":")[1]); + } + if(durability != null) itemStack.setDurability(durability); if(enchants != null) itemStack.addUnsafeEnchantments(this.enchantConverter.from(enchants)); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java index 7ba47ec..09f7023 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/ItemStackUtils.java @@ -62,15 +62,6 @@ public class ItemStackUtils { if(compoundData == null || compoundData.isEmpty()) return cloneStack; -// TODO -// ItemStack craftStack = NbtFactory.getCraftItemStack(cloneStack); -// NbtFactory.NbtCompound compound = NbtFactory.fromItemTag(craftStack); -// -// for(String s : compoundData.keySet()) { -// compound.put(s, compoundData.get(s)); -// } -// -// return craftStack; return cloneStack; } @@ -87,17 +78,26 @@ public class ItemStackUtils { String owner = configurationSection.getString("owner"); Map map = new HashMap<>(); List newLore = new ArrayList<>(); - Material mat = getType(type); - short meta = 0; boolean addGlow = false; + short meta = 0; + Material mat; - if(type instanceof String) { - String sType = (String) type; + if(NumberUtils.get().isInt(type)) { + mat = Material.getMaterial(NumberUtils.get().getInteger(type)); + } else { + if(type.contains(":")) { + String[] split = type.split(":"); + String typeSplit = split[0]; - if(sType.contains(":")) { - String[] split = sType.split(":"); + if(NumberUtils.get().isInt(typeSplit)) { + mat = Material.getMaterial(NumberUtils.get().getInteger(typeSplit)); + } else { + mat = Material.getMaterial(typeSplit); + } meta = Short.valueOf(split[1]); + } else { + mat = Material.getMaterial(type); } } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/converters/MaterialConverter.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/converters/MaterialConverter.java index 516540c..0efc4af 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/converters/MaterialConverter.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/itemstack/converters/MaterialConverter.java @@ -24,6 +24,10 @@ public class MaterialConverter implements IConverter { input = split[0]; } + if(NumberUtils.get().isInt(input)) { + return Material.getMaterial(NumberUtils.get().getInteger(input)); + } + return Material.matchMaterial(input); } }