From 1c143f43da1ac6e681a81b956ad2345734f99f36 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 14 May 2021 16:33:06 +0200 Subject: [PATCH] Add Config query database Fix BauInfoBauGuiItem Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 3 ++- .../de/steamwar/bausystem/configplayer/Config.java | 13 ++++++++++--- .../bausystem/features/bau/BauInfoBauGuiItem.java | 4 ++-- .../features/countingwand/CountingwandCommand.java | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index ae09adcf..2dccbe9b 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -105,10 +105,11 @@ BAU_UNKNOWN-PLAYER = §cUnbekannter Spieler BAU_NO-PLAYER = §cDer Spieler ist kein Mitglied deiner Welt! BAU_NO-WORLD = §cDies ist nicht deine Welt! -BAU_INFO_ITEM_NAME = §eBau management +BAU-INFO_ITEM_NAME = §eBau management ## This is used in BauInfoBauGuiItem.java BAU-INFO_ITEM_LORE-TNT = §7TNT §8: §e{0} BAU-INFO_ITEM_LORE-FREEZE = §7Freeze §8: §e{0} +BAU-INFO_ITEM_LORE-DAMAGE = §7Damage §8: §e{0} BAU-INFO_ITEM_LORE-FIRE = §7Feuer §8: §e{0} BAU-INFO_ITEM_LORE-COLOR = §7Farbe §8: §e{0} BAU-INFO_ITEM_LORE-PROTECT = §7Protect §8: §e{0} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java index 357b4781..a855c710 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java @@ -2,6 +2,7 @@ package de.steamwar.bausystem.configplayer; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.sql.UserConfig; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -9,6 +10,7 @@ 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.output.StringOutput; import yapion.hierarchy.types.YAPIONObject; import yapion.parser.YAPIONParser; @@ -55,14 +57,14 @@ public class Config implements Listener { public YAPIONObject get(Player player) { UUID uuid = player.getUniqueId(); if (!playerConfigurations.containsKey(uuid)) { - // TODO: Load call -> Database - String s = null; + String s = UserConfig.getConfig(uuid, "bausystem"); YAPIONObject yapionObject; if (s == null) { yapionObject = ConfigCreator.createDefaultConfig(); } else { yapionObject = YAPIONParser.parse(s); } + yapionObject = update(yapionObject); playerConfigurations.put(uuid, yapionObject); return yapionObject; } @@ -75,7 +77,12 @@ public class Config implements Listener { * @param player the player to save the config. */ public void save(Player player) { - // TODO: Save call -> Database + UUID uuid = player.getUniqueId(); + if (playerConfigurations.containsKey(uuid)) { + YAPIONObject yapionObject = playerConfigurations.get(uuid); + String string = yapionObject.toYAPION(new StringOutput()).getResult(); + UserConfig.updatePlayerConfig(uuid, "bausystem", string); + } } private YAPIONObject update(YAPIONObject yapionObject) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java index dd843c85..761d4aa0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java @@ -46,7 +46,7 @@ public class BauInfoBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { SWItem itemStack = SWItem.getPlayerSkull(SteamwarUser.get(BauServer.getInstance().getOwner()).getUserName()); - itemStack.setName(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_NAME", player)); + itemStack.setName(BauSystem.MESSAGE.parse("BAU-INFO_ITEM_NAME", player)); Region region = Region.getRegion(player.getLocation()); List stringList = new ArrayList<>(); for (Flag flag : Flag.getFlags()) { @@ -55,7 +55,7 @@ public class BauInfoBauGuiItem extends BauGuiItem { } Flag.Value value = region.get(flag); if (value != null) { - stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE-" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player))); + stringList.add(BauSystem.MESSAGE.parse("BAU-INFO_ITEM_LORE-" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player))); } } itemStack.setLore(stringList); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java index 3ab684f3..4a2bde6f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java @@ -35,6 +35,6 @@ public class CountingwandCommand extends SWCommand { @Register public void genericCommand(final Player p) { - SWUtils.giveItemToPlayer(p, Countingwand.WAND_ITEM); + SWUtils.giveItemToPlayer(p, Countingwand.getWandItem(p)); } } \ No newline at end of file