mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 15:17:36 +01:00
Fixed some chest protection issues.
This commit is contained in:
parent
b23e35cf26
commit
97bde50708
@ -56,23 +56,23 @@ private boolean isProtectedSignAround(Block searchBlock, Player player) {
|
||||
|
||||
side = searchBlock;
|
||||
res = isProtectedSign(side, player);
|
||||
if (res != null) return res;
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(-1, 0, 0);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null) return res;
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(1, 0, 0);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null) return res;
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, -1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null) return res;
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, 1);
|
||||
res = isProtectedSignAndChest(side, player);
|
||||
if (res != null) return res;
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -120,10 +120,37 @@ private boolean isProtectedSignAndChestBinary(Block block, Player player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isChest(Material material) {
|
||||
public boolean isChest(Material material) {
|
||||
return material == Material.CHEST
|
||||
|| material == Material.DISPENSER
|
||||
|| material == Material.FURNACE
|
||||
|| material == Material.BURNING_FURNACE;
|
||||
}
|
||||
|
||||
public boolean isAdjacentChestProtected(Block searchBlock, Player player) {
|
||||
Block side;
|
||||
Boolean res;
|
||||
|
||||
side = searchBlock;
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(-1, 0, 0);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(1, 0, 0);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, -1);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
side = searchBlock.getRelative(0, 0, 1);
|
||||
res = isProtected(side, player);
|
||||
if (res != null && res == true) return res;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -357,4 +357,18 @@ public boolean isChestProtectedPlacement(Block block, Player player) {
|
||||
return chestProtection.isProtectedPlacement(block, player);
|
||||
}
|
||||
|
||||
public boolean isAdjacentChestProtected(Block block, Player player) {
|
||||
if (!signChestProtection) {
|
||||
return false;
|
||||
}
|
||||
if (plugin.hasPermission(player, "worldguard.chest-protection.override")) {
|
||||
return false;
|
||||
}
|
||||
return chestProtection.isAdjacentChestProtected(block, player);
|
||||
}
|
||||
|
||||
public SignChestProtection getChestProtection() {
|
||||
return chestProtection;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -449,6 +449,14 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.signChestProtection && wcfg.getChestProtection().isChest(blockPlaced.getType())) {
|
||||
if (wcfg.isAdjacentChestProtected(event.getBlock(), player)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.simulateSponge && blockPlaced.getTypeId() == 19) {
|
||||
if (wcfg.redstoneSponges && blockPlaced.isBlockIndirectlyPowered()) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user