Update ConfigUpdater.update
Dieser Commit ist enthalten in:
Ursprung
e12bedec6c
Commit
ec771d31de
@ -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;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren