From 26484e71e7bdfc243c5c4191472f3a7a3e4ce106 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 13 Apr 2016 21:05:19 -0700 Subject: [PATCH] Fire protection is back. Found a way to make it cheaper - we'll see how the new cost looks on production servers. --- .../GriefPrevention/GriefPrevention.java | 3 -- .../GriefPrevention/PlayerEventHandler.java | 45 +++++++++---------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index ac9bd9b..98f81b7 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -87,7 +87,6 @@ public class GriefPrevention extends JavaPlugin public boolean config_claims_preventTheft; //whether containers and crafting blocks are protectable public boolean config_claims_protectCreatures; //whether claimed animals may be injured by players without permission - public boolean config_claims_protectFires; //whether open flint+steel flames should be protected - optional because it's expensive public boolean config_claims_protectHorses; //whether horses on a claim should be protected by that claim's rules public boolean config_claims_preventButtonsSwitches; //whether buttons and switches are protectable public boolean config_claims_lockWoodenDoors; //whether wooden doors should be locked by default (require /accesstrust) @@ -514,7 +513,6 @@ public class GriefPrevention extends JavaPlugin this.config_claims_preventTheft = config.getBoolean("GriefPrevention.Claims.PreventTheft", true); this.config_claims_protectCreatures = config.getBoolean("GriefPrevention.Claims.ProtectCreatures", true); - this.config_claims_protectFires = config.getBoolean("GriefPrevention.Claims.ProtectFires", false); this.config_claims_protectHorses = config.getBoolean("GriefPrevention.Claims.ProtectHorses", true); this.config_claims_preventButtonsSwitches = config.getBoolean("GriefPrevention.Claims.PreventButtonsSwitches", true); this.config_claims_lockWoodenDoors = config.getBoolean("GriefPrevention.Claims.LockWoodenDoors", false); @@ -755,7 +753,6 @@ public class GriefPrevention extends JavaPlugin outConfig.set("GriefPrevention.Claims.LockTrapDoors", this.config_claims_lockTrapDoors); outConfig.set("GriefPrevention.Claims.LockFenceGates", this.config_claims_lockFenceGates); outConfig.set("GriefPrevention.Claims.EnderPearlsRequireAccessTrust", this.config_claims_enderPearlsRequireAccessTrust); - outConfig.set("GriefPrevention.Claims.ProtectFires", this.config_claims_protectFires); outConfig.set("GriefPrevention.Claims.ProtectHorses", this.config_claims_protectHorses); outConfig.set("GriefPrevention.Claims.InitialBlocks", this.config_claims_initialBlocks); outConfig.set("GriefPrevention.Claims.BlocksAccruedPerHour", this.config_claims_blocksAccruedPerHour); diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 3844da0..e64f850 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -1590,33 +1590,30 @@ class PlayerEventHandler implements Listener PlayerData playerData = null; if(action == Action.LEFT_CLICK_BLOCK && clickedBlock != null) { + Block adjacentBlock = clickedBlock.getRelative(event.getBlockFace()); + byte lightLevel = adjacentBlock.getLightFromBlocks(); + 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; + + String noBuildReason = claim.allowBuild(player, Material.AIR); + if(noBuildReason != null) + { + event.setCancelled(true); + GriefPrevention.sendMessage(player, TextMode.Err, noBuildReason); + player.sendBlockChange(adjacentBlock.getLocation(), adjacentBlock.getTypeId(), adjacentBlock.getData()); + return; + } + } + } + //exception for blocks on a specific watch list if(!this.onLeftClickWatchList(clickedBlockType) && !GriefPrevention.instance.config_mods_accessTrustIds.Contains(new MaterialInfo(clickedBlock.getTypeId(), clickedBlock.getData(), null))) { - //and an exception for putting our fires - if(GriefPrevention.instance.config_claims_protectFires && event.getClickedBlock() != null) - { - Block adjacentBlock = event.getClickedBlock().getRelative(event.getBlockFace()); - if(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; - - String noBuildReason = claim.allowBuild(player, Material.AIR); - if(noBuildReason != null) - { - event.setCancelled(true); - GriefPrevention.sendMessage(player, TextMode.Err, noBuildReason); - player.sendBlockChange(adjacentBlock.getLocation(), adjacentBlock.getTypeId(), adjacentBlock.getData()); - return; - } - } - } - } - return; } }