mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-21 14:21:19 +01:00
c64627205e
- Speeded it up - Added Buy/Sell specified ID permission - Removed EXCLUDE_ITEM permission - just use normal Permission negating - Doesn't add more LWC's on an already protected block - Updated Register - Added option to turn off messages
38 lines
1.2 KiB
Java
38 lines
1.2 KiB
Java
package com.Acrobot.ChestShop.Protection;
|
|
|
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
|
import com.Acrobot.ChestShop.Utils.uLongName;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.block.Chest;
|
|
import org.bukkit.block.Sign;
|
|
import org.bukkit.entity.Player;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class Default implements Protection {
|
|
public boolean isProtected(Block block) {
|
|
if (!(block.getState() instanceof Chest)) return false;
|
|
if (uBlock.findSign(block) != null) return true;
|
|
|
|
Chest neighbor = uBlock.findNeighbor(block);
|
|
return neighbor != null && uBlock.findSign(neighbor.getBlock()) != null;
|
|
}
|
|
|
|
public boolean canAccess(Player player, Block block) {
|
|
String playerName = player.getName();
|
|
|
|
Sign sign = uBlock.findSign(block);
|
|
if(sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0));
|
|
|
|
Chest neighborChest = uBlock.findNeighbor(block);
|
|
Sign neighborSign = (neighborChest != null ? uBlock.findSign(neighborChest.getBlock()) : null);
|
|
|
|
return neighborSign != null && uLongName.stripName(playerName).equals(neighborSign.getLine(0));
|
|
}
|
|
|
|
public boolean protect(String name, Block block) {
|
|
return false;
|
|
}
|
|
}
|