SteamWar/BauSystem2.0
Archiviert
12
0

Update ConfigUpdater.update

Dieser Commit ist enthalten in:
yoyosource 2021-04-29 10:33:23 +02:00
Ursprung e12bedec6c
Commit ec771d31de

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bausystem.configplayer;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -12,10 +13,13 @@ import yapion.hierarchy.types.YAPIONObject;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
@Linked(LinkageType.LISTENER)
public class ConfigUpdater implements Listener {
// TODO: implement everything
private final Map<UUID, YAPIONObject> playerConfigurations = new HashMap<>();
private static final Map<Integer, ConfigConverter> CONFIG_CONVERTER_MAP = new HashMap<>();
@ -50,14 +54,21 @@ public class ConfigUpdater implements Listener {
while (version < ConfigCreator.currentVersion) {
ConfigConverter configConverter = CONFIG_CONVERTER_MAP.getOrDefault(version, null);
if (configConverter == null) {
Bukkit.getLogger().log(Level.SEVERE, "No updater found for version " + version);
return ConfigCreator.createDefaultConfig();
}
try {
configConverter.update(yapionObject);
} catch (Exception e) {
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
return ConfigCreator.createDefaultConfig();
}
version = yapionObject.getPlainValue("@version");
int newVersion = yapionObject.getPlainValue("@version");
if (version == newVersion) {
Bukkit.getLogger().log(Level.SEVERE, "Version Tag was the same after conversion");
return ConfigCreator.createDefaultConfig();
}
version = newVersion;
}
return yapionObject;
}