Skip to content

Commit

Permalink
Stopped water from flowing into busted chunks and added version line …
Browse files Browse the repository at this point in the history
…in config.
  • Loading branch information
biscuut committed Aug 20, 2018
1 parent bf7d4b8 commit 179d896
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/main/java/xyz/biscut/chunkbuster/ChunkBuster.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package xyz.biscut.chunkbuster;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import xyz.biscut.chunkbuster.commands.ChunkBusterCommand;
import xyz.biscut.chunkbuster.events.OtherEvents;
import xyz.biscut.chunkbuster.events.PlayerEvents;
import xyz.biscut.chunkbuster.utils.HookUtils;
import xyz.biscut.chunkbuster.hooks.MCoreFactionsHook;
Expand All @@ -15,14 +17,16 @@
import xyz.biscut.chunkbuster.utils.Utils;

import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;

public class ChunkBuster extends JavaPlugin {

private ConfigValues configValues = new ConfigValues(this);
private Utils utils = new Utils(this);
private HashMap<Player, Location> chunkBusterLocations = new HashMap<>();
private LinkedList<Block> removalQueue = new LinkedList<>();
private HashSet<Chunk> waterChunks = new HashSet<>();
private Utils utils = new Utils(this);
private HookUtils hookUtils;

@Override
Expand All @@ -35,6 +39,7 @@ public void onEnable() {
getConfig().options().copyDefaults(true);
saveDefaultConfig();
Bukkit.getPluginManager().registerEvents(new PlayerEvents(this), this);
Bukkit.getPluginManager().registerEvents(new OtherEvents(this), this);
getCommand("chunkbuster").setExecutor(new ChunkBusterCommand(this));
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new RemovalQueue(this), 1L, 1L);
}
Expand All @@ -48,4 +53,6 @@ public void onEnable() {
public HashMap<Player, Location> getChunkBusterLocations() { return chunkBusterLocations; }

public LinkedList<Block> getRemovalQueue() { return removalQueue; }

public HashSet<Chunk> getWaterChunks() { return waterChunks; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
sender.sendMessage(ChatColor.RED + "The area must be 1, 3, or 5.");
}
} else {
sender.sendMessage(ChatColor.RED + "Please specify a chunk radius!");
sender.sendMessage(ChatColor.RED + "Please specify a chunk area!");
}
} else {
sender.sendMessage(ChatColor.RED + "This player is not online!");
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/xyz/biscut/chunkbuster/events/OtherEvents.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package xyz.biscut.chunkbuster.events;

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import xyz.biscut.chunkbuster.ChunkBuster;

public class OtherEvents implements Listener {

private ChunkBuster main;

public OtherEvents(ChunkBuster main) {
this.main = main;
}

@EventHandler
public void onWaterFlow(BlockFromToEvent e) {
if (e.getBlock().getType().equals(Material.WATER) || e.getBlock().getType().equals(Material.STATIONARY_WATER)
|| e.getBlock().getType().equals(Material.LAVA) || e.getBlock().getType().equals(Material.STATIONARY_LAVA)) {
if (main.getWaterChunks().contains(e.getToBlock().getChunk())) {
e.setCancelled(true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ public void onConfirmClick(InventoryClickEvent e) {
if (main.getConfigValues().getChunkBusterWarmup() > 0) {
int seconds = main.getConfigValues().getChunkBusterWarmup();
new MessageTimer(seconds, p, main).runTaskTimer(main, 0L, 20L);
Bukkit.getScheduler().runTaskLater(main, () -> main.getUtils().clearChunks(chunkBusterDiameter, chunkBusterLocation, p), 20L * seconds);
Bukkit.getScheduler().runTaskLater(main, () -> {
main.getWaterChunks().add(chunkBusterLocation.getChunk());
main.getUtils().clearChunks(chunkBusterDiameter, chunkBusterLocation, p);
}, 20L * seconds);
} else {
main.getWaterChunks().add(chunkBusterLocation.getChunk());
main.getUtils().clearChunks(chunkBusterDiameter, chunkBusterLocation, p);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# | \__/\| | | || |_| || | | || < | |_/ /| |_| |\__ \| |_| __/| | #
# \____/|_| |_| \__,_||_| |_||_|\_\\____/ \__,_||___/ \__|\___||_| #
# #
# v1.0 by Biscut #
# v1.0.1 by Biscut #
#########################################################################

chunkbuster:
Expand Down Expand Up @@ -55,3 +55,6 @@ messages:
clearing-chunks: '&aChunk(s) added to queue, clearing!'
#This will only show if "chunkbuster-activation-delay" is above 0
clearing-in-seconds: '&aChunk(s) will clear in {seconds} second(s).'

# Please do not edit :)
config-version: 1.0

0 comments on commit 179d896

Please sign in to comment.