From e8a0e6e4a48acb65ca3647e6a95f5504de4f6abe Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 9 Mar 2021 19:47:35 -0800 Subject: [PATCH] Don't upgrade old party DB schema from 8 years ago (band-aid fix, real fix coming later) --- .../com/gmail/nossr50/party/PartyManager.java | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 6a1591a70..c825694b9 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -586,10 +586,10 @@ public final class PartyManager { return; } - if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) { - loadAndUpgradeParties(); - return; - } +// if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) { +// loadAndUpgradeParties(); +// return; +// } try { YamlConfiguration partiesFile; @@ -693,72 +693,72 @@ public final class PartyManager { } } - private static void loadAndUpgradeParties() { - YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile); - - if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) { - mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!"); - return; - } - - ArrayList hasAlly = new ArrayList<>(); - - for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { - Party party = new Party(partyName); - - String leaderName = partiesFile.getString(partyName + ".Leader"); - PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(leaderName, false); - - if (!profile.isLoaded()) { - mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName); - continue; - } - - UUID leaderUniqueId = profile.getUniqueId(); - - party.setLeader(new PartyLeader(leaderUniqueId, leaderName)); - party.setPassword(partiesFile.getString(partyName + ".Password")); - party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); - party.setLevel(partiesFile.getInt(partyName + ".Level")); - party.setXp(partiesFile.getInt(partyName + ".Xp")); - - if (partiesFile.getString(partyName + ".Ally") != null) { - hasAlly.add(party); - } - - party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE"))); - party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE"))); - - for (ItemShareType itemShareType : ItemShareType.values()) { - party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true)); - } - - LinkedHashMap members = party.getMembers(); - - for (String memberName : partiesFile.getStringList(partyName + ".Members")) { - PlayerProfile memberProfile = mcMMO.getDatabaseManager().loadPlayerProfile(memberName, false); - - if (!memberProfile.isLoaded()) { - mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName); - continue; - } - - UUID memberUniqueId = memberProfile.getUniqueId(); - - members.put(memberUniqueId, memberName); - } - - parties.add(party); - } - - mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); - - for (Party party : hasAlly) { - party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); - } - - mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY); - } +// private static void loadAndUpgradeParties() { +// YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile); +// +// if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) { +// mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!"); +// return; +// } +// +// ArrayList hasAlly = new ArrayList<>(); +// +// for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { +// Party party = new Party(partyName); +// +// String leaderName = partiesFile.getString(partyName + ".Leader"); +// PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(leaderName, false); +// +// if (!profile.isLoaded()) { +// mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName); +// continue; +// } +// +// UUID leaderUniqueId = profile.getUniqueId(); +// +// party.setLeader(new PartyLeader(leaderUniqueId, leaderName)); +// party.setPassword(partiesFile.getString(partyName + ".Password")); +// party.setLocked(partiesFile.getBoolean(partyName + ".Locked")); +// party.setLevel(partiesFile.getInt(partyName + ".Level")); +// party.setXp(partiesFile.getInt(partyName + ".Xp")); +// +// if (partiesFile.getString(partyName + ".Ally") != null) { +// hasAlly.add(party); +// } +// +// party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE"))); +// party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE"))); +// +// for (ItemShareType itemShareType : ItemShareType.values()) { +// party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true)); +// } +// +// LinkedHashMap members = party.getMembers(); +// +// for (String memberName : partiesFile.getStringList(partyName + ".Members")) { +// PlayerProfile memberProfile = mcMMO.getDatabaseManager().loadPlayerProfile(memberName, false); +// +// if (!memberProfile.isLoaded()) { +// mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName); +// continue; +// } +// +// UUID memberUniqueId = memberProfile.getUniqueId(); +// +// members.put(memberUniqueId, memberName); +// } +// +// parties.add(party); +// } +// +// mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); +// +// for (Party party : hasAlly) { +// party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); +// } +// +// mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY); +// } /** * Handle party change event.