Skip to content

Commit

Permalink
Merge pull request #35 from SmartGecko44/bedrock-fix
Browse files Browse the repository at this point in the history
Fix BedrockListener.java, fix formatting in ConfigGUI.java
  • Loading branch information
SmartGecko44 authored Dec 14, 2023
2 parents 5743866 + 24fb61d commit 2ae4139
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.gecko</groupId>
<artifactId>Wauh</artifactId>
<version>5.5.0</version>
<version>5.5.1</version>
<packaging>jar</packaging>

<name>wauh</name>
Expand Down
52 changes: 28 additions & 24 deletions src/main/java/org/gecko/wauh/gui/ConfigGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -114,10 +114,14 @@ private void fillBorders(ItemStack borderItem) {
private ItemStack createButtonItem(Material material, String name, short data, String lore, String ident) {
List<String> 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);
Expand Down Expand Up @@ -168,83 +172,83 @@ 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;
}

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;
}

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;
}

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;
}

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;
}

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;
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/gecko/wauh/listeners/BedrockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block> nextSet) {
Expand All @@ -58,8 +58,7 @@ private void addIfValid(Block block, Set<Block> 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();
Expand Down

0 comments on commit 2ae4139

Please sign in to comment.