ChestShop-3/com/Acrobot/ChestShop/Plugins/SimpleChestLock.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

41 lines
996 B
Java

package com.Acrobot.ChestShop.Plugins;
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
import com.webkonsept.bukkit.simplechestlock.SCL;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Acrobot
*/
public class SimpleChestLock implements Listener {
private SCL scl;
public SimpleChestLock(SCL scl) {
this.scl = scl;
}
@EventHandler
public void onProtectionCheck(ProtectionCheckEvent event) {
if (event.getResult() == Event.Result.DENY) {
return;
}
Block block = event.getBlock();
Player player = event.getPlayer();
if (!scl.chests.isLocked(block)) {
return;
}
String playerName = player.getName();
if (!scl.chests.getOwner(block).equals(playerName)) {
event.setResult(Event.Result.DENY);
}
}
}