mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16: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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) {
|
// if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) {
|
||||||
loadAndUpgradeParties();
|
// loadAndUpgradeParties();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
YamlConfiguration partiesFile;
|
YamlConfiguration partiesFile;
|
||||||
@ -693,72 +693,72 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAndUpgradeParties() {
|
// private static void loadAndUpgradeParties() {
|
||||||
YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
// YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||||
|
//
|
||||||
if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
|
// if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
|
||||||
mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!");
|
// mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ArrayList<Party> hasAlly = new ArrayList<>();
|
// ArrayList<Party> hasAlly = new ArrayList<>();
|
||||||
|
//
|
||||||
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
// for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||||
Party party = new Party(partyName);
|
// Party party = new Party(partyName);
|
||||||
|
//
|
||||||
String leaderName = partiesFile.getString(partyName + ".Leader");
|
// String leaderName = partiesFile.getString(partyName + ".Leader");
|
||||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(leaderName, false);
|
// PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(leaderName, false);
|
||||||
|
//
|
||||||
if (!profile.isLoaded()) {
|
// if (!profile.isLoaded()) {
|
||||||
mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName);
|
// mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName);
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UUID leaderUniqueId = profile.getUniqueId();
|
// UUID leaderUniqueId = profile.getUniqueId();
|
||||||
|
//
|
||||||
party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
|
// party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
|
||||||
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
// party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
// party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||||
party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
// party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||||
party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
// party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||||
|
//
|
||||||
if (partiesFile.getString(partyName + ".Ally") != null) {
|
// if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||||
hasAlly.add(party);
|
// hasAlly.add(party);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
// party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||||
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
// party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||||
|
//
|
||||||
for (ItemShareType itemShareType : ItemShareType.values()) {
|
// for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||||
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
// party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
// LinkedHashMap<UUID, String> members = party.getMembers();
|
||||||
|
//
|
||||||
for (String memberName : partiesFile.getStringList(partyName + ".Members")) {
|
// for (String memberName : partiesFile.getStringList(partyName + ".Members")) {
|
||||||
PlayerProfile memberProfile = mcMMO.getDatabaseManager().loadPlayerProfile(memberName, false);
|
// PlayerProfile memberProfile = mcMMO.getDatabaseManager().loadPlayerProfile(memberName, false);
|
||||||
|
//
|
||||||
if (!memberProfile.isLoaded()) {
|
// if (!memberProfile.isLoaded()) {
|
||||||
mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName);
|
// mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName);
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UUID memberUniqueId = memberProfile.getUniqueId();
|
// UUID memberUniqueId = memberProfile.getUniqueId();
|
||||||
|
//
|
||||||
members.put(memberUniqueId, memberName);
|
// members.put(memberUniqueId, memberName);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
parties.add(party);
|
// parties.add(party);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");
|
// mcMMO.p.debug("Loaded (" + parties.size() + ") Parties...");
|
||||||
|
//
|
||||||
for (Party party : hasAlly) {
|
// for (Party party : hasAlly) {
|
||||||
party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
|
// party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY);
|
// mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle party change event.
|
* Handle party change event.
|
||||||
|
Loading…
Reference in New Issue
Block a user