mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-03 12:31:46 +00:00
Trim stored precision to below that of a double, to prevent rounding issues.
This commit is contained in:
parent
aeb1b4601c
commit
801acbb004
2 changed files with 55 additions and 47 deletions
|
@ -89,12 +89,12 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
money = Util.sanitizeMoney(value);
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.setProperty("money", money);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
@ -122,11 +122,11 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
String search = getHomeName(name);
|
||||
return config.getLocation("homes." + search, getServer());
|
||||
return config.getLocation("homes." + search, getServer());
|
||||
}
|
||||
|
||||
public Location getHome(final Location world)
|
||||
|
@ -318,7 +318,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private Location logoutLocation;
|
||||
|
||||
private Location _getLogoutLocation()
|
||||
|
@ -337,7 +336,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
{
|
||||
return logoutLocation;
|
||||
}
|
||||
|
||||
|
||||
public void setLogoutLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
|
@ -348,7 +347,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
config.setProperty("logoutlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private long lastTeleportTimestamp;
|
||||
|
||||
private long _getLastTeleportTimestamp()
|
||||
|
@ -549,7 +547,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean getMuted()
|
||||
{
|
||||
return muted;
|
||||
|
@ -825,10 +823,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private Map<String, Long> kitTimestamps;
|
||||
|
||||
|
||||
private Map<String, Long> _getKitTimestamps()
|
||||
{
|
||||
|
||||
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
||||
|
@ -848,7 +846,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
}
|
||||
return new HashMap<String, Long>();
|
||||
}
|
||||
|
||||
|
||||
public long getKitTimestamp(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
|
@ -867,32 +865,32 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
}
|
||||
|
||||
public void setConfigProperty(String node, Object object)
|
||||
{
|
||||
final String prefix = "info.";
|
||||
node = prefix+node;
|
||||
if (object instanceof Map)
|
||||
{
|
||||
config.setProperty(node, (Map) object);
|
||||
}
|
||||
else if (object instanceof List)
|
||||
{
|
||||
config.setProperty(node, (List<String>) object);
|
||||
}
|
||||
else if (object instanceof Location)
|
||||
{
|
||||
config.setProperty(node, (Location) object);
|
||||
}
|
||||
else if (object instanceof ItemStack)
|
||||
{
|
||||
config.setProperty(node, (ItemStack) object);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.setProperty(node, object);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
{
|
||||
final String prefix = "info.";
|
||||
node = prefix + node;
|
||||
if (object instanceof Map)
|
||||
{
|
||||
config.setProperty(node, (Map)object);
|
||||
}
|
||||
else if (object instanceof List)
|
||||
{
|
||||
config.setProperty(node, (List<String>)object);
|
||||
}
|
||||
else if (object instanceof Location)
|
||||
{
|
||||
config.setProperty(node, (Location)object);
|
||||
}
|
||||
else if (object instanceof ItemStack)
|
||||
{
|
||||
config.setProperty(node, (ItemStack)object);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.setProperty(node, object);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
public Set<String> getConfigKeys()
|
||||
{
|
||||
if (config.isConfigurationSection("info"))
|
||||
|
@ -901,7 +899,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getConfigMap()
|
||||
{
|
||||
if (config.isConfigurationSection("info"))
|
||||
|
@ -910,16 +908,16 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getConfigMap(String node)
|
||||
{
|
||||
if (config.isConfigurationSection("info."+node))
|
||||
if (config.isConfigurationSection("info." + node))
|
||||
{
|
||||
return config.getConfigurationSection("info."+node).getValues(true);
|
||||
return config.getConfigurationSection("info." + node).getValues(true);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
|
||||
public void save()
|
||||
{
|
||||
config.save();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue