From 696df595bdc6ba300f842774ff9230b5aac77da5 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 14 Jan 2015 19:46:15 -0800 Subject: [PATCH] Reduced frequency of "building outside claims". Added a 10 minute cooldown period and administrators (those who can create admin claims) won't see it at all. --- .../GriefPrevention/BlockEventHandler.java | 35 +++++++++++-------- .../GriefPrevention/PlayerData.java | 3 ++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 48449f9..710909d 100644 --- a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -271,23 +271,30 @@ public class BlockEventHandler implements Listener //FEATURE: warn players when they're placing non-trash blocks outside of their claimed areas else if(!this.trashBlocks.contains(block.getType()) && GriefPrevention.instance.claimsEnabledForWorld(block.getWorld())) { - if(!playerData.warnedAboutBuildingOutsideClaims + if(!playerData.warnedAboutBuildingOutsideClaims && !player.hasPermission("griefprevention.adminclaims") && ((playerData.lastClaim == null && playerData.getClaims().size() == 0) || (playerData.lastClaim != null && playerData.lastClaim.isNear(player.getLocation(), 15)))) { - GriefPrevention.sendMessage(player, TextMode.Warn, Messages.BuildingOutsideClaims); - playerData.warnedAboutBuildingOutsideClaims = true; - - if(playerData.getClaims().size() < 2) - { - GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL); - } - - if(playerData.lastClaim != null) - { - Visualization visualization = Visualization.FromClaim(playerData.lastClaim, block.getY(), VisualizationType.Claim, player.getLocation()); - Visualization.Apply(player, visualization); - } + Long now = null; + if(playerData.buildWarningTimestamp == null || (now = System.currentTimeMillis()) - playerData.buildWarningTimestamp > 600000) //10 minute cooldown + { + GriefPrevention.sendMessage(player, TextMode.Warn, Messages.BuildingOutsideClaims); + playerData.warnedAboutBuildingOutsideClaims = true; + + if(now == null) now = System.currentTimeMillis(); + playerData.buildWarningTimestamp = now; + + if(playerData.getClaims().size() < 2) + { + GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL); + } + + if(playerData.lastClaim != null) + { + Visualization visualization = Visualization.FromClaim(playerData.lastClaim, block.getY(), VisualizationType.Claim, player.getLocation()); + Visualization.Apply(player, visualization); + } + } } } diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerData.java b/src/me/ryanhamshire/GriefPrevention/PlayerData.java index e3efbfe..bfd9c5e 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerData.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerData.java @@ -125,6 +125,9 @@ public class PlayerData //player which a pet will be given to when it's right-clicked OfflinePlayer petGiveawayRecipient = null; + //timestamp for last "you're building outside your land claims" message + Long buildWarningTimestamp = null; + //whether or not this player is "in" pvp combat public boolean inPvpCombat() {