From f18fd50d15b26f983fffce6a7981e92f40f7a156 Mon Sep 17 00:00:00 2001 From: ProSavage Date: Sat, 4 Aug 2018 21:41:31 -0500 Subject: [PATCH] Made Config converter to change legacy items to new items --- .../java/com/massivecraft/factions/P.java | 54 ++++++++++++++++++- .../zcore/fupgrades/FUpgradesGUI.java | 2 + 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index ddf620ab..4321f0b7 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -26,6 +26,7 @@ import net.milkbowl.vault.permission.Permission; import org.bukkit.*; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -55,6 +56,7 @@ public class P extends MPlugin { public CmdAutoHelp cmdAutoHelp; public boolean mc17 = false; public boolean mc18 = false; + public boolean mc113 = false; public boolean useNonPacketParticles = false; public boolean factionsFlight = false; ItemStack item = new ItemStack(Material.CAKE); @@ -159,7 +161,13 @@ public class P extends MPlugin { } else if (version == 8) { P.p.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable."); mc18 = true; - } else if (version > 8) { + } else if (version == 13) { + P.p.log("Minecraft Version 1.13 found, New Items will be used."); + mc113 = true; + changeItemIDSInConfig(); + } + + if (version > 8) { useNonPacketParticles = true; P.p.log("Minecraft Version 1.9 or higher found, using non packet based particle API"); } @@ -218,6 +226,50 @@ public class P extends MPlugin { } } + + public void changeItemIDSInConfig() { + + + P.p.log("Starting conversion of legacy material in config to 1.13 materials."); + + + replaceStringInConfig("fperm-gui.relation.materials.recruit", "WOOD_SWORD", "WOODEN_SWORD"); + + replaceStringInConfig("fperm-gui.relation.materials.normal", "GOLD_SWORD", "GOLDEN_SWORD"); + + replaceStringInConfig("fperm-gui.relation.materials.ally", "GOLD_AXE", "GOLDEN_AXE"); + + replaceStringInConfig("fperm-gui.relation.materials.neutral", "WOOD_AXE", "WOODEN_AXE"); + + ConfigurationSection actionMaterialsConfigSection = getConfig().getConfigurationSection("fperm-gui.action.materials"); + + Set actionMaterialKeys = actionMaterialsConfigSection.getKeys(true); + + + for (String key : actionMaterialKeys) { + replaceStringInConfig("fperm-gui.action.materials." + key, "STAINED_GLASS", "GRAY_STAINED_GLASS"); + } + + replaceStringInConfig("fperm-gui.dummy-items.0.material", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); + + replaceStringInConfig("fwarp-gui.dummy-items.0.material", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); + + replaceStringInConfig("fupgrades.MainMenu.DummyItem.Type", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); + + replaceStringInConfig("fupgrades.MainMenu.EXP.EXPItem.Type", "EXP_BOTTLE", "EXPERIENCE_BOTTLE"); + + replaceStringInConfig("fupgrades.MainMenu.Spawners.SpawnerItem.Type", "MOB_SPAWNER", "SPAWNER"); + + + } + + public void replaceStringInConfig(String path, String stringToReplace, String replacementString) { + if (getConfig().getString(path).equals(stringToReplace)) { + P.p.log("Replacing legacy material '" + stringToReplace + "' with '" + stringToReplace + "' for config node '" + path + "'."); + getConfig().set(path, replacementString); + } + } + public boolean isClipPlaceholderAPIHooked() { return this.clipPlaceholderAPIManager != null; } diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java index 480c4cc5..79ac6543 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java @@ -238,6 +238,8 @@ public class FUpgradesGUI implements Listener { for (int i = 0; i <= expLore.size() - 1; i++) { expLore.set(i, expLore.get(i).replace("{level}", expLevel + "")); } + Bukkit.broadcastMessage(P.p.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type")); + ItemStack expItem = P.p.createItem(expMaterial, expAmt, expData, expName, expLore); if (expLevel >= 1) { ItemMeta itemMeta = expItem.getItemMeta();