mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-23 02:35:25 +01:00
Fix a bug with inactive player unrent/sell settings
If the 'inactiveTimeUntilUnrent' or 'inactiveTimeUntilSell' settings would be set to a value above 35000 it would cause an integer overflow, resulting in a 50% chance that all regions will be unrentend/sold (and if that does not happen it will still sell/unrent them too early). This is caused by an integer overflow, switching to long fixed this problem.
This commit is contained in:
parent
40338b66df
commit
00d3256716
@ -218,7 +218,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
* @return The number of minutes until the region is unrented while player is offline
|
||||
*/
|
||||
public long getInactiveTimeUntilSell() {
|
||||
return getIntegerSetting("buy.inactiveTimeUntilSell");
|
||||
return getLongSetting("buy.inactiveTimeUntilSell");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -402,11 +402,11 @@ public class BuyRegion extends GeneralRegion {
|
||||
return false;
|
||||
}
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(getBuyer());
|
||||
//AreaShop.debug("inactive checking for " + getName() + ", player=" + player.getName() + ", currenttime=" + Calendar.getInstance().getTimeInMillis() + ", lastPlayed=" + player.getLastPlayed() + ", diff=" + (Calendar.getInstance().getTimeInMillis() - player.getLastPlayed()));
|
||||
int inactiveSetting = getIntegerSetting("buy.inactiveTimeUntilSell");
|
||||
long inactiveSetting = getInactiveTimeUntilSell();
|
||||
if(inactiveSetting <= 0 || player.isOp()) {
|
||||
return false;
|
||||
}
|
||||
AreaShop.debug("inactivetimemillis: " + inactiveSetting * 60 * 1000);
|
||||
if(Calendar.getInstance().getTimeInMillis() > (player.getLastPlayed() + inactiveSetting * 60 * 1000)) {
|
||||
plugin.getLogger().info("Region " + getName() + " sold because of inactivity for player " + getPlayerName());
|
||||
this.sell(true);
|
||||
|
@ -293,7 +293,7 @@ public class RentRegion extends GeneralRegion {
|
||||
* @return The number of minutes until the region is unrented while player is offline
|
||||
*/
|
||||
public long getInactiveTimeUntilUnrent() {
|
||||
return getIntegerSetting("rent.inactiveTimeUntilUnrent");
|
||||
return getLongSetting("rent.inactiveTimeUntilUnrent");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -603,11 +603,11 @@ public class RentRegion extends GeneralRegion {
|
||||
return false;
|
||||
}
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(getRenter());
|
||||
//AreaShop.debug("inactive checking for " + getName() + ", player=" + player.getName() + ", currenttime=" + Calendar.getInstance().getTimeInMillis() + ", lastPlayed=" + player.getLastPlayed() + ", diff=" + (Calendar.getInstance().getTimeInMillis() - player.getLastPlayed()));
|
||||
int inactiveSetting = getIntegerSetting("rent.inactiveTimeUntilUnrent");
|
||||
long inactiveSetting = getInactiveTimeUntilUnrent();
|
||||
if(inactiveSetting <= 0 || player.isOp()) {
|
||||
return false;
|
||||
}
|
||||
AreaShop.debug("inactivetimemillis: " + inactiveSetting * 60 * 1000);
|
||||
if(Calendar.getInstance().getTimeInMillis() > (player.getLastPlayed() + inactiveSetting * 60 * 1000)) {
|
||||
plugin.getLogger().info("Region " + getName() + " unrented because of inactivity for player " + getPlayerName());
|
||||
this.unRent(true);
|
||||
|
Loading…
Reference in New Issue
Block a user