add configurable threshold for idle detection (#75)
Also fixes the no-movement idle detection.
This commit is contained in:
parent
70469d1b4c
commit
ac319f4e1c
|
|
@ -31,11 +31,13 @@ class DeliverClaimBlocksTask implements Runnable
|
|||
{
|
||||
private Player player;
|
||||
private GriefPrevention instance;
|
||||
private int idleThresholdSquared;
|
||||
|
||||
public DeliverClaimBlocksTask(Player player, GriefPrevention instance)
|
||||
{
|
||||
this.player = player;
|
||||
this.instance = instance;
|
||||
this.idleThresholdSquared = instance.config_claims_accruedIdleThreshold * instance.config_claims_accruedIdleThreshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -72,7 +74,7 @@ class DeliverClaimBlocksTask implements Runnable
|
|||
//if he's not in a vehicle and has moved at least three blocks since the last check
|
||||
//and he's not being pushed around by fluids
|
||||
if(!player.isInsideVehicle() &&
|
||||
(lastLocation == null || lastLocation.distanceSquared(player.getLocation()) >= 0) &&
|
||||
(lastLocation == null || lastLocation.distanceSquared(player.getLocation()) > idleThresholdSquared) &&
|
||||
!player.getLocation().getBlock().isLiquid())
|
||||
{
|
||||
//determine how fast blocks accrue for this player //RoboMWM: addons determine this instead
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
public double config_claims_abandonReturnRatio; //the portion of claim blocks returned to a player when a claim is abandoned
|
||||
public int config_claims_blocksAccruedPerHour_default; //how many additional blocks players get each hour of play (can be zero) without any special permissions
|
||||
public int config_claims_maxAccruedBlocks_default; //the limit on accrued blocks (over time) for players without any special permissions. doesn't limit purchased or admin-gifted blocks
|
||||
public int config_claims_accruedIdleThreshold; //how far (in blocks) a player must move in order to not be considered afk/idle when determining accrued claim blocks
|
||||
public int config_claims_maxDepth; //limit on how deep claims can go
|
||||
public int config_claims_expirationDays; //how many days of inactivity before a player loses his claims
|
||||
public int config_claims_expirationExemptionTotalBlocks; //total claim blocks amount which will exempt a player from claim expiration
|
||||
|
|
@ -537,6 +538,8 @@ public class GriefPrevention extends JavaPlugin
|
|||
this.config_claims_blocksAccruedPerHour_default = config.getInt("GriefPrevention.Claims.Claim Blocks Accrued Per Hour.Default", config_claims_blocksAccruedPerHour_default);
|
||||
this.config_claims_maxAccruedBlocks_default = config.getInt("GriefPrevention.Claims.MaxAccruedBlocks", 2000);
|
||||
this.config_claims_maxAccruedBlocks_default = config.getInt("GriefPrevention.Claims.Max Accrued Claim Blocks.Default", this.config_claims_maxAccruedBlocks_default);
|
||||
this.config_claims_accruedIdleThreshold = config.getInt("GriefPrevention.Claims.AccruedIdleThreshold", 0);
|
||||
this.config_claims_accruedIdleThreshold = config.getInt("GriefPrevention.Claims.Accrued Idle Threshold", this.config_claims_accruedIdleThreshold);
|
||||
this.config_claims_abandonReturnRatio = config.getDouble("GriefPrevention.Claims.AbandonReturnRatio", 1);
|
||||
this.config_claims_automaticClaimsForNewPlayersRadius = config.getInt("GriefPrevention.Claims.AutomaticNewPlayerClaimsRadius", 4);
|
||||
this.config_claims_claimsExtendIntoGroundDistance = Math.abs(config.getInt("GriefPrevention.Claims.ExtendIntoGroundDistance", 5));
|
||||
|
|
@ -788,6 +791,7 @@ public class GriefPrevention extends JavaPlugin
|
|||
outConfig.set("GriefPrevention.Claims.InitialBlocks", this.config_claims_initialBlocks);
|
||||
outConfig.set("GriefPrevention.Claims.Claim Blocks Accrued Per Hour.Default", this.config_claims_blocksAccruedPerHour_default);
|
||||
outConfig.set("GriefPrevention.Claims.Max Accrued Claim Blocks.Default", this.config_claims_maxAccruedBlocks_default);
|
||||
outConfig.set("GriefPrevention.Claims.Accrued Idle Threshold", this.config_claims_accruedIdleThreshold);
|
||||
outConfig.set("GriefPrevention.Claims.AbandonReturnRatio", this.config_claims_abandonReturnRatio);
|
||||
outConfig.set("GriefPrevention.Claims.AutomaticNewPlayerClaimsRadius", this.config_claims_automaticClaimsForNewPlayersRadius);
|
||||
outConfig.set("GriefPrevention.Claims.ExtendIntoGroundDistance", this.config_claims_claimsExtendIntoGroundDistance);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user