mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-20 15:27:34 +01:00
5908eb67fa
- 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.
67 lines
1.3 KiB
Java
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;
|
|
}
|
|
}
|