Skip to content

Commit

Permalink
block place check now only does its thing if its a chest
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccoystephenson committed Jul 9, 2020
1 parent fbd84cb commit 6e07b98
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void handle(BlockPlaceEvent event) {
// if next to non-owned locked block
if (isNextToNonOwnedLockedBlock(event.getPlayer(), event.getBlock())) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You can't place chests/doors next to blocks you don't own.");
player.sendMessage(ChatColor.RED + "You can't place chests next to locked chests you don't own.");
return;
}
}
Expand All @@ -65,18 +65,30 @@ private boolean isNextToNonOwnedLockedBlock(Player player, Block block) {
Block neighbor3 = block.getWorld().getBlockAt(block.getX(), block.getY(), block.getZ() + 1);
Block neighbor4 = block.getWorld().getBlockAt(block.getX(), block.getY(), block.getZ() - 1);

if (main.isBlockLocked(neighbor1) && !main.getLockedBlock(neighbor1).getOwner().equalsIgnoreCase(player.getName())) {
return true;
if (main.isChest(neighbor1)) {
if (main.isBlockLocked(neighbor1) && !main.getLockedBlock(neighbor1).getOwner().equalsIgnoreCase(player.getName())) {
return true;
}
}
if (main.isBlockLocked(neighbor2) && !main.getLockedBlock(neighbor2).getOwner().equalsIgnoreCase(player.getName())) {
return true;

if (main.isChest(neighbor1)) {
if (main.isBlockLocked(neighbor2) && !main.getLockedBlock(neighbor2).getOwner().equalsIgnoreCase(player.getName())) {
return true;
}
}
if (main.isBlockLocked(neighbor3) && !main.getLockedBlock(neighbor3).getOwner().equalsIgnoreCase(player.getName())) {
return true;

if (main.isChest(neighbor1)) {
if (main.isBlockLocked(neighbor3) && !main.getLockedBlock(neighbor3).getOwner().equalsIgnoreCase(player.getName())) {
return true;
}
}
if (main.isBlockLocked(neighbor4) && !main.getLockedBlock(neighbor4).getOwner().equalsIgnoreCase(player.getName())) {
return true;

if (main.isChest(neighbor1)) {
if (main.isBlockLocked(neighbor4) && !main.getLockedBlock(neighbor4).getOwner().equalsIgnoreCase(player.getName())) {
return true;
}
}

return false;
}
}

0 comments on commit 6e07b98

Please sign in to comment.