From 6cb8df52c71f099d7a9ebee0d6218da10dbd5639 Mon Sep 17 00:00:00 2001 From: Ryan Hamshire Date: Thu, 5 Jul 2012 17:22:50 -0700 Subject: [PATCH] 5.0 --- plugin.yml | 2 +- .../GriefPrevention/BlockEventHandler.java | 4 +-- .../GriefPrevention/DataStore.java | 2 +- .../GriefPrevention/EntityEventHandler.java | 11 +++---- .../GriefPrevention/GriefPrevention.java | 18 ++++++++++- .../GriefPrevention/PlayerEventHandler.java | 32 ++++++++++++------- .../GriefPrevention/Visualization.java | 2 +- 7 files changed, 46 insertions(+), 25 deletions(-) diff --git a/plugin.yml b/plugin.yml index c102f8e..84e4a7b 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: GriefPrevention main: me.ryanhamshire.GriefPrevention.GriefPrevention softdepend: [Vault, Multiverse-Core] -version: 4.9 +version: 5.0 commands: abandonclaim: description: Deletes a claim. diff --git a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index e92db94..cd0d97a 100644 --- a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -554,8 +554,8 @@ public class BlockEventHandler implements Listener //if it's growing into a claim if(blockClaim != null) { - //if there's no owner for the new tree, or the owner doesn't have permission to build in the claim, don't grow this block - if(fromOwner == null || fromOwner.getPlayer() == null || blockClaim.allowBuild(fromOwner.getPlayer()) != null) + //if there's no owner for the new tree, or the owner for the new tree is different from the owner of the claim + if(fromOwner == null || !fromOwner.getName().equals(blockClaim.ownerName)) { growEvent.getBlocks().remove(i--); } diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index cf4e4c7..585c769 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -1499,7 +1499,7 @@ public class DataStore this.addDefault(defaults, Messages.AdjustGroupBlocksSuccess, "Adjusted bonus claim blocks for players with the {0} permission by {1}. New total: {2}.", "0: permission; 1: adjustment amount; 2: new total bonus"); this.addDefault(defaults, Messages.InvalidPermissionID, "Please specify a player name, or a permission in [brackets].", null); this.addDefault(defaults, Messages.UntrustOwnerOnly, "Only {0} can revoke permissions here.", "0: claim owner's name"); - this.addDefault(defaults, Messages.HowToClaimRegex, "(^|.*\\W)how\\W.*\\W(claim|protect)(\\W.*|$)", "This is a Java Regular Expression. Look it up before editing! It's used to tell players about the demo video when they ask how to claim land."); + this.addDefault(defaults, Messages.HowToClaimRegex, "(^|.*\\W)how\\W.*\\W(claim|protect)(\\W.*|$)", "This is a Java Regular Expression. Look it up before editing! It's used to tell players about the demo video when they ask how to claim land."); //load the config file FileConfiguration config = YamlConfiguration.loadConfiguration(new File(messagesFilePath)); diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index 5126e74..e65d525 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -335,15 +335,12 @@ class EntityEventHandler implements Listener //if the attacker is a player and defender is a player (pvp combat) if(attacker != null && event.getEntity() instanceof Player) { - //if pvp is disabled, cancel the event - if(!event.getEntity().getWorld().getPVP()) - { - event.setCancelled(true); - return; - } - //FEATURE: prevent pvp in the first minute after spawn, and prevent pvp when one or both players have no inventory + //doesn't apply when the attacker has the no pvp immunity permission + //this rule is here to allow server owners to have a world with no spawn camp protection by assigning permissions based on the player's world + if(attacker.hasPermission("griefprevention.nopvpimmunity")) return; + Player defender = (Player)(event.getEntity()); PlayerData defenderData = this.dataStore.getPlayerData(((Player)event.getEntity()).getName()); diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index c304533..1965a20 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -66,6 +66,7 @@ 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_preventButtonsSwitches; //whether buttons and switches are protectable + public boolean config_claims_lockAllDoors; //whether wooden doors, trap doors, fence gates, etc require permission to use public int config_claims_initialBlocks; //the number of claim blocks a new player starts with public int config_claims_blocksAccruedPerHour; //how many additional blocks players get each hour of play (can be zero) @@ -214,7 +215,8 @@ 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_preventButtonsSwitches = config.getBoolean("GriefPrevention.Claims.PreventButtonsSwitches", true); + this.config_claims_preventButtonsSwitches = config.getBoolean("GriefPrevention.Claims.PreventButtonsSwitches", true); + this.config_claims_lockAllDoors = config.getBoolean("GriefPrevention.Claims.LockAllDoors", false); this.config_claims_initialBlocks = config.getInt("GriefPrevention.Claims.InitialBlocks", 100); this.config_claims_blocksAccruedPerHour = config.getInt("GriefPrevention.Claims.BlocksAccruedPerHour", 100); this.config_claims_maxAccruedBlocks = config.getInt("GriefPrevention.Claims.MaxAccruedBlocks", 80000); @@ -351,6 +353,7 @@ public class GriefPrevention extends JavaPlugin config.set("GriefPrevention.Claims.PreventTheft", this.config_claims_preventTheft); config.set("GriefPrevention.Claims.ProtectCreatures", this.config_claims_protectCreatures); config.set("GriefPrevention.Claims.PreventButtonsSwitches", this.config_claims_preventButtonsSwitches); + config.set("GriefPrevention.Claims.LockAllDoors", this.config_claims_lockAllDoors); config.set("GriefPrevention.Claims.InitialBlocks", this.config_claims_initialBlocks); config.set("GriefPrevention.Claims.BlocksAccruedPerHour", this.config_claims_blocksAccruedPerHour); config.set("GriefPrevention.Claims.MaxAccruedBlocks", this.config_claims_maxAccruedBlocks); @@ -948,6 +951,11 @@ public class GriefPrevention extends JavaPlugin return false; //causes usage to be displayed } + if(blockCount <= 0) + { + return false; + } + //correct block count to max allowed if(blockCount > maxPurchasable) { @@ -1015,6 +1023,11 @@ public class GriefPrevention extends JavaPlugin return false; //causes usage to be displayed } + if(blockCount <= 0) + { + return false; + } + //if he doesn't have enough blocks, tell him so if(blockCount > availableBlocks) { @@ -1687,6 +1700,9 @@ public class GriefPrevention extends JavaPlugin //if anti spawn camping feature is not enabled, do nothing if(!this.config_pvp_protectFreshSpawns) return; + //if the player has the damage any player permission enabled, do nothing + if(player.hasPermission("griefprevention.nopvpimmunity")) return; + //check inventory for well, anything PlayerInventory inventory = player.getInventory(); ItemStack [] armorStacks = inventory.getArmorContents(); diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 2975094..2637999 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -126,19 +126,11 @@ class PlayerEventHandler implements Listener boolean spam = false; boolean muted = false; - //single-character messages will not be sent - if(message.length() == 1) - { - playerData.spamCount++; - spam = true; - muted = true; - } - //check message content and timing long millisecondsSinceLastMessage = (new Date()).getTime() - playerData.lastMessageTimestamp.getTime(); //if the message came too close to the last one - if(millisecondsSinceLastMessage < 3000) + if(millisecondsSinceLastMessage < 2000) { //increment the spam counter playerData.spamCount++; @@ -209,7 +201,7 @@ class PlayerEventHandler implements Listener if(!player.hasPermission("griefprevention.spam") && spam) { //anything above level 4 for a player which has received a warning... kick or if enabled, ban - if(playerData.spamCount > 4 && playerData.spamWarned) + if(playerData.spamCount > 8 && playerData.spamWarned) { if(GriefPrevention.instance.config_spam_banOffenders) { @@ -913,6 +905,22 @@ class PlayerEventHandler implements Listener } } + //otherwise apply rules for doors, if configured that way + else if(GriefPrevention.instance.config_claims_lockAllDoors && (clickedBlockType == Material.WOOD_DOOR || clickedBlockType == Material.WOODEN_DOOR || clickedBlockType == Material.TRAP_DOOR || clickedBlockType == Material.FENCE_GATE)) + { + Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, null); + if(claim != null) + { + String noAccessReason = claim.allowAccess(player); + if(noAccessReason != null) + { + event.setCancelled(true); + GriefPrevention.sendMessage(player, TextMode.Err, noAccessReason); + return; + } + } + } + //otherwise apply rules for buttons and switches else if(GriefPrevention.instance.config_claims_preventButtonsSwitches && (clickedBlockType == null || clickedBlockType == Material.STONE_BUTTON || clickedBlockType == Material.LEVER)) { @@ -937,8 +945,8 @@ class PlayerEventHandler implements Listener return; } - //apply rule for note blocks - else if(clickedBlockType == Material.NOTE_BLOCK) + //apply rule for note blocks and repeaters + else if(clickedBlockType == Material.NOTE_BLOCK || clickedBlockType == Material.DIODE_BLOCK_ON || clickedBlockType == Material.DIODE_BLOCK_OFF) { Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, null); if(claim != null) diff --git a/src/me/ryanhamshire/GriefPrevention/Visualization.java b/src/me/ryanhamshire/GriefPrevention/Visualization.java index 277e2c7..e6cf6f6 100644 --- a/src/me/ryanhamshire/GriefPrevention/Visualization.java +++ b/src/me/ryanhamshire/GriefPrevention/Visualization.java @@ -135,7 +135,7 @@ public class Visualization else { - cornerMaterial = Material.LAVA; + cornerMaterial = Material.GLOWING_REDSTONE_ORE; accentMaterial = Material.NETHERRACK; }