mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Don't upgrade old party DB schema from 8 years ago (band-aid fix, real fix coming later)
This commit is contained in:
parent
6c69cd2aea
commit
e8a0e6e4a4
@ -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<Party> 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<UUID, String> 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<Party> 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<UUID, String> 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.
|
||||
|
Loading…
Reference in New Issue
Block a user