From 50f572fc2b5e35b73da6d0f2135eb08769341180 Mon Sep 17 00:00:00 2001 From: Ryan Hamshire Date: Mon, 23 Jul 2012 08:17:55 -0700 Subject: [PATCH] 5.5 --- plugin.yml | 2 +- .../GriefPrevention/DataStore.java | 1 + .../GriefPrevention/EntityEventHandler.java | 26 +++++++++++---- .../GriefPrevention/GriefPrevention.java | 15 +++++++-- .../GriefPrevention/Messages.java | 2 +- .../GriefPrevention/PlayerEventHandler.java | 33 ++++++++++++++----- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/plugin.yml b/plugin.yml index 541011e..42a6ab1 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: GriefPrevention main: me.ryanhamshire.GriefPrevention.GriefPrevention softdepend: [Vault, Multiverse-Core, My Worlds] -version: 5.4 +version: 5.5 commands: abandonclaim: description: Deletes a claim. diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index 3bcc691..1e019a3 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -993,6 +993,7 @@ public abstract class DataStore 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.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"); //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 7643206..3d0875a 100644 --- a/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/EntityEventHandler.java @@ -95,27 +95,39 @@ class EntityEventHandler implements Listener if(GriefPrevention.instance.config_blockSurfaceExplosions && location.getWorld().getEnvironment() == Environment.NORMAL) { - if(location.getBlockY() >location.getWorld().getSeaLevel() - 7) + for(int i = 0; i < blocks.size(); i++) { - blocks.clear(); //explosion still happens, can damage creatures/players, but no blocks will be destroyed - return; - } + Block block = blocks.get(i); + if(GriefPrevention.instance.config_mods_explodableIds.contains(block.getTypeId())) continue; + + if(block.getLocation().getBlockY() > location.getWorld().getSeaLevel() - 7) + { + blocks.remove(i--); + } + } } //special rule for creative worlds: explosions don't destroy anything if(GriefPrevention.instance.creativeRulesApply(explodeEvent.getLocation())) { - blocks.clear(); + for(int i = 0; i < blocks.size(); i++) + { + Block block = blocks.get(i); + if(GriefPrevention.instance.config_mods_explodableIds.contains(block.getTypeId())) continue; + + blocks.remove(i--); + } } - //FEATURE: creating an explosion near a claim doesn't damage any of the claimed blocks - + //FEATURE: explosions don't damage claimed blocks Claim claim = null; for(int i = 0; i < blocks.size(); i++) //for each destroyed block { Block block = blocks.get(i); if(block.getType() == Material.AIR) continue; //if it's air, we don't care + if(GriefPrevention.instance.config_mods_explodableIds.contains(block.getTypeId())) continue; + claim = this.dataStore.getClaimAt(block.getLocation(), false, claim); //if the block is claimed, remove it from the list of destroyed blocks if(claim != null) diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 12a6112..ecb77ad 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -127,6 +127,7 @@ public class GriefPrevention extends JavaPlugin public List config_mods_accessTrustIds; //list of block IDs which should require /accesstrust for player interaction public List config_mods_containerTrustIds; //list of block IDs which should require /containertrust for player interaction public List config_mods_ignoreClaimsAccounts; //list of player names which ALWAYS ignore claims + public List config_mods_explodableIds; //list of block IDs which can be destroyed by explosions, even in claimed areas //reference to the economy plugin, if economy integration is enabled public static Economy economy = null; @@ -281,6 +282,9 @@ public class GriefPrevention extends JavaPlugin this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims"); if(this.config_mods_ignoreClaimsAccounts == null) this.config_mods_ignoreClaimsAccounts = new ArrayList(); + this.config_mods_explodableIds = config.getIntegerList("GriefPrevention.Mods.BlockIdsExplodable"); + if(this.config_mods_explodableIds == null) this.config_mods_explodableIds = new ArrayList(); + //default for claim investigation tool String investigationToolMaterialName = Material.STICK.name(); @@ -450,6 +454,7 @@ public class GriefPrevention extends JavaPlugin config.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", this.config_mods_accessTrustIds); config.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", this.config_mods_containerTrustIds); + config.set("GriefPrevention.Mods.BlockIdsExplodable", this.config_mods_explodableIds); config.set("GriefPrevention.Mods.PlayersIgnoringAllClaims", this.config_mods_ignoreClaimsAccounts); try @@ -1269,15 +1274,19 @@ public class GriefPrevention extends JavaPlugin //load the player's data PlayerData playerData = this.dataStore.getPlayerData(otherPlayer.getName()); - player.sendMessage(playerData.accruedClaimBlocks + "(+" + playerData.bonusClaimBlocks + ")=" + playerData.accruedClaimBlocks + playerData.bonusClaimBlocks); + GriefPrevention.sendMessage(player, TextMode.Instr, " " + playerData.accruedClaimBlocks + "(+" + playerData.bonusClaimBlocks + ")=" + (playerData.accruedClaimBlocks + playerData.bonusClaimBlocks)); for(int i = 0; i < playerData.claims.size(); i++) { Claim claim = playerData.claims.get(i); - player.sendMessage("(-" + claim.getArea() + ") " + getfriendlyLocationString(claim.getLesserBoundaryCorner())); + GriefPrevention.sendMessage(player, TextMode.Instr, " (-" + claim.getArea() + ") " + getfriendlyLocationString(claim.getLesserBoundaryCorner())); } if(playerData.claims.size() > 0) - player.sendMessage("=" + playerData.getRemainingClaimBlocks()); + GriefPrevention.sendMessage(player, TextMode.Instr, " =" + playerData.getRemainingClaimBlocks()); + + //drop the data we just loaded, if the player isn't online + if(!otherPlayer.isOnline()) + this.dataStore.clearCachedPlayerData(otherPlayer.getName()); return true; } diff --git a/src/me/ryanhamshire/GriefPrevention/Messages.java b/src/me/ryanhamshire/GriefPrevention/Messages.java index e1f8f54..1b61330 100644 --- a/src/me/ryanhamshire/GriefPrevention/Messages.java +++ b/src/me/ryanhamshire/GriefPrevention/Messages.java @@ -2,5 +2,5 @@ package me.ryanhamshire.GriefPrevention; public enum Messages { - RespectingClaims, IgnoringClaims, SuccessfulAbandon, RestoreNatureActivate, RestoreNatureAggressiveActivate, FillModeActive, TransferClaimPermission, TransferClaimMissing, TransferClaimAdminOnly, PlayerNotFound, TransferTopLevel, TransferSuccess, TrustListNoClaim, ClearPermsOwnerOnly, UntrustIndividualAllClaims, UntrustEveryoneAllClaims, NoPermissionTrust, ClearPermissionsOneClaim, UntrustIndividualSingleClaim, OnlySellBlocks, BlockPurchaseCost, ClaimBlockLimit, InsufficientFunds, PurchaseConfirmation, OnlyPurchaseBlocks, BlockSaleValue, NotEnoughBlocksForSale, BlockSaleConfirmation, AdminClaimsMode, BasicClaimsMode, SubdivisionMode, SubdivisionDemo, DeleteClaimMissing, DeletionSubdivisionWarning, DeleteSuccess, CantDeleteAdminClaim, DeleteAllSuccess, NoDeletePermission, AllAdminDeleted, AdjustBlocksSuccess, NotTrappedHere, TrappedOnCooldown, RescuePending, NonSiegeWorld, AlreadySieging, NotSiegableThere, SiegeTooFarAway, NoSiegeDefenseless, AlreadyUnderSiegePlayer, AlreadyUnderSiegeArea, NoSiegeAdminClaim, SiegeOnCooldown, SiegeAlert, SiegeConfirmed, AbandonClaimMissing, NotYourClaim, DeleteTopLevelClaim, AbandonSuccess, CantGrantThatPermission, GrantPermissionNoClaim, GrantPermissionConfirmation, ManageUniversalPermissionsInstruction, ManageOneClaimPermissionsInstruction, CollectivePublic, BuildPermission, ContainersPermission, AccessPermission, PermissionsPermission, LocationCurrentClaim, LocationAllClaims, PvPImmunityStart, SiegeNoDrop, DonateItemsInstruction, ChestFull, DonationSuccess, PlayerTooCloseForFire, TooDeepToClaim, ChestClaimConfirmation, AutomaticClaimNotification, TrustCommandAdvertisement, GoldenShovelAdvertisement, UnprotectedChestWarning, ThatPlayerPvPImmune, CantFightWhileImmune, NoDamageClaimedEntity, ShovelBasicClaimMode, RemainingBlocks, CreativeBasicsDemoAdvertisement, SurvivalBasicsDemoAdvertisement, TrappedChatKeyword, TrappedInstructions, PvPNoDrop, SiegeNoTeleport, BesiegedNoTeleport, SiegeNoContainers, PvPNoContainers, PvPImmunityEnd, NoBedPermission, NoWildernessBuckets, NoLavaNearOtherPlayer, TooFarAway, BlockNotClaimed, BlockClaimed, SiegeNoShovel, RestoreNaturePlayerInChunk, NoCreateClaimPermission, ResizeClaimTooSmall, ResizeNeedMoreBlocks, NoCreativeUnClaim, ClaimResizeSuccess, ResizeFailOverlap, ResizeStart, ResizeFailOverlapSubdivision, SubdivisionStart, CreateSubdivisionOverlap, SubdivisionSuccess, CreateClaimFailOverlap, CreateClaimFailOverlapOtherPlayer, ClaimsDisabledWorld, ClaimStart, NewClaimTooSmall, CreateClaimInsufficientBlocks, AbandonClaimAdvertisement, CreateClaimFailOverlapShort, CreateClaimSuccess, SiegeWinDoorsOpen, RescueAbortedMoved, SiegeDoorsLockedEjection, NoModifyDuringSiege, OnlyOwnersModifyClaims, NoBuildUnderSiege, NoBuildPvP, NoBuildPermission, NonSiegeMaterial, NoOwnerBuildUnderSiege, NoAccessPermission, NoContainersSiege, NoContainersPermission, OwnerNameForAdminClaims, ClaimTooSmallForEntities, TooManyEntitiesInClaim, YouHaveNoClaims, ConfirmFluidRemoval, AutoBanNotify, AdjustGroupBlocksSuccess, InvalidPermissionID, UntrustOwnerOnly, HowToClaimRegex, NoBuildOutsideClaims + RespectingClaims, IgnoringClaims, SuccessfulAbandon, RestoreNatureActivate, RestoreNatureAggressiveActivate, FillModeActive, TransferClaimPermission, TransferClaimMissing, TransferClaimAdminOnly, PlayerNotFound, TransferTopLevel, TransferSuccess, TrustListNoClaim, ClearPermsOwnerOnly, UntrustIndividualAllClaims, UntrustEveryoneAllClaims, NoPermissionTrust, ClearPermissionsOneClaim, UntrustIndividualSingleClaim, OnlySellBlocks, BlockPurchaseCost, ClaimBlockLimit, InsufficientFunds, PurchaseConfirmation, OnlyPurchaseBlocks, BlockSaleValue, NotEnoughBlocksForSale, BlockSaleConfirmation, AdminClaimsMode, BasicClaimsMode, SubdivisionMode, SubdivisionDemo, DeleteClaimMissing, DeletionSubdivisionWarning, DeleteSuccess, CantDeleteAdminClaim, DeleteAllSuccess, NoDeletePermission, AllAdminDeleted, AdjustBlocksSuccess, NotTrappedHere, TrappedOnCooldown, RescuePending, NonSiegeWorld, AlreadySieging, NotSiegableThere, SiegeTooFarAway, NoSiegeDefenseless, AlreadyUnderSiegePlayer, AlreadyUnderSiegeArea, NoSiegeAdminClaim, SiegeOnCooldown, SiegeAlert, SiegeConfirmed, AbandonClaimMissing, NotYourClaim, DeleteTopLevelClaim, AbandonSuccess, CantGrantThatPermission, GrantPermissionNoClaim, GrantPermissionConfirmation, ManageUniversalPermissionsInstruction, ManageOneClaimPermissionsInstruction, CollectivePublic, BuildPermission, ContainersPermission, AccessPermission, PermissionsPermission, LocationCurrentClaim, LocationAllClaims, PvPImmunityStart, SiegeNoDrop, DonateItemsInstruction, ChestFull, DonationSuccess, PlayerTooCloseForFire, TooDeepToClaim, ChestClaimConfirmation, AutomaticClaimNotification, TrustCommandAdvertisement, GoldenShovelAdvertisement, UnprotectedChestWarning, ThatPlayerPvPImmune, CantFightWhileImmune, NoDamageClaimedEntity, ShovelBasicClaimMode, RemainingBlocks, CreativeBasicsDemoAdvertisement, SurvivalBasicsDemoAdvertisement, TrappedChatKeyword, TrappedInstructions, PvPNoDrop, SiegeNoTeleport, BesiegedNoTeleport, SiegeNoContainers, PvPNoContainers, PvPImmunityEnd, NoBedPermission, NoWildernessBuckets, NoLavaNearOtherPlayer, TooFarAway, BlockNotClaimed, BlockClaimed, SiegeNoShovel, RestoreNaturePlayerInChunk, NoCreateClaimPermission, ResizeClaimTooSmall, ResizeNeedMoreBlocks, NoCreativeUnClaim, ClaimResizeSuccess, ResizeFailOverlap, ResizeStart, ResizeFailOverlapSubdivision, SubdivisionStart, CreateSubdivisionOverlap, SubdivisionSuccess, CreateClaimFailOverlap, CreateClaimFailOverlapOtherPlayer, ClaimsDisabledWorld, ClaimStart, NewClaimTooSmall, CreateClaimInsufficientBlocks, AbandonClaimAdvertisement, CreateClaimFailOverlapShort, CreateClaimSuccess, SiegeWinDoorsOpen, RescueAbortedMoved, SiegeDoorsLockedEjection, NoModifyDuringSiege, OnlyOwnersModifyClaims, NoBuildUnderSiege, NoBuildPvP, NoBuildPermission, NonSiegeMaterial, NoOwnerBuildUnderSiege, NoAccessPermission, NoContainersSiege, NoContainersPermission, OwnerNameForAdminClaims, ClaimTooSmallForEntities, TooManyEntitiesInClaim, YouHaveNoClaims, ConfirmFluidRemoval, AutoBanNotify, AdjustGroupBlocksSuccess, InvalidPermissionID, UntrustOwnerOnly, HowToClaimRegex, NoBuildOutsideClaims, PlayerOfflineTime } diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index ad8a640..b6bf22b 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -859,7 +859,7 @@ class PlayerEventHandler implements Listener transparentMaterials.add(Byte.valueOf((byte)Material.AIR.getId())); transparentMaterials.add(Byte.valueOf((byte)Material.SNOW.getId())); transparentMaterials.add(Byte.valueOf((byte)Material.LONG_GRASS.getId())); - clickedBlock = player.getTargetBlock(null, 250); + clickedBlock = player.getTargetBlock(transparentMaterials, 250); } } catch(Exception e) //an exception intermittently comes from getTargetBlock(). when it does, just ignore the event @@ -1058,6 +1058,27 @@ class PlayerEventHandler implements Listener //visualize boundary Visualization visualization = Visualization.FromClaim(claim, clickedBlock.getY(), VisualizationType.Claim, player.getLocation()); Visualization.Apply(player, visualization); + + //if can resize this claim, tell about the boundaries + if(claim.allowEdit(player) == null) + { + GriefPrevention.sendMessage(player, TextMode.Info, " " + claim.getWidth() + "x" + claim.getHeight() + "=" + claim.getArea()); + } + + //if deleteclaims permission, tell about the player's offline time + if(!claim.isAdminClaim() && player.hasPermission("griefprevention.deleteclaims")) + { + PlayerData otherPlayerData = this.dataStore.getPlayerData(claim.getOwnerName()); + Date lastLogin = otherPlayerData.lastLogin; + Date now = new Date(); + long daysElapsed = (now.getTime() - lastLogin.getTime()) / (1000 * 60 * 60 * 24); + + GriefPrevention.sendMessage(player, TextMode.Info, Messages.PlayerOfflineTime, String.valueOf(daysElapsed)); + + //drop the data we just loaded, if the player isn't online + if(GriefPrevention.instance.getServer().getPlayerExact(claim.getOwnerName()) == null) + this.dataStore.clearCachedPlayerData(claim.getOwnerName()); + } } return; @@ -1181,12 +1202,6 @@ class PlayerEventHandler implements Listener Block centerBlock = clickedBlock; - //sink through a snow layer - if(centerBlock.getType() == Material.SNOW) - { - centerBlock = centerBlock.getRelative(BlockFace.DOWN); - } - int maxHeight = centerBlock.getY(); int minx = centerBlock.getX() - playerData.fillRadius; int maxx = centerBlock.getX() + playerData.fillRadius; @@ -1217,8 +1232,8 @@ class PlayerEventHandler implements Listener break; } - //only replace air, spilling water, snow - if(block.getType() == Material.AIR || block.getType() == Material.SNOW || (block.getType() == Material.STATIONARY_WATER && block.getData() != 0)) + //only replace air, spilling water, snow, long grass + if(block.getType() == Material.AIR || block.getType() == Material.SNOW || (block.getType() == Material.STATIONARY_WATER && block.getData() != 0) || block.getType() == Material.LONG_GRASS) { //look to neighbors for an appropriate fill block Block eastBlock = block.getRelative(BlockFace.EAST);