From 35e82cddc606a9747db2c543c75d102c8675212d Mon Sep 17 00:00:00 2001 From: Gecko! Date: Thu, 14 Dec 2023 16:09:01 +0100 Subject: [PATCH 1/3] Fix BedrockListener.java, fix formatting in ConfigGUI.java --- pom.xml | 2 +- .../java/org/gecko/wauh/gui/ConfigGUI.java | 52 ++++++++++--------- .../gecko/wauh/listeners/BedrockListener.java | 5 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index bafcc82..ca1d200 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.gecko Wauh - 5.5.0 + 5.5.1 jar wauh diff --git a/src/main/java/org/gecko/wauh/gui/ConfigGUI.java b/src/main/java/org/gecko/wauh/gui/ConfigGUI.java index fdb4d73..d7e3cee 100644 --- a/src/main/java/org/gecko/wauh/gui/ConfigGUI.java +++ b/src/main/java/org/gecko/wauh/gui/ConfigGUI.java @@ -49,39 +49,39 @@ public ConfigGUI(Main plugin) { private void initializeGUI() { if (config.getInt("Bucket enabled") == 1) { - gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Bucket")); + gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Bucket")); } else { - gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Bucket")); + gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Bucket")); } if (config.getInt("Barrier enabled") == 1) { - gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Barrier")); + gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Barrier")); } else { - gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Barrier")); + gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Barrier")); } if (config.getInt("Bedrock enabled") == 1) { - gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Bedrock")); + gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Bedrock")); } else { - gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Bedrock")); + gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Bedrock")); } if (config.getInt("Tsunami enabled") == 1) { - gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Tsunami")); + gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Tsunami")); } else { - gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Tsunami")); + gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Tsunami")); } if (config.getInt("Creeper enabled") == 1) { - gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Creeper")); + gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Creeper")); } else { - gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Creeper")); + gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Creeper")); } if (config.getInt("TNT enabled") == 1) { - gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable TNT")); + gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable TNT")); } else { - gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable TNT")); + gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable TNT")); } gui.setItem(9 * 4 + 8, createButtonItem(Material.PAPER, ChatColor.RESET + "" + ChatColor.RED + "Reset config", (short) 0, null, "Reset")); @@ -114,10 +114,14 @@ private void fillBorders(ItemStack borderItem) { private ItemStack createButtonItem(Material material, String name, short data, String lore, String ident) { List loreToString; if (lore != null) { + lore = ChatColor.RESET + lore; loreToString = Collections.singletonList(lore); } else { loreToString = null; } + if (name != null) { + name = ChatColor.RESET + name; + } ItemStack item = new ItemStack(material, 1, data); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(name); @@ -168,13 +172,13 @@ public void onInventoryClick(InventoryClickEvent event) { if (identifier.equalsIgnoreCase("Enable Bucket") && data == 8) { config.set("Bucket enabled", 1); configManager.saveConfig(); - gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Bucket")); + gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Bucket")); player.sendMessage("Liquid removal enabled!"); return; } else if (identifier.equalsIgnoreCase("Enable Bucket") && data == 10) { config.set("Bucket enabled", 0); configManager.saveConfig(); - gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Bucket")); + gui.setItem(9 * 3 + 1, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Bucket")); player.sendMessage("Liquid removal disabled!"); return; } @@ -182,13 +186,13 @@ public void onInventoryClick(InventoryClickEvent event) { if (identifier.equalsIgnoreCase("Enable Barrier") && data == 8) { config.set("Barrier enabled", 1); configManager.saveConfig(); - gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Barrier")); + gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Barrier")); player.sendMessage("Surface removal enabled!"); return; } else if (identifier.equalsIgnoreCase("Enable Barrier") && data == 10) { config.set("Barrier enabled", 0); configManager.saveConfig(); - gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Barrier")); + gui.setItem(9 * 3 + 2, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Barrier")); player.sendMessage("Surface removal disabled!"); return; } @@ -196,13 +200,13 @@ public void onInventoryClick(InventoryClickEvent event) { if (identifier.equalsIgnoreCase("Enable Bedrock") && data == 8) { config.set("Bedrock enabled", 1); configManager.saveConfig(); - gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Bedrock")); + gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Bedrock")); player.sendMessage("All block removal enabled!"); return; } else if (identifier.equalsIgnoreCase("Enable Bedrock") && data == 10) { config.set("Bedrock enabled", 0); configManager.saveConfig(); - gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Bedrock")); + gui.setItem(9 * 3 + 3, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Bedrock")); player.sendMessage("All block removal disabled!"); return; } @@ -210,13 +214,13 @@ public void onInventoryClick(InventoryClickEvent event) { if (identifier.equalsIgnoreCase("Enable Tsunami") && data == 8) { config.set("Tsunami enabled", 1); configManager.saveConfig(); - gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Tsunami")); + gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Tsunami")); player.sendMessage("Tsunami enabled!"); return; } else if (identifier.equalsIgnoreCase("Enable Tsunami") && data == 10) { config.set("Tsunami enabled", 0); configManager.saveConfig(); - gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Tsunami")); + gui.setItem(9 * 3 + 4, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Tsunami")); player.sendMessage("Tsunami disabled!"); return; } @@ -224,13 +228,13 @@ public void onInventoryClick(InventoryClickEvent event) { if (identifier.equalsIgnoreCase("Enable Creeper") && data == 8) { config.set("Creeper enabled", 1); configManager.saveConfig(); - gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable Creeper")); + gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable Creeper")); player.sendMessage("Custom creeper explosions enabled!"); return; } else if (identifier.equalsIgnoreCase("Enable Creeper") && data == 10) { config.set("Creeper enabled", 0); configManager.saveConfig(); - gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable Creeper")); + gui.setItem(9 * 3 + 5, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable Creeper")); player.sendMessage("Custom creeper explosions disabled!"); return; } @@ -238,13 +242,13 @@ public void onInventoryClick(InventoryClickEvent event) { if (identifier.equalsIgnoreCase("Enable TNT") && data == 8) { config.set("TNT enabled", 1); configManager.saveConfig(); - gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "§rDisable", (short) 10, null, "Enable TNT")); + gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "Disable", (short) 10, null, "Enable TNT")); player.sendMessage("Custom TNT explosions enabled!"); return; } else if (identifier.equalsIgnoreCase("Enable TNT") && data == 10) { config.set("TNT enabled", 0); configManager.saveConfig(); - gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "§rEnable", (short) 8, null, "Enable TNT")); + gui.setItem(9 * 3 + 6, createButtonItem(Material.INK_SACK, "Enable", (short) 8, null, "Enable TNT")); player.sendMessage("Custom TNT explosions disabled!"); return; } diff --git a/src/main/java/org/gecko/wauh/listeners/BedrockListener.java b/src/main/java/org/gecko/wauh/listeners/BedrockListener.java index 7132959..28e9704 100644 --- a/src/main/java/org/gecko/wauh/listeners/BedrockListener.java +++ b/src/main/java/org/gecko/wauh/listeners/BedrockListener.java @@ -44,7 +44,7 @@ public class BedrockListener implements Listener { private int repetitions = 3; private boolean repeated = false; private boolean explosionTrigger = false; - private String realSource; + private String realSource = null; private final java.util.logging.Logger logger = Logger.getLogger(Main.class.getName()); private void addIfValid(Block block, Set nextSet) { @@ -58,8 +58,7 @@ private void addIfValid(Block block, Set nextSet) { tntPrimed.setFuseTicks(20); nextSet.add(block); } - } - if (!IMMUTABLE_MATERIALS.contains(block.getType()) || block.getType() == Material.AIR) { + } else if (!IMMUTABLE_MATERIALS.contains(block.getType()) && !(block.getType() == Material.AIR)) { nextSet.add(block); } else if (block.getType() == Material.TNT) { Location location = block.getLocation(); From 7b060335c653fd69707c2c90f73a57cd5dd20fe9 Mon Sep 17 00:00:00 2001 From: Gecko! Date: Thu, 14 Dec 2023 16:15:41 +0100 Subject: [PATCH 2/3] test --- src/main/java/org/gecko/wauh/listeners/BedrockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gecko/wauh/listeners/BedrockListener.java b/src/main/java/org/gecko/wauh/listeners/BedrockListener.java index 28e9704..29fdb16 100644 --- a/src/main/java/org/gecko/wauh/listeners/BedrockListener.java +++ b/src/main/java/org/gecko/wauh/listeners/BedrockListener.java @@ -25,7 +25,7 @@ public class BedrockListener implements Listener { - private static final Set IMMUTABLE_MATERIALS = EnumSet.of(Material.BEDROCK, Material.STATIONARY_WATER, Material.WATER, Material.LAVA, Material.STATIONARY_LAVA, Material.TNT); + private static final Set IMMUTABLE_MATERIALS = EnumSet.of(Material.BEDROCK, Material.STATIONARY_WATER, Material.WATER, Material.LAVA, Material.STATIONARY_LAVA); private final Set markedBlocks = new HashSet<>(); private final Set processedBlocks = new HashSet<>(); private final Set removedBlocks = new HashSet<>(); From 24fb61d23f36578cbe8b746fb1efa386a745a276 Mon Sep 17 00:00:00 2001 From: Gecko! Date: Thu, 14 Dec 2023 16:16:19 +0100 Subject: [PATCH 3/3] revert: test --- src/main/java/org/gecko/wauh/listeners/BedrockListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gecko/wauh/listeners/BedrockListener.java b/src/main/java/org/gecko/wauh/listeners/BedrockListener.java index 29fdb16..28e9704 100644 --- a/src/main/java/org/gecko/wauh/listeners/BedrockListener.java +++ b/src/main/java/org/gecko/wauh/listeners/BedrockListener.java @@ -25,7 +25,7 @@ public class BedrockListener implements Listener { - private static final Set IMMUTABLE_MATERIALS = EnumSet.of(Material.BEDROCK, Material.STATIONARY_WATER, Material.WATER, Material.LAVA, Material.STATIONARY_LAVA); + private static final Set IMMUTABLE_MATERIALS = EnumSet.of(Material.BEDROCK, Material.STATIONARY_WATER, Material.WATER, Material.LAVA, Material.STATIONARY_LAVA, Material.TNT); private final Set markedBlocks = new HashSet<>(); private final Set processedBlocks = new HashSet<>(); private final Set removedBlocks = new HashSet<>();