This commit is contained in:
Ryan Hamshire 2012-07-17 19:06:17 -07:00
parent 341e200c42
commit 098a8c557f
5 changed files with 71 additions and 19 deletions

View File

@ -1,41 +1,50 @@
name: GriefPrevention
main: me.ryanhamshire.GriefPrevention.GriefPrevention
softdepend: [Vault, Multiverse-Core]
version: 5.2
softdepend: [Vault, Multiverse-Core, My Worlds]
version: 5.3
commands:
abandonclaim:
description: Deletes a claim.
usage: /AbandonClaim
permission: griefprevention.claims
abandontoplevelclaim:
description: Deletes a claim and all its subdivisions.
usage: /AbandonTopLevelClaim
permission: griefprevention.claims
abandonallclaims:
description: Deletes ALL your claims.
usage: /AbandonAllClaims
permission: griefprevention.claims
trust:
description: Grants a player full access to your claim(s).
usage: /Trust <player> Graants a player permission to build. See also /UnTrust, /ContainerTrust, /AccessTrust, and /PermissionTrust.
aliases: t
permission: griefprevention.claims
untrust:
description: Revokes a player's access to your claim(s).
usage: /UnTrust <player>
aliases: ut
permission: griefprevention.claims
containertrust:
description: Grants a player access to your containers.
usage: /ContainerTrust <player>. Grants a player access to your inventory, bed, and buttons/levers.
aliases: ct
permission: griefprevention.claims
accesstrust:
description: Grants a player entry to your claim(s) and use of your bed.
usage: /AccessTrust <player>. Grants a player access to your bed, buttons, and levers.
aliases: at
permission: griefprevention.claims
permissiontrust:
description: Grants a player permission to grant his level of permission to others.
usage: /PermissionTrust <player>. Permits a player to share his permission level with others.
aliases: pt
permission: griefprevention.claims
subdivideclaims:
description: Switches the shovel tool to subdivision mode, used to subdivide your claims.
usage: /SubdivideClaims
aliases: sc
permission: griefprevention.claims
adjustbonusclaimblocks:
description: Adds or subtracts bonus claim blocks for a player.
usage: /AdjustBonusClaimBlocks <player> <amount>
@ -74,20 +83,24 @@ commands:
description: Switches the shovel tool back to basic claims mode.
usage: /BasicClaims
aliases: bc
permission: griefprevention.claims
buyclaimblocks:
description: Purchases additional claim blocks with server money. Doesn't work on servers without a Vault-compatible economy plugin.
usage: /BuyClaimBlocks <numberOfBlocks>
aliases: buyclaim
aliases: buyclaim
permission: griefprevention.claims
sellclaimblocks:
description: Sells your claim blocks for server money. Doesn't work on servers without a Vault-compatible economy plugin.
usage: /SellClaimBlocks <numberOfBlocks>
aliases: sellclaim
permission: griefprevention.claims
trapped:
description: Ejects you to nearby unclaimed land. Has a substantial cooldown period.
usage: /Trapped
trustlist:
description: Lists permissions for the claim you're standing in.
usage: /TrustList
permission: griefprevention.claims
siege:
description: Initiates a siege versus another player.
usage: /Siege <playerName>
@ -154,4 +167,7 @@ permissions:
default: op
griefprevention.deathblow:
description: Grants access to /DeathBlow.
default: op
default: op
griefprevention.claims:
description: Grants access to claim-related slash commands.
default: true

View File

@ -704,6 +704,9 @@ public class Claim
//admin claims aren't restricted
if(this.isAdminClaim()) return null;
//don't apply this rule to very large claims
if(this.getArea() > 10000) return null;
//determine maximum allowable entity count, based on claim size
int maxEntities = this.getArea() / 50;
if(maxEntities == 0) return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForEntities);

View File

