mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-01 06:23:22 +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.
35 lines
968 B
Java
35 lines
968 B
Java
package com.Acrobot.ChestShop.Plugins;
|
|
|
|
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
|
import com.Acrobot.ChestShop.Utils.uName;
|
|
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 Lockette implements Listener {
|
|
@EventHandler
|
|
public static void onProtectionCheck(ProtectionCheckEvent event) {
|
|
if (event.getResult() == Event.Result.DENY) {
|
|
return;
|
|
}
|
|
|
|
Player player = event.getPlayer();
|
|
Block block = event.getBlock();
|
|
|
|
if (!org.yi.acru.bukkit.Lockette.Lockette.isProtected(block)) {
|
|
return;
|
|
}
|
|
|
|
String shortPlayerName = uName.shortenName(player);
|
|
|
|
if (!org.yi.acru.bukkit.Lockette.Lockette.isUser(block, shortPlayerName, true)) {
|
|
event.setResult(Event.Result.DENY);
|
|
}
|
|
}
|
|
}
|