Skip to content

Commit 01c3a74

Browse files
committed
Added a water debug command, a new feature & config option to choose what Y-levels to clear blocks, more permissions, and heavily optimized the config updating feature (smaller file!).
1 parent 189c9ac commit 01c3a74

6 files changed

Lines changed: 91 additions & 206 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.biscut.chunkbuster</groupId>
88
<artifactId>ChunkBuster</artifactId>
9-
<version>1.1.7</version>
9+
<version>1.1.8</version>
1010
<name>ChunkBuster</name>
1111

1212
<build>

src/main/java/xyz/biscut/chunkbuster/commands/ChunkBusterCommand.java

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public ChunkBusterCommand(ChunkBuster main) {
2222

2323
@Override
2424
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
25-
if (sender.hasPermission("chunkbuster.admin") || sender.isOp()) {
26-
if (args.length > 0) {
27-
switch (args[0].toLowerCase()) {
28-
case "give":
25+
if (args.length > 0) {
26+
switch (args[0].toLowerCase()) {
27+
case "give":
28+
if (sender.hasPermission("chunkbuster.give") || sender.hasPermission("chunkbuster.admin") || sender.isOp()) {
2929
if (args.length > 1) {
3030
Player p = Bukkit.getPlayerExact(args[1]);
3131
if (p != null) {
@@ -67,15 +67,15 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
6767
}
6868
excessItems = p.getInventory().addItem(item);
6969
for (Object excessItem : excessItems.values()) {
70-
int itemCount = ((ItemStack)excessItem).getAmount();
70+
int itemCount = ((ItemStack) excessItem).getAmount();
7171
while (itemCount > 64) {
7272
((ItemStack) excessItem).setAmount(64);
73-
p.getWorld().dropItemNaturally(p.getLocation(), (ItemStack)excessItem);
73+
p.getWorld().dropItemNaturally(p.getLocation(), (ItemStack) excessItem);
7474
itemCount = itemCount - 64;
7575
}
7676
if (itemCount > 0) {
7777
((ItemStack) excessItem).setAmount(itemCount);
78-
p.getWorld().dropItemNaturally(p.getLocation(), (ItemStack)excessItem);
78+
p.getWorld().dropItemNaturally(p.getLocation(), (ItemStack) excessItem);
7979
}
8080
}
8181
if (!main.getConfigValues().getGiveMessage(p, giveAmount).equals("")) {
@@ -96,25 +96,50 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
9696
} else {
9797
sender.sendMessage(ChatColor.RED + "Please specify a player!");
9898
}
99-
break;
100-
case "reload":
99+
} else {
100+
if (!main.getConfigValues().getNoPermissionMessageCommand().equals("")) {
101+
sender.sendMessage(main.getConfigValues().getNoPermissionMessageCommand());
102+
}
103+
}
104+
break;
105+
case "reload":
106+
if (sender.hasPermission("chunkbuster.reload") || sender.hasPermission("chunkbuster.admin") || sender.isOp()) {
101107
main.reloadConfig();
102108
sender.sendMessage(ChatColor.GREEN + "Successfully reloaded the config. Most values have been instantly updated.");
103-
break;
104-
default:
105-
sender.sendMessage(ChatColor.RED + "Invalid argument!");
106-
}
107-
} else {
108-
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------" + ChatColor.GRAY +"[" + ChatColor.GREEN + ChatColor.BOLD + " ChunkBuster " + ChatColor.GRAY + "]" + ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------");
109-
sender.sendMessage(ChatColor.GREEN + "● /cb give <player> <chunk-area> [amount] " + ChatColor.GRAY + "- Give a player a chunk buster");
110-
sender.sendMessage(ChatColor.GREEN + "● /cb reload " + ChatColor.GRAY + "- Reload the config");
111-
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.ITALIC + "v" + main.getDescription().getVersion() + " by Biscut");
112-
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------------------------------");
109+
} else {
110+
if (!main.getConfigValues().getNoPermissionMessageCommand().equals("")) {
111+
sender.sendMessage(main.getConfigValues().getNoPermissionMessageCommand());
112+
}
113+
}
114+
break;
115+
case "water":
116+
if (sender.hasPermission("chunkbuster.water") || sender.hasPermission("chunkbuster.admin") || sender.isOp()) {
117+
if (sender instanceof Player) {
118+
if (main.getUtils().getWaterChunks().contains(((Player)sender).getLocation().getChunk())) {
119+
main.getUtils().getWaterChunks().remove(((Player)sender).getLocation().getChunk());
120+
sender.sendMessage(ChatColor.GREEN + "Water can now flow normally into this chunk.");
121+
} else {
122+
sender.sendMessage(ChatColor.RED + "This chunk doesn't have water flow disabled!");
123+
}
124+
} else {
125+
sender.sendMessage(ChatColor.RED + "You cannot use this command from here!");
126+
}
127+
} else {
128+
if (!main.getConfigValues().getNoPermissionMessageCommand().equals("")) {
129+
sender.sendMessage(main.getConfigValues().getNoPermissionMessageCommand());
130+
}
131+
}
132+
break;
133+
default:
134+
sender.sendMessage(ChatColor.RED + "Invalid argument!");
113135
}
114136
} else {
115-
if (!main.getConfigValues().getNoPermissionMessageCommand().equals("")) {
116-
sender.sendMessage(main.getConfigValues().getNoPermissionMessageCommand());
117-
}
137+
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------" + ChatColor.GRAY +"[" + ChatColor.GREEN + ChatColor.BOLD + " ChunkBuster " + ChatColor.GRAY + "]" + ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "--------------");
138+
sender.sendMessage(ChatColor.GREEN + "● /cb give <player> <chunk-area> [amount] " + ChatColor.GRAY + "- Give a player a chunk buster");
139+
sender.sendMessage(ChatColor.GREEN + "● /cb reload " + ChatColor.GRAY + "- Reload the config");
140+
sender.sendMessage(ChatColor.GREEN + "● /cb water " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "[DEBUG]" + ChatColor.GRAY + " Allow water to flow normally in your current chunk");
141+
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.ITALIC + "v" + main.getDescription().getVersion() + " by Biscut");
142+
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------------------------------");
118143
}
119144
return false;
120145
}

src/main/java/xyz/biscut/chunkbuster/utils/ConfigValues.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,16 @@ public String getCooldownMessage(int minutes, int seconds) {
366366
public boolean showUpdateMessage() {
367367
return main.getConfig().getBoolean("show-update-messages");
368368
}
369+
370+
public int getMinimumY() {
371+
return main.getConfig().getInt("minimum-y");
372+
}
373+
374+
public int getMaximumY() {
375+
return main.getConfig().getInt("maximum-y");
376+
}
377+
378+
public double getConfigVersion() {
379+
return main.getConfig().getDouble("config-version");
380+
}
369381
}

0 commit comments

Comments
 (0)