From ec771d31dee13b54f08a3df832a5dd3ffb42eace Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 29 Apr 2021 10:33:23 +0200 Subject: [PATCH] Update ConfigUpdater.update --- .../bausystem/configplayer/ConfigUpdater.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java index c48cd2f2..d028ff1d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java @@ -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 playerConfigurations = new HashMap<>(); private static final Map 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; }