1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-15 11:04:29 +02:00

Limiting the amount of money a player can have.

The maximum limit is 10 trillions.
This commit is contained in:
snowleo
2011-07-05 23:50:31 +02:00
parent c76958585e
commit 8e043d27c3
3 changed files with 34 additions and 17 deletions

View File

@@ -375,4 +375,14 @@ public class Settings implements IConf
{ {
return config.getBoolean(configName, def); 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;
}
} }

View File

@@ -58,18 +58,20 @@ public abstract class UserData extends PlayerExtension implements IConf
isSocialSpyEnabled = _isSocialSpyEnabled(); isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC(); isNPC = _isNPC();
} }
private double money; private double money;
private double _getMoney() { private double _getMoney()
{
double money = ess.getSettings().getStartingBalance();
if (config.hasProperty("money")) 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() public double getMoney()
@@ -80,6 +82,10 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setMoney(double value) public void setMoney(double value)
{ {
money = value; money = value;
if (Math.abs(money) > ess.getSettings().getMaxMoney())
{
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
}
config.setProperty("money", value); config.setProperty("money", value);
config.save(); config.save();
} }
@@ -92,7 +98,7 @@ public abstract class UserData extends PlayerExtension implements IConf
} }
return false; return false;
} }
public Location getHome(Location location) public Location getHome(Location location)
{ {
if (!hasHome()) if (!hasHome())
@@ -383,6 +389,7 @@ public abstract class UserData extends PlayerExtension implements IConf
setTeleportEnabled(ret); setTeleportEnabled(ret);
return ret; return ret;
} }
public boolean toggleSocialSpy() public boolean toggleSocialSpy()
{ {
boolean ret = !isSocialSpyEnabled(); boolean ret = !isSocialSpyEnabled();
@@ -622,7 +629,6 @@ public abstract class UserData extends PlayerExtension implements IConf
setAfk(ret); setAfk(ret);
return ret; return ret;
} }
private boolean newplayer; private boolean newplayer;
private boolean getNew() private boolean getNew()
@@ -641,7 +647,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("newplayer", set); config.setProperty("newplayer", set);
config.save(); config.save();
} }
private String geolocation; private String geolocation;
private String _getGeoLocation() private String _getGeoLocation()
@@ -668,38 +673,36 @@ public abstract class UserData extends PlayerExtension implements IConf
} }
config.save(); config.save();
} }
private boolean isSocialSpyEnabled; private boolean isSocialSpyEnabled;
private boolean _isSocialSpyEnabled() private boolean _isSocialSpyEnabled()
{ {
return config.getBoolean("socialspy", false); return config.getBoolean("socialspy", false);
} }
public boolean isSocialSpyEnabled() public boolean isSocialSpyEnabled()
{ {
return isSocialSpyEnabled; return isSocialSpyEnabled;
} }
public void setSocialSpyEnabled(boolean status) public void setSocialSpyEnabled(boolean status)
{ {
isSocialSpyEnabled = status; isSocialSpyEnabled = status;
config.setProperty("socialspy", status); config.setProperty("socialspy", status);
config.save(); config.save();
} }
private boolean isNPC; private boolean isNPC;
private boolean _isNPC() private boolean _isNPC()
{ {
return config.getBoolean("npc", false); return config.getBoolean("npc", false);
} }
public boolean isNPC() public boolean isNPC()
{ {
return isNPC; return isNPC;
} }
public void setNPC(boolean set) public void setNPC(boolean set)
{ {
isNPC = set; isNPC = set;

View File

@@ -229,6 +229,10 @@ command-costs:
# Set this to a currency symbol you want to use. # Set this to a currency symbol you want to use.
currency-symbol: '$' 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 | # # | EssentialsHelp | #