@ -297,7 +297,7 @@ class EntityEventHandler implements Listener
}
//when an entity is damaged
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamage (EntityDamageEvent event)
{
//only actually interested in entities damaging entities (ignoring environmental damage)

View File

@ -117,12 +117,17 @@ public class GriefPrevention extends JavaPlugin
public boolean config_addItemsToClaimedChests; //whether players may add items to claimed chests by left-clicking them
public boolean config_eavesdrop; //whether whispered messages will be visible to administrators
public ArrayList<String> config_eavesdrop_whisperCommands; //list of whisper commands to eavesdrop on
public boolean config_smartBan; //whether to ban accounts which very likely owned by a banned player
public boolean config_endermenMoveBlocks; //whether or not endermen may move blocks around
public boolean config_creaturesTrampleCrops; //whether or not non-player entities may trample crops
public List<Integer> config_mods_accessTrustIds; //list of block IDs which should require /accesstrust for player interaction
public List<Integer> config_mods_containerTrustIds; //list of block IDs which should require /containertrust for player interaction
public List<String> config_mods_ignoreClaimsAccounts; //list of player names which ALWAYS ignore claims
//reference to the economy plugin, if economy integration is enabled
public static Economy economy = null;
@ -260,12 +265,22 @@ public class GriefPrevention extends JavaPlugin
this.config_addItemsToClaimedChests = config.getBoolean("GriefPrevention.AddItemsToClaimedChests", true);
this.config_eavesdrop = config.getBoolean("GriefPrevention.EavesdropEnabled", false);
String whisperCommandsToMonitor = config.getString("GriefPrevention.WhisperCommands", "/tell;/pm;/r");
this.config_smartBan = config.getBoolean("GriefPrevention.SmartBan", true);
this.config_endermenMoveBlocks = config.getBoolean("GriefPrevention.EndermenMoveBlocks", false);
this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", false);
this.config_mods_accessTrustIds = config.getIntegerList("GriefPrevention.Mods.BlockIdsRequiringAccessTrust");
if(this.config_mods_accessTrustIds == null) this.config_mods_accessTrustIds = new ArrayList<Integer>();
this.config_mods_accessTrustIds = config.getIntegerList("GriefPrevention.Mods.BlockIdsRequiringContainerTrust");
if(this.config_mods_containerTrustIds == null) this.config_mods_containerTrustIds = new ArrayList<Integer>();
this.config_mods_ignoreClaimsAccounts = config.getStringList("GriefPrevention.Mods.PlayersIgnoringAllClaims");
if(this.config_mods_ignoreClaimsAccounts == null) this.config_mods_ignoreClaimsAccounts = new ArrayList<String>();
//default for claim investigation tool
String investigationToolMaterialName = Material.STICK.name();
@ -420,6 +435,7 @@ public class GriefPrevention extends JavaPlugin
config.set("GriefPrevention.AddItemsToClaimedChests", this.config_addItemsToClaimedChests);
config.set("GriefPrevention.EavesdropEnabled", this.config_eavesdrop);
config.set("GriefPrevention.WhisperCommands", whisperCommandsToMonitor);
config.set("GriefPrevention.SmartBan", this.config_smartBan);
config.set("GriefPrevention.Siege.Worlds", siegeEnabledWorldNames);
@ -432,6 +448,10 @@ public class GriefPrevention extends JavaPlugin
config.set("GriefPrevention.Database.UserName", databaseUserName);
config.set("GriefPrevention.Database.Password", databasePassword);
config.set("GriefPrevention.Mods.BlockIdsRequiringAccessTrust", this.config_mods_accessTrustIds);
config.set("GriefPrevention.Mods.BlockIdsRequiringContainerTrust", this.config_mods_containerTrustIds);
config.set("GriefPrevention.Mods.PlayersIgnoringAllClaims", this.config_mods_ignoreClaimsAccounts);
try
{
config.save(DataStore.configFilePath);
@ -449,6 +469,14 @@ public class GriefPrevention extends JavaPlugin
this.config_spam_monitorSlashCommands.add(commands[i].trim());
}
//try to parse the list of commands which should be monitored for spam
this.config_eavesdrop_whisperCommands = new ArrayList<String>();
commands = whisperCommandsToMonitor.split(";");
for(int i = 0; i < commands.length; i++)
{
this.config_eavesdrop_whisperCommands.add(commands[i].trim());
}
//when datastore initializes, it loads player and claim data, and posts some stats to the log
if(databaseUrl.length() > 0)
{
@ -2080,8 +2108,8 @@ public class GriefPrevention extends JavaPlugin
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
//exception: administrators in ignore claims mode
if(playerData.ignoreClaims) return null;
//exception: administrators in ignore claims mode and special player accounts created by server mods
if(playerData.ignoreClaims || GriefPrevention.instance.config_mods_ignoreClaimsAccounts.contains(player.getName())) return null;
//wilderness rules
if(claim == null)
@ -2120,8 +2148,8 @@ public class GriefPrevention extends JavaPlugin
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
//exception: administrators in ignore claims mode
if(playerData.ignoreClaims) return null;
//exception: administrators in ignore claims mode, and special player accounts created by server mods
if(playerData.ignoreClaims || GriefPrevention.instance.config_mods_ignoreClaimsAccounts.contains(player.getName())) return null;
//wilderness rules
if(claim == null)

View File

@ -308,22 +308,20 @@ class PlayerEventHandler implements Listener
return false;
}
//when a player uses a slash command, monitor for spam
//when a player uses a slash command...
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
void onPlayerCommandPreprocess (PlayerCommandPreprocessEvent event)
{
if(!GriefPrevention.instance.config_spam_enabled) return;
//if the slash command used is in the list of monitored commands, treat it like a chat message (see above)
String [] args = event.getMessage().split(" ");
if(GriefPrevention.instance.config_spam_monitorSlashCommands.contains(args[0])) this.onPlayerChat(event);
if(GriefPrevention.instance.config_eavesdrop && args[0].equalsIgnoreCase("/tell") && !event.getPlayer().hasPermission("griefprevention.eavesdrop") && args.length > 2)
//if eavesdrop enabled, eavesdrop
String command = args[0].toLowerCase();
if(GriefPrevention.instance.config_eavesdrop && GriefPrevention.instance.config_eavesdrop_whisperCommands.contains(command) && !event.getPlayer().hasPermission("griefprevention.eavesdrop") && args.length > 1)
{
StringBuilder logMessageBuilder = new StringBuilder();
logMessageBuilder.append("[").append(event.getPlayer().getName()).append(" > ").append(args[1]).append("] ");
logMessageBuilder.append("[[").append(event.getPlayer().getName()).append("]] ");
for(int i = 2; i < args.length; i++)
for(int i = 1; i < args.length; i++)
{
logMessageBuilder.append(args[i]).append(" ");
}
@ -342,6 +340,12 @@ class PlayerEventHandler implements Listener
}
}
}
//if anti spam enabled, check for spam
if(!GriefPrevention.instance.config_spam_enabled) return;
//if the slash command used is in the list of monitored commands, treat it like a chat message (see above)
if(GriefPrevention.instance.config_spam_monitorSlashCommands.contains(args[0])) this.onPlayerChat(event);
}
//when a player attempts to join the server...
@ -878,7 +882,8 @@ class PlayerEventHandler implements Listener
clickedBlockType == Material.BREWING_STAND ||
clickedBlockType == Material.WORKBENCH ||
clickedBlockType == Material.JUKEBOX ||
clickedBlockType == Material.ENCHANTMENT_TABLE)))
clickedBlockType == Material.ENCHANTMENT_TABLE ||
GriefPrevention.instance.config_mods_containerTrustIds.contains(clickedBlock.getTypeId()))))
{
//block container use while under siege, so players can't hide items from attackers
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
@ -936,7 +941,7 @@ class PlayerEventHandler implements Listener
}
//otherwise apply rules for buttons and switches
else if(GriefPrevention.instance.config_claims_preventButtonsSwitches && (clickedBlockType == null || clickedBlockType == Material.STONE_BUTTON || clickedBlockType == Material.LEVER))
else if(GriefPrevention.instance.config_claims_preventButtonsSwitches && (clickedBlockType == null || clickedBlockType == Material.STONE_BUTTON || clickedBlockType == Material.LEVER || GriefPrevention.instance.config_mods_accessTrustIds.contains(clickedBlock.getTypeId())))
{
Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, null);
if(claim != null)