mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 04:25:14 +01:00
uBlock now contains the chest neighbor methods
This commit is contained in:
parent
b8d8cdb398
commit
1fdc32e230
@ -15,6 +15,31 @@ import org.bukkit.material.Attachable;
|
||||
public class uBlock {
|
||||
private static final BlockFace[] CHEST_EXTENSION_FACES = {BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
private static final BlockFace[] SHOP_FACES = {BlockFace.SELF, BlockFace.DOWN, BlockFace.UP, BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
private static final BlockFace[] NEIGHBOR_FACES = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
|
||||
public static Sign getConnectedSign(Chest chest) {
|
||||
Sign sign = uBlock.findAnyNearbyShopSign(chest.getBlock());
|
||||
|
||||
if (sign == null && getNeighbor(chest) != null) {
|
||||
sign = uBlock.findAnyNearbyShopSign(getNeighbor(chest).getBlock());
|
||||
}
|
||||
|
||||
return sign;
|
||||
}
|
||||
|
||||
private static Chest getNeighbor(Chest chest) {
|
||||
Block chestBlock = chest.getBlock();
|
||||
|
||||
for (BlockFace chestFace : NEIGHBOR_FACES) {
|
||||
Block relative = chestBlock.getRelative(chestFace);
|
||||
|
||||
if (relative.getState() instanceof Chest) {
|
||||
return (Chest) relative.getState();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Chest findConnectedChest(Sign sign) {
|
||||
Block block = sign.getBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user