ChestShop-3/com/Acrobot/ChestShop/Events/Protection/BuildPermissionEvent.java
Acrobot 5908eb67fa - Added API (let's start with simple things first)
- Copied utilities from ChestShop-4
- Made code really, really nicer to read
- Made every external plugin's wrapper a listener, so it listens to events instead of being hard-coded.
2012-06-08 15:28:36 +02:00

67 lines
1.3 KiB
Java

package com.Acrobot.ChestShop.Events.Protection;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* @author Acrobot
*/
public class BuildPermissionEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player;
private Location chest, sign;
private int disallowed = 0;
private int received = 0;
public BuildPermissionEvent(Player player, Location chest, Location sign) {
this.player = player;
this.chest = chest;
this.sign = sign;
}
public Player getPlayer() {
return player;
}
public Location getChest() {
return chest;
}
public Location getSign() {
return sign;
}
public void allow() {
received++;
}
public boolean isAllowed() {
return disallowed != received || received == 0;
}
public void allow(boolean yesOrNot) {
if (yesOrNot) {
allow();
} else {
disallow();
}
}
public void disallow() {
received++;
disallowed++;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}