From 312381d47c21ae4696fedf9b75752bbb44fd2c0e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 25 Jul 2023 17:16:09 +0200 Subject: [PATCH] Fix changes --- .../bausystem/configplayer/Config.java | 26 +++++++++++++------ .../features/detonator/Detonator.java | 2 +- .../features/detonator/DetonatorCommand.java | 4 +-- .../InventoryFillBauGuiItem.java | 2 +- .../inventoryfiller/InventoryFiller.java | 4 +-- .../InventoryFillerCommand.java | 4 +-- .../simulator/gui/TNTSimulatorGui.java | 4 +-- .../smartplace/SmartPlaceCommand.java | 4 +-- .../smartplace/SmartPlaceListener.java | 4 +-- .../testblock/blockcounter/BlockCounter.java | 9 +++---- 10 files changed, 35 insertions(+), 28 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java index 5983ed21..f2be052c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.configplayer; import de.steamwar.bausystem.config.ConfigField; import de.steamwar.bausystem.config.YamlConfig; -import de.steamwar.bausystem.features.testblock.depthcounter.CountMode; import de.steamwar.linkage.Linked; import de.steamwar.sql.UserConfig; import lombok.Getter; @@ -33,10 +32,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.stream.Collectors; public class Config extends YamlConfig { @@ -61,11 +58,27 @@ public class Config extends YamlConfig { @Getter @Setter @ConfigField - private List depthCounter; + private boolean simulatorAutoTrace; @Getter + @Setter @ConfigField - private boolean simulatorAutoTrace; + private boolean detonatorAutostart; + + @Getter + @Setter + @ConfigField + private boolean blockCounter; + + @Getter + @Setter + @ConfigField + private boolean smartPlace; + + @Getter + @Setter + @ConfigField + private boolean inventoryFill; @Getter @ConfigField @@ -75,9 +88,6 @@ public class Config extends YamlConfig { super(configuration); this.uuid = uuid; - if(depthCounter == null) - depthCounter = CountMode.ALL().stream().map(CountMode::name).collect(Collectors.toList()); - if(baugui.isEmpty()) { // 0: ? | 1: ? | 2: 10 | 3: 3 | 4: 7 | 5: 17 | 6: 15 | 7: ? | 8: ? // 9: 5 | 10: ? | 11: ? | 12: ? | 13: ? | 14: ? | 15: ? | 16: ? | 17: 16 diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java index 80d5b33b..599581c7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java @@ -79,7 +79,7 @@ public class Detonator { public static void activateDetonator(DetonatorStorage detonator) { Player p = detonator.getPlayer(); - if (Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false)) { + if (Config.get(p).isDetonatorAutostart()) { AutostartListener.instance.activate(p); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java index bb71245d..79bf0aef 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java @@ -76,8 +76,8 @@ public class DetonatorCommand extends SWCommand { @Register(value = "autostart", description = "DETONATOR_HELP_AUTOSTART") public void toggleAutostartTimer(Player p) { - boolean current = Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false); - Config.getInstance().get(p).put("detonator-autostart", !current); + boolean current = Config.get(p).isDetonatorAutostart(); + Config.get(p).setDetonatorAutostart(!current); if (!current) { BauSystem.MESSAGE.send("DETONATOR_AUTOSTART_ENABLE", p); } else { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java index 7e94710a..e0b33550 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java @@ -30,7 +30,7 @@ public class InventoryFillBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - String loreKey = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false) ? "OTHER_ITEMS_INVENTORY_FILL_LORE_ACTIVE" : "OTHER_ITEMS_INVENTORY_FILL_LORE_INACTIVE"; + String loreKey = Config.get(player).isInventoryFill() ? "OTHER_ITEMS_INVENTORY_FILL_LORE_ACTIVE" : "OTHER_ITEMS_INVENTORY_FILL_LORE_INACTIVE"; return new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("OTHER_ITEMS_INVENTORY_FILL_NAME", player), Collections.singletonList(BauSystem.MESSAGE.parse(loreKey, player)), false, clickType -> {}).getItemStack(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java index f72d08f2..27902cee 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java @@ -38,7 +38,7 @@ public class InventoryFiller implements Listener { @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { - if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; + if (!Config.get(event.getPlayer()).isInventoryFill()) return; if (!event.getPlayer().isSneaking()) return; Block block = event.getPlayer().getTargetBlockExact(5); if (block == null) return; @@ -59,7 +59,7 @@ public class InventoryFiller implements Listener { */ @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { - if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; + if (!Config.get(event.getPlayer()).isInventoryFill()) return; if (!event.getPlayer().isSneaking()) return; ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand(); if (itemStack.getType() == Material.AIR) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java index 4804a9d7..965a92e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java @@ -16,8 +16,8 @@ public class InventoryFillerCommand extends SWCommand { @Register(description = {"INVENTORY_FILL_HELP", "INVENTORY_FILL_INFO"}) public void toggle(Player player) { - boolean inventoryFill = Config.getInstance().get(player).getPlainValueOrDefault("inventoryfill", false); - Config.getInstance().get(player).put("inventoryfill", !inventoryFill); + boolean inventoryFill = Config.get(player).isInventoryFill(); + Config.get(player).setInventoryFill(!inventoryFill); if (!inventoryFill) { SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player)); BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java index e813580a..89122193 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java @@ -119,9 +119,9 @@ public class TNTSimulatorGui { })); } - boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false); + boolean simulatorAutoTrace = Config.get(player).isSimulatorAutoTrace(); inv.setItem(47, new SWItem(simulatorAutoTrace ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, BauSystem.MESSAGE.parse("SIMULATOR_GUI_AUTO_TRACE", player, simulatorAutoTrace), clickType -> { - Config.getInstance().get(player).put("simulatorAutoTrace", !simulatorAutoTrace); + Config.get(player).setSimulatorAutoTrace(!simulatorAutoTrace); open(player, currentTntSimulator, currentTntGroup, simulatorElements, back); })); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java index 526e59e6..7a4d2e56 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java @@ -35,8 +35,8 @@ public class SmartPlaceCommand extends SWCommand { @Register(description = {"SMART_PLACE_HELP", "SMART_PLACE_INFO"}) public void genericToggle(Player p) { - boolean smartPlace = Config.getInstance().get(p).getPlainValueOrDefault("smartPlace", false); - Config.getInstance().get(p).put("smartPlace", !smartPlace); + boolean smartPlace = Config.get(p).isSmartPlace(); + Config.get(p).setSmartPlace(!smartPlace); if (!smartPlace) { SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("SMART_PLACE_ENABLE", p)); BauSystem.MESSAGE.send("SMART_PLACE_INFO", p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index a5ac0456..fc8339a7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -46,7 +46,7 @@ public class SmartPlaceListener implements Listener { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { - if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; + if (!Config.get(event.getPlayer()).isSmartPlace()) return; if (smartPlaceBehaviours.isEmpty()) LinkageUtils.linkSmartPlace(); SmartPlaceBehaviour.SmartPlaceResult smartPlaceResult = SmartPlaceBehaviour.SmartPlaceResult.IGNORED; for (SmartPlaceBehaviour smartPlaceBehaviour : smartPlaceBehaviours) { @@ -61,7 +61,7 @@ public class SmartPlaceListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; + if (!Config.get(event.getPlayer()).isSmartPlace()) return; if (smartPlaceBehaviours.isEmpty()) LinkageUtils.linkSmartPlace(); if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java index cf34f6f1..9875367c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java @@ -34,18 +34,15 @@ public class BlockCounter { public final Map blockCountMap = new HashMap<>(); public boolean isActive(final Player p) { - if (!Config.getInstance().get(p).containsKey("blockCounter")) { - return false; - } - return Config.getInstance().get(p).getPlainValue("blockCounter"); + return Config.get(p).isBlockCounter(); } public void enable(final Player p) { - Config.getInstance().get(p).put("blockCounter", true); + Config.get(p).setBlockCounter(true); } public void disable(final Player p) { - Config.getInstance().get(p).put("blockCounter", false); + Config.get(p).setBlockCounter(false); } public String getMessage(Player player, int count, int tntCount, long tick, long lastTick) {