mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-03 14:01:37 +01:00
Limiting the amount of money a player can have.
The maximum limit is 10 trillions.
This commit is contained in:
parent
ae053dea58
commit
f610dd9c72
@ -375,4 +375,14 @@ public class Settings implements IConf
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY) {
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
@ -58,18 +58,20 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
}
|
||||
|
||||
private double money;
|
||||
|
||||
private double _getMoney() {
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
return config.getDouble("money", ess.getSettings().getStartingBalance());
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
else
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
return ess.getSettings().getStartingBalance();
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
@ -80,6 +82,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
@ -92,7 +98,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Location getHome(Location location)
|
||||
{
|
||||
if (!hasHome())
|
||||
@ -383,6 +389,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
@ -622,7 +629,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean newplayer;
|
||||
|
||||
private boolean getNew()
|
||||
@ -641,7 +647,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("newplayer", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
@ -668,38 +673,36 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isNPC;
|
||||
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
|
@ -229,6 +229,10 @@ command-costs:
|
||||
# Set this to a currency symbol you want to use.
|
||||
currency-symbol: '$'
|
||||
|
||||
# Set the maximum amount of money a player can have
|
||||
# The amount is always limited to 10 trillions because of the limitations of a java double
|
||||
max-money: 10000000000000
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | EssentialsHelp | #
|
||||
|
Loading…
Reference in New Issue
Block a user