Add option to enforce a minimum claim size for automatically-generated claims (#1037)
This commit is contained in:
parent
6e055c90c3
commit
74700dc3de
|
|
@ -334,7 +334,7 @@ public class BlockEventHandler implements Listener
|
|||
else
|
||||
{
|
||||
//if failure due to insufficient claim blocks available
|
||||
if (playerData.getRemainingClaimBlocks() < 1)
|
||||
if (playerData.getRemainingClaimBlocks() < Math.pow(1 + 2 * GriefPrevention.instance.config_claims_automaticClaimsForNewPlayersRadiusMin, 2))
|
||||
{
|
||||
GriefPrevention.sendMessage(player, TextMode.Warn, Messages.NoEnoughBlocksForChestClaim);
|
||||
return;
|
||||
|
|
@ -343,7 +343,7 @@ public class BlockEventHandler implements Listener
|
|||
//as long as the automatic claim overlaps another existing claim, shrink it
|
||||
//note that since the player had permission to place the chest, at the very least, the automatic claim will include the chest
|
||||
CreateClaimResult result = null;
|
||||
while (radius >= 0)
|
||||
while (radius >= GriefPrevention.instance.config_claims_automaticClaimsForNewPlayersRadiusMin)
|
||||
{
|
||||
int area = (radius * 2 + 1) * (radius * 2 + 1);
|
||||
if (playerData.getRemainingClaimBlocks() >= area)
|
||||
|
|
@ -363,14 +363,26 @@ public class BlockEventHandler implements Listener
|
|||
radius--;
|
||||
}
|
||||
|
||||
if (result != null && result.succeeded)
|
||||
if (result != null && result.claim != null)
|
||||
{
|
||||
//notify and explain to player
|
||||
GriefPrevention.sendMessage(player, TextMode.Success, Messages.AutomaticClaimNotification);
|
||||
if (result.succeeded)
|
||||
{
|
||||
//notify and explain to player
|
||||
GriefPrevention.sendMessage(player, TextMode.Success, Messages.AutomaticClaimNotification);
|
||||
|
||||
//show the player the protected area
|
||||
Visualization visualization = Visualization.FromClaim(result.claim, block.getY(), VisualizationType.Claim, player.getLocation());
|
||||
Visualization.Apply(player, visualization);
|
||||
//show the player the protected area
|
||||
Visualization visualization = Visualization.FromClaim(result.claim, block.getY(), VisualizationType.Claim, player.getLocation());
|
||||
Visualization.Apply(player, visualization);
|
||||
}
|
||||
else
|
||||
{
|
||||
//notify and explain to player
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.AutomaticClaimOtherClaimTooClose);
|
||||
|
||||
//show the player the protected area
|
||||
Visualization visualization = Visualization.FromClaim(result.claim, block.getY(), VisualizationType.ErrorClaim, player.getLocation());
|
||||
Visualization.Apply(player, visualization);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1574,6 +1574,7 @@ public abstract class DataStore
|
|||
this.addDefault(defaults, Messages.TooDeepToClaim, "This chest can't be protected because it's too deep underground. Consider moving it.", null);
|
||||
this.addDefault(defaults, Messages.ChestClaimConfirmation, "This chest is protected.", null);
|
||||
this.addDefault(defaults, Messages.AutomaticClaimNotification, "This chest and nearby blocks are protected from breakage and theft.", null);
|
||||
this.addDefault(defaults, Messages.AutomaticClaimOtherClaimTooClose, "Cannot create a claim for your chest, there is another claim too close!", null);
|
||||
this.addDefault(defaults, Messages.UnprotectedChestWarning, "This chest is NOT protected. Consider using a golden shovel to expand an existing claim or to create a new one.", null);
|
||||
this.addDefault(defaults, Messages.ThatPlayerPvPImmune, "You can't injure defenseless players.", null);
|
||||
this.addDefault(defaults, Messages.CantFightWhileImmune, "You can't fight someone while you're protected from PvP.", null);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ public class GriefPrevention extends JavaPlugin
|
|||
public int config_claims_expirationExemptionTotalBlocks; //total claim blocks amount which will exempt a player from claim expiration
|
||||
public int config_claims_expirationExemptionBonusBlocks; //bonus claim blocks amount which will exempt a player from claim expiration
|
||||
|
||||
public int config_claims_automaticClaimsForNewPlayersRadius; //how big automatic new player claims (when they place a chest) should be. 0 to disable
|
||||
public int config_claims_automaticClaimsForNewPlayersRadius; //how big automatic new player claims (when they place a chest) should be. -1 to disable
|
||||
public int config_claims_automaticClaimsForNewPlayersRadiusMin; //how big automatic new player claims must be. 0 to disable
|
||||
public int config_claims_claimsExtendIntoGroundDistance; //how far below the shoveled block a new claim will reach
|
||||
public int config_claims_minWidth; //minimum width for non-admin claims
|
||||
public int config_claims_minArea; //minimum area for non-admin claims
|
||||
|
|
@ -570,6 +571,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
this.config_claims_accruedIdlePercent = config.getInt("GriefPrevention.Claims.AccruedIdlePercent", 0);
|
||||
this.config_claims_abandonReturnRatio = config.getDouble("GriefPrevention.Claims.AbandonReturnRatio", 1.0D);
|
||||
this.config_claims_automaticClaimsForNewPlayersRadius = config.getInt("GriefPrevention.Claims.AutomaticNewPlayerClaimsRadius", 4);
|
||||
this.config_claims_automaticClaimsForNewPlayersRadiusMin = Math.max(0, config.getInt("GriefPrevention.Claims.AutomaticNewPlayerClaimsRadiusMinimum", 0));
|
||||
this.config_claims_claimsExtendIntoGroundDistance = Math.abs(config.getInt("GriefPrevention.Claims.ExtendIntoGroundDistance", 5));
|
||||
this.config_claims_minWidth = config.getInt("GriefPrevention.Claims.MinimumWidth", 5);
|
||||
this.config_claims_minArea = config.getInt("GriefPrevention.Claims.MinimumArea", 100);
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ public enum Messages
|
|||
TooDeepToClaim,
|
||||
ChestClaimConfirmation,
|
||||
AutomaticClaimNotification,
|
||||
AutomaticClaimOtherClaimTooClose,
|
||||
UnprotectedChestWarning,
|
||||
ThatPlayerPvPImmune,
|
||||
CantFightWhileImmune,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user