Skip to content

Commit

Permalink
Workaround for CraftBukkit bug with slab placement
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Jan 15, 2013
1 parent 833795e commit 3e06000
Showing 1 changed file with 22 additions and 1 deletion.
Expand Up @@ -689,8 +689,8 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
return;
}

Block placedOn = block.getRelative(event.getBlockFace());
if (item.getTypeId() == BlockID.TNT) {
Block placedOn = block.getRelative(event.getBlockFace());
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !plugin.getGlobalRegionManager().allows(
DefaultFlag.TNT, placedOn.getLocation(), localPlayer)) {
Expand All @@ -699,6 +699,27 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
}
}

// hacky workaround for craftbukkit bug
if (item.getTypeId() == BlockID.STEP
|| item.getTypeId() == BlockID.WOODEN_STEP) {
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)) {
boolean cancel = false;
if ((block.getTypeId() == item.getTypeId())
&& !plugin.getGlobalRegionManager().canBuild(player, block.getLocation())) {
// if we are on a step already, the new block will end up in the same block as the interact
cancel = true;
} else if (!plugin.getGlobalRegionManager().canBuild(player, placedOn.getLocation())) {
// if we are on another block, the half-slab in hand will be pushed to the adjacent block
cancel = true;
}
if (cancel) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true);
return;
}
}
}

if (item.getTypeId() == ItemID.INK_SACK
&& item.getData() != null) {
if (item.getData().getData() == 15 // bonemeal
Expand Down

0 comments on commit 3e06000

Please sign in to comment.