Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit f18fd50

Browse files
committed
Made Config converter to change legacy items to new items
1 parent d0cf88c commit f18fd50

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/main/java/com/massivecraft/factions/P.java

+53-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.bukkit.*;
2727
import org.bukkit.command.Command;
2828
import org.bukkit.command.CommandSender;
29+
import org.bukkit.configuration.ConfigurationSection;
2930
import org.bukkit.entity.ArmorStand;
3031
import org.bukkit.entity.EntityType;
3132
import org.bukkit.entity.Player;
@@ -55,6 +56,7 @@ public class P extends MPlugin {
5556
public CmdAutoHelp cmdAutoHelp;
5657
public boolean mc17 = false;
5758
public boolean mc18 = false;
59+
public boolean mc113 = false;
5860
public boolean useNonPacketParticles = false;
5961
public boolean factionsFlight = false;
6062
ItemStack item = new ItemStack(Material.CAKE);
@@ -159,7 +161,13 @@ public void onEnable() {
159161
} else if (version == 8) {
160162
P.p.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable.");
161163
mc18 = true;
162-
} else if (version > 8) {
164+
} else if (version == 13) {
165+
P.p.log("Minecraft Version 1.13 found, New Items will be used.");
166+
mc113 = true;
167+
changeItemIDSInConfig();
168+
}
169+
170+
if (version > 8) {
163171
useNonPacketParticles = true;
164172
P.p.log("Minecraft Version 1.9 or higher found, using non packet based particle API");
165173
}
@@ -218,6 +226,50 @@ private void setupPlaceholderAPI() {
218226
}
219227
}
220228

229+
230+
public void changeItemIDSInConfig() {
231+
232+
233+
P.p.log("Starting conversion of legacy material in config to 1.13 materials.");
234+
235+
236+
replaceStringInConfig("fperm-gui.relation.materials.recruit", "WOOD_SWORD", "WOODEN_SWORD");
237+
238+
replaceStringInConfig("fperm-gui.relation.materials.normal", "GOLD_SWORD", "GOLDEN_SWORD");
239+
240+
replaceStringInConfig("fperm-gui.relation.materials.ally", "GOLD_AXE", "GOLDEN_AXE");
241+
242+
replaceStringInConfig("fperm-gui.relation.materials.neutral", "WOOD_AXE", "WOODEN_AXE");
243+
244+
ConfigurationSection actionMaterialsConfigSection = getConfig().getConfigurationSection("fperm-gui.action.materials");
245+
246+
Set<String> actionMaterialKeys = actionMaterialsConfigSection.getKeys(true);
247+
248+
249+
for (String key : actionMaterialKeys) {
250+
replaceStringInConfig("fperm-gui.action.materials." + key, "STAINED_GLASS", "GRAY_STAINED_GLASS");
251+
}
252+
253+
replaceStringInConfig("fperm-gui.dummy-items.0.material", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE");
254+
255+
replaceStringInConfig("fwarp-gui.dummy-items.0.material", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE");
256+
257+
replaceStringInConfig("fupgrades.MainMenu.DummyItem.Type", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE");
258+
259+
replaceStringInConfig("fupgrades.MainMenu.EXP.EXPItem.Type", "EXP_BOTTLE", "EXPERIENCE_BOTTLE");
260+
261+
replaceStringInConfig("fupgrades.MainMenu.Spawners.SpawnerItem.Type", "MOB_SPAWNER", "SPAWNER");
262+
263+
264+
}
265+
266+
public void replaceStringInConfig(String path, String stringToReplace, String replacementString) {
267+
if (getConfig().getString(path).equals(stringToReplace)) {
268+
P.p.log("Replacing legacy material '" + stringToReplace + "' with '" + stringToReplace + "' for config node '" + path + "'.");
269+
getConfig().set(path, replacementString);
270+
}
271+
}
272+
221273
public boolean isClipPlaceholderAPIHooked() {
222274
return this.clipPlaceholderAPIManager != null;
223275
}

src/main/java/com/massivecraft/factions/zcore/fupgrades/FUpgradesGUI.java

+2
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ private ItemStack[] buildItems(FPlayer fme) {
238238
for (int i = 0; i <= expLore.size() - 1; i++) {
239239
expLore.set(i, expLore.get(i).replace("{level}", expLevel + ""));
240240
}
241+
Bukkit.broadcastMessage(P.p.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type"));
242+
241243
ItemStack expItem = P.p.createItem(expMaterial, expAmt, expData, expName, expLore);
242244
if (expLevel >= 1) {
243245
ItemMeta itemMeta = expItem.getItemMeta();

0 commit comments

Comments
 (0)