Reworked previous "workaround for craftbukkit bug".

Now with better understanding of root cause.
This commit is contained in:
ryanhamshire 2016-05-05 08:24:21 -07:00
parent 124f20753f
commit 4d9175e9a9

View File

@ -1590,28 +1590,26 @@ class PlayerEventHandler implements Listener
PlayerData playerData = null; PlayerData playerData = null;
if(action == Action.LEFT_CLICK_BLOCK && clickedBlock != null) if(action == Action.LEFT_CLICK_BLOCK && clickedBlock != null)
{ {
Block adjacentBlock = clickedBlock.getRelative(event.getBlockFace()); if(clickedBlock.getY() < clickedBlock.getWorld().getMaxHeight() - 1 || event.getBlockFace() != BlockFace.UP)
byte lightLevel = 15;
try
{ {
lightLevel = adjacentBlock.getLightFromBlocks(); Block adjacentBlock = clickedBlock.getRelative(event.getBlockFace());
} byte lightLevel = adjacentBlock.getLightFromBlocks();
catch(ArrayIndexOutOfBoundsException e){ } //assume default value of 15 to work around a craftbukkit bug if(lightLevel == 15 && adjacentBlock.getType() == Material.FIRE)
if(lightLevel == 15 && adjacentBlock.getType() == Material.FIRE)
{
if(playerData == null) playerData = this.dataStore.getPlayerData(player.getUniqueId());
Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, playerData.lastClaim);
if(claim != null)
{ {
playerData.lastClaim = claim; if(playerData == null) playerData = this.dataStore.getPlayerData(player.getUniqueId());
Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, playerData.lastClaim);
String noBuildReason = claim.allowBuild(player, Material.AIR); if(claim != null)
if(noBuildReason != null)
{ {
event.setCancelled(true); playerData.lastClaim = claim;
GriefPrevention.sendMessage(player, TextMode.Err, noBuildReason);
player.sendBlockChange(adjacentBlock.getLocation(), adjacentBlock.getTypeId(), adjacentBlock.getData()); String noBuildReason = claim.allowBuild(player, Material.AIR);
return; if(noBuildReason != null)
{
event.setCancelled(true);
GriefPrevention.sendMessage(player, TextMode.Err, noBuildReason);
player.sendBlockChange(adjacentBlock.getLocation(), adjacentBlock.getTypeId(), adjacentBlock.getData());
return;
}
} }
} }
} }