From e746aa20c035210cc739dbb61b8de60f97655c72 Mon Sep 17 00:00:00 2001 From: Ryan Hamshire Date: Sat, 11 Aug 2012 15:38:26 -0700 Subject: [PATCH] 6.0 --- plugin.yml | 2 +- .../ryanhamshire/GriefPrevention/DataStore.java | 8 ++++---- .../GriefPrevention/EntityEventHandler.java | 7 ++++++- .../GriefPrevention/GriefPrevention.java | 2 +- .../GriefPrevention/PlayerEventHandler.java | 14 +------------- .../RestoreNatureExecutionTask.java | 15 +++++++++++++-- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/plugin.yml b/plugin.yml index 13cc197..2483ee3 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: GriefPrevention main: me.ryanhamshire.GriefPrevention.GriefPrevention softdepend: [Vault, Multiverse-Core, My Worlds] dev-url: http://dev.bukkit.org/server-mods/grief-prevention -version: 5.9 +version: 6.0 commands: abandonclaim: description: Deletes a claim. diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index 7328400..a252506 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -876,7 +876,7 @@ public abstract class DataStore this.addDefault(defaults, Messages.AdminClaimsMode, "Administrative claims mode active. Any claims created will be free and editable by other administrators.", null); this.addDefault(defaults, Messages.BasicClaimsMode, "Returned to basic claim creation mode.", null); this.addDefault(defaults, Messages.SubdivisionMode, "Subdivision mode. Use your shovel to create subdivisions in your existing claims. Use /basicclaims to exit.", null); - this.addDefault(defaults, Messages.SubdivisionDemo, "Want a demonstration? http://tinyurl.com/7urdtue", null); + this.addDefault(defaults, Messages.SubdivisionDemo, "Land Claim Help: http://tinyurl.com/7urdtue", null); this.addDefault(defaults, Messages.DeleteClaimMissing, "There's no claim here.", null); this.addDefault(defaults, Messages.DeletionSubdivisionWarning, "This claim includes subdivisions. If you're sure you want to delete it, use /DeleteClaim again.", null); this.addDefault(defaults, Messages.DeleteSuccess, "Claim deleted.", null); @@ -932,8 +932,8 @@ public abstract class DataStore this.addDefault(defaults, Messages.NoDamageClaimedEntity, "That belongs to {0}.", "0: owner name"); this.addDefault(defaults, Messages.ShovelBasicClaimMode, "Shovel returned to basic claims mode.", null); this.addDefault(defaults, Messages.RemainingBlocks, "You may claim up to {0} more blocks.", "0: remaining blocks"); - this.addDefault(defaults, Messages.CreativeBasicsDemoAdvertisement, "Want a demonstration? http://tinyurl.com/c7bajb8", null); - this.addDefault(defaults, Messages.SurvivalBasicsDemoAdvertisement, "Want a demonstration? http://tinyurl.com/6nkwegj", null); + this.addDefault(defaults, Messages.CreativeBasicsDemoAdvertisement, "Land Claim Help: http://tinyurl.com/c7bajb8", null); + this.addDefault(defaults, Messages.SurvivalBasicsDemoAdvertisement, "Land Claim Help: http://tinyurl.com/6nkwegj", null); this.addDefault(defaults, Messages.TrappedChatKeyword, "trapped", "When mentioned in chat, players get information about the /trapped command."); this.addDefault(defaults, Messages.TrappedInstructions, "Are you trapped in someone's claim? Consider the /trapped command.", null); this.addDefault(defaults, Messages.PvPNoDrop, "You can't drop items while in PvP combat.", null); @@ -991,7 +991,7 @@ public abstract 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|lock)(\\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.NoBuildOutsideClaims, "You can't build here unless you claim some land first.", null); this.addDefault(defaults, Messages.PlayerOfflineTime, " Last login: {0} days ago.", "0: number of full days since last login"); this.addDefault(defaults, Messages.BuildingOutsideClaims, "Other players can undo your work here! Consider claiming this area to protect your work.", null); diff --git a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java index f9b3a1f..36bf02a 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -323,6 +323,7 @@ class EntityEventHandler implements Listener //determine which player is attacking, if any Player attacker = null; + Arrow arrow = null; Entity damageSource = subEvent.getDamager(); if(damageSource instanceof Player) { @@ -330,7 +331,7 @@ class EntityEventHandler implements Listener } else if(damageSource instanceof Arrow) { - Arrow arrow = (Arrow)damageSource; + arrow = (Arrow)damageSource; if(arrow.getShooter() instanceof Player) { attacker = (Player)arrow.getShooter(); @@ -423,6 +424,10 @@ class EntityEventHandler implements Listener if(noContainersReason != null) { event.setCancelled(true); + + //kill the arrow to avoid infinite bounce between crowded together animals + if(arrow != null) arrow.remove(); + GriefPrevention.sendMessage(attacker, TextMode.Err, Messages.NoDamageClaimedEntity, claim.getOwnerName()); } diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 813dbe0..e21d5e7 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -232,7 +232,7 @@ public class GriefPrevention extends JavaPlugin this.config_claims_preventButtonsSwitches = config.getBoolean("GriefPrevention.Claims.PreventButtonsSwitches", true); this.config_claims_lockWoodenDoors = config.getBoolean("GriefPrevention.Claims.LockWoodenDoors", false); this.config_claims_lockTrapDoors = config.getBoolean("GriefPrevention.Claims.LockTrapDoors", false); - this.config_claims_lockFenceGates = config.getBoolean("GriefPrevention.Claims.LockFenceGates", false); + this.config_claims_lockFenceGates = config.getBoolean("GriefPrevention.Claims.LockFenceGates", true); 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); diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index fb05ec4..3bb5c79 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -941,7 +941,7 @@ class PlayerEventHandler implements Listener } //otherwise apply rules for doors, if configured that way - else if((GriefPrevention.instance.config_claims_lockWoodenDoors && clickedBlockType == Material.WOOD_DOOR) || + else if((GriefPrevention.instance.config_claims_lockWoodenDoors && clickedBlockType == Material.WOODEN_DOOR) || (GriefPrevention.instance.config_claims_lockTrapDoors && clickedBlockType == Material.TRAP_DOOR) || (GriefPrevention.instance.config_claims_lockFenceGates && clickedBlockType == Material.FENCE_GATE)) { @@ -1141,18 +1141,6 @@ class PlayerEventHandler implements Listener //figure out which chunk to repair Chunk chunk = player.getWorld().getChunkAt(clickedBlock.getLocation()); - //check it for players, and cancel if there are any - Entity [] entities = chunk.getEntities(); - for(int i = 0; i < entities.length; i++) - { - if(entities[i] instanceof Player) - { - Player otherPlayer = (Player)entities[i]; - GriefPrevention.sendMessage(player, TextMode.Err, Messages.RestoreNaturePlayerInChunk, otherPlayer.getName()); - return; - } - } - //build a snapshot of this chunk, including 1 block boundary outside of the chunk all the way around int maxHeight = chunk.getWorld().getMaxHeight(); BlockSnapshot[][][] snapshots = new BlockSnapshot[18][maxHeight][18]; diff --git a/src/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java b/src/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java index 8aedb2e..17237be 100644 --- a/src/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java +++ b/src/me/ryanhamshire/GriefPrevention/RestoreNatureExecutionTask.java @@ -20,7 +20,9 @@ package me.ryanhamshire.GriefPrevention; import org.bukkit.Chunk; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -80,13 +82,22 @@ class RestoreNatureExecutionTask implements Runnable } } - //clean up any entities in the chunk + //clean up any entities in the chunk, ensure no players are suffocated Chunk chunk = this.lesserCorner.getChunk(); Entity [] entities = chunk.getEntities(); for(int i = 0; i < entities.length; i++) { Entity entity = entities[i]; - if(!(entity instanceof Player)) entity.remove(); + if(!(entity instanceof Player)) + { + entity.remove(); + } + else + { + Block feetBlock = entity.getLocation().getBlock(); + feetBlock.setType(Material.AIR); + feetBlock.getRelative(BlockFace.UP).setType(Material.AIR); + } } //show visualization to player