5.3
This commit is contained in:
parent
341e200c42
commit
098a8c557f
24
plugin.yml
24
plugin.yml
|
|
@ -1,41 +1,50 @@
|
||||||
name: GriefPrevention
|
name: GriefPrevention
|
||||||
main: me.ryanhamshire.GriefPrevention.GriefPrevention
|
main: me.ryanhamshire.GriefPrevention.GriefPrevention
|
||||||
softdepend: [Vault, Multiverse-Core]
|
softdepend: [Vault, Multiverse-Core, My Worlds]
|
||||||
version: 5.2
|
version: 5.3
|
||||||
commands:
|
commands:
|
||||||
abandonclaim:
|
abandonclaim:
|
||||||
description: Deletes a claim.
|
description: Deletes a claim.
|
||||||
usage: /AbandonClaim
|
usage: /AbandonClaim
|
||||||
|
permission: griefprevention.claims
|
||||||
abandontoplevelclaim:
|
abandontoplevelclaim:
|
||||||
description: Deletes a claim and all its subdivisions.
|
description: Deletes a claim and all its subdivisions.
|
||||||
usage: /AbandonTopLevelClaim
|
usage: /AbandonTopLevelClaim
|
||||||
|
permission: griefprevention.claims
|
||||||
abandonallclaims:
|
abandonallclaims:
|
||||||
description: Deletes ALL your claims.
|
description: Deletes ALL your claims.
|
||||||
usage: /AbandonAllClaims
|
usage: /AbandonAllClaims
|
||||||
|
permission: griefprevention.claims
|
||||||
trust:
|
trust:
|
||||||
description: Grants a player full access to your claim(s).
|
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.
|
usage: /Trust <player> Graants a player permission to build. See also /UnTrust, /ContainerTrust, /AccessTrust, and /PermissionTrust.
|
||||||
aliases: t
|
aliases: t
|
||||||
|
permission: griefprevention.claims
|
||||||
untrust:
|
untrust:
|
||||||
description: Revokes a player's access to your claim(s).
|
description: Revokes a player's access to your claim(s).
|
||||||
usage: /UnTrust <player>
|
usage: /UnTrust <player>
|
||||||
aliases: ut
|
aliases: ut
|
||||||
|
permission: griefprevention.claims
|
||||||
containertrust:
|
containertrust:
|
||||||
description: Grants a player access to your containers.
|
description: Grants a player access to your containers.
|
||||||
usage: /ContainerTrust <player>. Grants a player access to your inventory, bed, and buttons/levers.
|
usage: /ContainerTrust <player>. Grants a player access to your inventory, bed, and buttons/levers.
|
||||||
aliases: ct
|
aliases: ct
|
||||||
|
permission: griefprevention.claims
|
||||||
accesstrust:
|
accesstrust:
|
||||||
description: Grants a player entry to your claim(s) and use of your bed.
|
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.
|
usage: /AccessTrust <player>. Grants a player access to your bed, buttons, and levers.
|
||||||
aliases: at
|
aliases: at
|
||||||
|
permission: griefprevention.claims
|
||||||
permissiontrust:
|
permissiontrust:
|
||||||
description: Grants a player permission to grant his level of permission to others.
|
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.
|
usage: /PermissionTrust <player>. Permits a player to share his permission level with others.
|
||||||
aliases: pt
|
aliases: pt
|
||||||
|
permission: griefprevention.claims
|
||||||
subdivideclaims:
|
subdivideclaims:
|
||||||
description: Switches the shovel tool to subdivision mode, used to subdivide your claims.
|
description: Switches the shovel tool to subdivision mode, used to subdivide your claims.
|
||||||
usage: /SubdivideClaims
|
usage: /SubdivideClaims
|
||||||
aliases: sc
|
aliases: sc
|
||||||
|
permission: griefprevention.claims
|
||||||
adjustbonusclaimblocks:
|
adjustbonusclaimblocks:
|
||||||
description: Adds or subtracts bonus claim blocks for a player.
|
description: Adds or subtracts bonus claim blocks for a player.
|
||||||
usage: /AdjustBonusClaimBlocks <player> <amount>
|
usage: /AdjustBonusClaimBlocks <player> <amount>
|
||||||
|
|
@ -74,20 +83,24 @@ commands:
|
||||||
description: Switches the shovel tool back to basic claims mode.
|
description: Switches the shovel tool back to basic claims mode.
|
||||||
usage: /BasicClaims
|
usage: /BasicClaims
|
||||||
aliases: bc
|
aliases: bc
|
||||||
|
permission: griefprevention.claims
|
||||||
buyclaimblocks:
|
buyclaimblocks:
|
||||||
description: Purchases additional claim blocks with server money. Doesn't work on servers without a Vault-compatible economy plugin.
|
description: Purchases additional claim blocks with server money. Doesn't work on servers without a Vault-compatible economy plugin.
|
||||||
usage: /BuyClaimBlocks <numberOfBlocks>
|
usage: /BuyClaimBlocks <numberOfBlocks>
|
||||||
aliases: buyclaim
|
aliases: buyclaim
|
||||||
|
permission: griefprevention.claims
|
||||||
sellclaimblocks:
|
sellclaimblocks:
|
||||||
description: Sells your claim blocks for server money. Doesn't work on servers without a Vault-compatible economy plugin.
|
description: Sells your claim blocks for server money. Doesn't work on servers without a Vault-compatible economy plugin.
|
||||||
usage: /SellClaimBlocks <numberOfBlocks>
|
usage: /SellClaimBlocks <numberOfBlocks>
|
||||||
aliases: sellclaim
|
aliases: sellclaim
|
||||||
|
permission: griefprevention.claims
|
||||||
trapped:
|
trapped:
|
||||||
description: Ejects you to nearby unclaimed land. Has a substantial cooldown period.
|
description: Ejects you to nearby unclaimed land. Has a substantial cooldown period.
|
||||||
usage: /Trapped
|
usage: /Trapped
|
||||||
trustlist:
|
trustlist:
|
||||||
description: Lists permissions for the claim you're standing in.
|
description: Lists permissions for the claim you're standing in.
|
||||||
usage: /TrustList
|
usage: /TrustList
|
||||||
|
permission: griefprevention.claims
|
||||||
siege:
|
siege:
|
||||||
description: Initiates a siege versus another player.
|
description: Initiates a siege versus another player.
|
||||||
usage: /Siege <playerName>
|
usage: /Siege <playerName>
|
||||||
|
|
@ -154,4 +167,7 @@ permissions:
|
||||||
default: op
|
default: op
|
||||||
griefprevention.deathblow:
|
griefprevention.deathblow:
|
||||||
description: Grants access to /DeathBlow.
|
description: Grants access to /DeathBlow.
|
||||||
default: op
|
default: op
|
||||||
|
griefprevention.claims:
|
||||||
|
description: Grants access to claim-related slash commands.
|
||||||
|
default: true
|
||||||
|
|
@ -704,6 +704,9 @@ public class Claim
|
||||||
//admin claims aren't restricted
|
//admin claims aren't restricted
|
||||||
if(this.isAdminClaim()) return null;
|
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
|
//determine maximum allowable entity count, based on claim size
|
||||||
int maxEntities = this.getArea() / 50;
|
int maxEntities = this.getArea() / 50;
|
||||||
if(maxEntities == 0) return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForEntities);
|
if(maxEntities == 0) return GriefPrevention.instance.dataStore.getMessage(Messages.ClaimTooSmallForEntities);
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ class EntityEventHandler implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
//when an entity is damaged
|
//when an entity is damaged
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onEntityDamage (EntityDamageEvent event)
|
public void onEntityDamage (EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
//only actually interested in entities damaging entities (ignoring environmental damage)
|
//only actually interested in entities damaging entities (ignoring environmental damage)
|
||||||
|
|
|
||||||
|
|
@ -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_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 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_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_endermenMoveBlocks; //whether or not endermen may move blocks around
|
||||||
public boolean config_creaturesTrampleCrops; //whether or not non-player entities may trample crops
|
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
|
//reference to the economy plugin, if economy integration is enabled
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
|
|
||||||
|
|
@ -260,12 +265,22 @@ public class GriefPrevention extends JavaPlugin
|
||||||
|
|
||||||
this.config_addItemsToClaimedChests = config.getBoolean("GriefPrevention.AddItemsToClaimedChests", true);
|
this.config_addItemsToClaimedChests = config.getBoolean("GriefPrevention.AddItemsToClaimedChests", true);
|
||||||
this.config_eavesdrop = config.getBoolean("GriefPrevention.EavesdropEnabled", false);
|
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_smartBan = config.getBoolean("GriefPrevention.SmartBan", true);
|
||||||
|
|
||||||
this.config_endermenMoveBlocks = config.getBoolean("GriefPrevention.EndermenMoveBlocks", false);
|
this.config_endermenMoveBlocks = config.getBoolean("GriefPrevention.EndermenMoveBlocks", false);
|
||||||
this.config_creaturesTrampleCrops = config.getBoolean("GriefPrevention.CreaturesTrampleCrops", 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
|
//default for claim investigation tool
|
||||||
String investigationToolMaterialName = Material.STICK.name();
|
String investigationToolMaterialName = Material.STICK.name();
|
||||||
|
|
||||||
|
|
@ -420,6 +435,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
config.set("GriefPrevention.AddItemsToClaimedChests", this.config_addItemsToClaimedChests);
|
config.set("GriefPrevention.AddItemsToClaimedChests", this.config_addItemsToClaimedChests);
|
||||||
|
|
||||||
config.set("GriefPrevention.EavesdropEnabled", this.config_eavesdrop);
|
config.set("GriefPrevention.EavesdropEnabled", this.config_eavesdrop);
|
||||||
|
config.set("GriefPrevention.WhisperCommands", whisperCommandsToMonitor);
|
||||||
config.set("GriefPrevention.SmartBan", this.config_smartBan);
|
config.set("GriefPrevention.SmartBan", this.config_smartBan);
|
||||||
|
|
||||||
config.set("GriefPrevention.Siege.Worlds", siegeEnabledWorldNames);
|
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.UserName", databaseUserName);
|
||||||
config.set("GriefPrevention.Database.Password", databasePassword);
|
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
|
try
|
||||||
{
|
{
|
||||||
config.save(DataStore.configFilePath);
|
config.save(DataStore.configFilePath);
|
||||||
|
|
@ -449,6 +469,14 @@ public class GriefPrevention extends JavaPlugin
|
||||||
this.config_spam_monitorSlashCommands.add(commands[i].trim());
|
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
|
//when datastore initializes, it loads player and claim data, and posts some stats to the log
|
||||||
if(databaseUrl.length() > 0)
|
if(databaseUrl.length() > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2080,8 +2108,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||||
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
|
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
|
||||||
|
|
||||||
//exception: administrators in ignore claims mode
|
//exception: administrators in ignore claims mode and special player accounts created by server mods
|
||||||
if(playerData.ignoreClaims) return null;
|
if(playerData.ignoreClaims || GriefPrevention.instance.config_mods_ignoreClaimsAccounts.contains(player.getName())) return null;
|
||||||
|
|
||||||
//wilderness rules
|
//wilderness rules
|
||||||
if(claim == null)
|
if(claim == null)
|
||||||
|
|
@ -2120,8 +2148,8 @@ public class GriefPrevention extends JavaPlugin
|
||||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||||
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
|
Claim claim = this.dataStore.getClaimAt(location, false, playerData.lastClaim);
|
||||||
|
|
||||||
//exception: administrators in ignore claims mode
|
//exception: administrators in ignore claims mode, and special player accounts created by server mods
|
||||||
if(playerData.ignoreClaims) return null;
|
if(playerData.ignoreClaims || GriefPrevention.instance.config_mods_ignoreClaimsAccounts.contains(player.getName())) return null;
|
||||||
|
|
||||||
//wilderness rules
|
//wilderness rules
|
||||||
if(claim == null)
|
if(claim == null)
|
||||||
|
|
|
||||||
|
|
@ -308,22 +308,20 @@ class PlayerEventHandler implements Listener
|
||||||
return false;
|
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)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
void onPlayerCommandPreprocess (PlayerCommandPreprocessEvent event)
|
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(" ");
|
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();
|
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(" ");
|
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...
|
//when a player attempts to join the server...
|
||||||
|
|
@ -878,7 +882,8 @@ class PlayerEventHandler implements Listener
|
||||||
clickedBlockType == Material.BREWING_STAND ||
|
clickedBlockType == Material.BREWING_STAND ||
|
||||||
clickedBlockType == Material.WORKBENCH ||
|
clickedBlockType == Material.WORKBENCH ||
|
||||||
clickedBlockType == Material.JUKEBOX ||
|
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
|
//block container use while under siege, so players can't hide items from attackers
|
||||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||||
|
|
@ -936,7 +941,7 @@ class PlayerEventHandler implements Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
//otherwise apply rules for buttons and switches
|
//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);
|
Claim claim = this.dataStore.getClaimAt(clickedBlock.getLocation(), false, null);
|
||||||
if(claim != null)
|
if(claim != null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user