Skip to content

Commit

Permalink
Added USE_BUCKET protection type
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed May 24, 2020
1 parent 5cd1ff4 commit 2119dfe
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/redempt/redlib/region/ProtectionPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;

Expand Down Expand Up @@ -185,6 +187,26 @@ public void onInteract(PlayerInteractEvent e) {
}
}

@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent e) {
if (protections.contains(ProtectionType.USE_BUCKETS)
&& protectionCheck.test(e.getBlockClicked())
&& !canBypass(e.getPlayer(), ProtectionType.USE_BUCKETS, e.getBlockClicked())) {
e.setCancelled(true);
sendMessage(e.getPlayer(), ProtectionType.USE_BUCKETS);
}
}

@EventHandler
public void onBucketFill(PlayerBucketFillEvent e) {
if (protections.contains(ProtectionType.USE_BUCKETS)
&& protectionCheck.test(e.getBlockClicked())
&& !canBypass(e.getPlayer(), ProtectionType.USE_BUCKETS, e.getBlockClicked())) {
e.setCancelled(true);
sendMessage(e.getPlayer(), ProtectionType.USE_BUCKETS);
}
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent e) {
if (protections.contains(ProtectionType.ENTITY_EXPLOSION)) {
Expand Down Expand Up @@ -292,6 +314,10 @@ public static enum ProtectionType {
* Players interacting with non-container blocks
*/
INTERACT,
/**
* Players using buckets to place or collect liquids
*/
USE_BUCKETS,
/**
* Players opening containers
*/
Expand Down Expand Up @@ -344,7 +370,7 @@ public static enum ProtectionType {
/**
* All protection types relating to actions taken directly by players - Breaking, placing, and interacting with blocks
*/
public static final ProtectionType[] DIRECT_PLAYERS = {BREAK_BLOCK, PLACE_BLOCK, INTERACT, CONTAINER_ACCESS};
public static final ProtectionType[] DIRECT_PLAYERS = {BREAK_BLOCK, PLACE_BLOCK, INTERACT, CONTAINER_ACCESS, USE_BUCKETS};
/**
* All protection types relating to actions usually taken by players which indirectly affect blocks - Pistons, redstone, explosions, and falling blocks
*/
Expand Down

0 comments on commit 2119dfe

Please sign in to comment.