Protected cake.

This commit is contained in:
ryanhamshire 2015-02-25 17:24:21 -08:00
parent 7816409ff6
commit 07ea755b4d

View File

@ -1281,7 +1281,7 @@ class PlayerEventHandler implements Listener
Action action = event.getAction(); Action action = event.getAction();
if(action == Action.LEFT_CLICK_AIR) return; if(action == Action.LEFT_CLICK_AIR) return;
if(action == Action.PHYSICAL) return; if(action == Action.PHYSICAL) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock(); //null returned here means interacting with air Block clickedBlock = event.getClickedBlock(); //null returned here means interacting with air
@ -1337,6 +1337,7 @@ class PlayerEventHandler implements Listener
clickedBlockType == Material.CAULDRON || clickedBlockType == Material.CAULDRON ||
clickedBlockType == Material.JUKEBOX || clickedBlockType == Material.JUKEBOX ||
clickedBlockType == Material.ANVIL || clickedBlockType == Material.ANVIL ||
clickedBlockType == Material.CAKE_BLOCK ||
GriefPrevention.instance.config_mods_containerTrustIds.Contains(new MaterialInfo(clickedBlock.getTypeId(), clickedBlock.getData(), null))))) GriefPrevention.instance.config_mods_containerTrustIds.Contains(new MaterialInfo(clickedBlock.getTypeId(), clickedBlock.getData(), null)))))
{ {
if(playerData == null) playerData = this.dataStore.getPlayerData(player.getUniqueId()); if(playerData == null) playerData = this.dataStore.getPlayerData(player.getUniqueId());
@ -1440,6 +1441,25 @@ class PlayerEventHandler implements Listener
} }
} }
//otherwise apply rule for cake
else if(clickedBlock != null && GriefPrevention.instance.config_claims_preventTheft && clickedBlockType == Material.CAKE_BLOCK)
{
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;
String noContainerReason = claim.allowAccess(player);
if(noContainerReason != null)
{
event.setCancelled(true);
GriefPrevention.sendMessage(player, TextMode.Err, noContainerReason);
return;
}
}
}
//apply rule for note blocks and repeaters and daylight sensors //apply rule for note blocks and repeaters and daylight sensors
else if(clickedBlock != null && else if(clickedBlock != null &&
( (
@ -2299,6 +2319,7 @@ class PlayerEventHandler implements Listener
case LEVER: case LEVER:
case DIODE_BLOCK_ON: //redstone repeater case DIODE_BLOCK_ON: //redstone repeater
case DIODE_BLOCK_OFF: case DIODE_BLOCK_OFF:
case CAKE_BLOCK:
return true; return true;
default: default:
return false; return false;