Skip to content

Commit

Permalink
prevent entities (i.e villages) from opening protections (i.e doors) --
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidendra committed Jun 23, 2012
1 parent d5a5970 commit 7613fd4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ protections:
# If entities - such as zombies - are allowed to break down doors
allowEntityBreakDoor: false

# If entities - such as villages - should be allowed to interact with protections (i.e doors)
allowEntityInteract: false

# Creation messages and protection notices will not be shown for this protection
quiet: false

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/griefcraft/listeners/LWCEntityListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.plugin.Plugin;

import java.lang.Boolean;

public class LWCEntityListener implements Listener {

/**
Expand All @@ -56,6 +58,21 @@ public LWCEntityListener(LWCPlugin plugin) {
this.plugin = plugin;
}

@EventHandler
public void entityInteract(EntityInteractEvent event) {
Block block = event.getBlock();

Protection protection = plugin.getLWC().findProtection(block);

if (protection != null) {
boolean allowEntityInteract = Boolean.parseBoolean(plugin.getLWC().resolveProtectionConfiguration(block.getType(), "allowEntityInteract"));

if (!allowEntityInteract) {
event.setCancelled(true);
}
}
}

@EventHandler
public void entityBreakDoor(EntityBreakDoorEvent event) {
Block block = event.getBlock();
Expand Down

0 comments on commit 7613fd4

Please sign in to comment.