diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java new file mode 100644 index 00000000..1584c495 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java @@ -0,0 +1,15 @@ +package de.steamwar.bausystem.configplayer; + +import lombok.experimental.UtilityClass; +import yapion.hierarchy.types.YAPIONObject; + +@UtilityClass +public class ConfigCreator { + + public YAPIONObject createDefaultConfig() { + YAPIONObject yapionObject = new YAPIONObject(); + // Any initialising goes into here + return yapionObject; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java index cda0c09f..82e8264a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java @@ -1,12 +1,22 @@ package de.steamwar.bausystem.configplayer; -import lombok.experimental.UtilityClass; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import yapion.hierarchy.types.YAPIONObject; import java.util.HashMap; import java.util.Map; +import java.util.UUID; -@UtilityClass -public class ConfigUpdater { +@Linked(LinkageType.LISTENER) +public class ConfigUpdater implements Listener { + + private final Map playerConfigurations = new HashMap<>(); private static final Map CONFIG_CONVERTER_MAP = new HashMap<>(); @@ -14,4 +24,24 @@ public class ConfigUpdater { CONFIG_CONVERTER_MAP.putIfAbsent(configConverter.version(), configConverter); } + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + // Load call -> Database + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + // Save call -> Database + } + + public YAPIONObject load(Player player) { + if (!playerConfigurations.containsKey(player.getUniqueId())) { + // Load call -> Database + } + return playerConfigurations.get(player.getUniqueId()); + } + + public void save(Player player) { + // Save call -> Database + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/converter/.gitkeep b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/converter/.gitkeep new file mode 100644 index 00000000..e69de29b