mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-09 04:03:09 +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
67 lines
2.1 KiB
Java
67 lines
2.1 KiB
Java
package com.Acrobot.ChestShop.Utils;
|
|
|
|
import com.Acrobot.ChestShop.Signs.restrictedSign;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.block.BlockFace;
|
|
import org.bukkit.block.Chest;
|
|
import org.bukkit.block.Sign;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class uBlock {
|
|
|
|
private static final BlockFace[] chestFaces = {BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
|
private static final BlockFace[] shopFaces = {BlockFace.DOWN, BlockFace.UP, BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.SELF};
|
|
|
|
public static Chest findChest(Sign sign) {
|
|
Block block = sign.getBlock();
|
|
return findChest(block);
|
|
}
|
|
|
|
public static Chest findChest(Block block) {
|
|
for (BlockFace bf : shopFaces) {
|
|
Block faceBlock = block.getRelative(bf);
|
|
if (faceBlock.getType() == Material.CHEST) return (Chest) faceBlock.getState();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Sign findSign(Block block) {
|
|
for (BlockFace bf : shopFaces) {
|
|
Block faceBlock = block.getRelative(bf);
|
|
if (uSign.isSign(faceBlock)) {
|
|
Sign sign = (Sign) faceBlock.getState();
|
|
if (uSign.isValid(sign)) return sign;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Sign findRestrictedSign(Block block) {
|
|
for (BlockFace bf : shopFaces) {
|
|
Block faceBlock = block.getRelative(bf);
|
|
if (uSign.isSign(faceBlock)) {
|
|
Sign sign = (Sign) faceBlock.getState();
|
|
if (restrictedSign.isRestricted(sign)) return sign;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Chest findNeighbor(Block block) {
|
|
for (BlockFace blockFace : chestFaces) {
|
|
Block neighborBlock = block.getRelative(blockFace);
|
|
if (neighborBlock.getType() == Material.CHEST) {
|
|
return (Chest) neighborBlock.getState();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Chest findNeighbor(Chest chest) {
|
|
return findNeighbor(chest.getBlock());
|
|
}
|
|
}
|