Extend eco disable option to block eco lookups. This can be required to combat slow SQL economies.

This option is not recommended under normal circumstances.
This commit is contained in:
KHobbits 2013-08-28 17:50:28 +01:00
parent 3fb4d1f3bf
commit eca3be5cf3
2 changed files with 48 additions and 12 deletions

View File

@ -518,6 +518,7 @@ public class Settings implements net.ess3.api.ISettings
economyLagWarning = _getEconomyLagWarning(); economyLagWarning = _getEconomyLagWarning();
economyLog = _isEcoLogEnabled(); economyLog = _isEcoLogEnabled();
economyLogUpdate = _isEcoLogUpdateEnabled(); economyLogUpdate = _isEcoLogUpdateEnabled();
economyDisabled = _isEcoDisabled();
} }
private List<Integer> itemSpawnBl = new ArrayList<Integer>(); private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@ -650,12 +651,18 @@ public class Settings implements net.ess3.api.ISettings
{ {
return config.getBoolean("trade-in-stacks-" + id, false); return config.getBoolean("trade-in-stacks-" + id, false);
} }
// #easteregg // #easteregg
private boolean economyDisabled = false;
public boolean _isEcoDisabled()
{
return config.getBoolean("disable-eco", false);
}
@Override @Override
public boolean isEcoDisabled() public boolean isEcoDisabled()
{ {
return config.getBoolean("disable-eco", false); return economyDisabled;
} }
@Override @Override

View File

@ -49,8 +49,9 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
{ {
afkPosition = getLocation(); afkPosition = getLocation();
} }
if (isOnline()) { if (isOnline())
lastOnlineActivity = System.currentTimeMillis(); {
lastOnlineActivity = System.currentTimeMillis();
} }
} }
@ -240,12 +241,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
teleportRequestTime = System.currentTimeMillis(); teleportRequestTime = System.currentTimeMillis();
teleportRequester = player == null ? null : player.getName(); teleportRequester = player == null ? null : player.getName();
teleportRequestHere = here; teleportRequestHere = here;
if (player == null) { if (player == null)
{
teleportLocation = null; teleportLocation = null;
} }
else { else
{
teleportLocation = here ? player.getLocation() : this.getLocation(); teleportLocation = here ? player.getLocation() : this.getLocation();
} }
} }
public String getTeleportRequest() public String getTeleportRequest()
@ -257,7 +260,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
{ {
return teleportRequestHere; return teleportRequestHere;
} }
public Location getTpRequestLocation() public Location getTpRequestLocation()
{ {
return teleportLocation; return teleportLocation;
@ -392,6 +395,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
private BigDecimal _getMoney() private BigDecimal _getMoney()
{ {
if (ess.getSettings().isEcoDisabled())
{
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Internal economy functions disabled, aborting balance check.");
}
return BigDecimal.ZERO;
}
if (ess.getPaymentMethod().hasMethod()) if (ess.getPaymentMethod().hasMethod())
{ {
try try
@ -414,6 +425,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
@Override @Override
public void setMoney(final BigDecimal value) public void setMoney(final BigDecimal value)
{ {
if (ess.getSettings().isEcoDisabled())
{
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Internal economy functions disabled, aborting balance change.");
}
return;
}
if (ess.getPaymentMethod().hasMethod()) if (ess.getPaymentMethod().hasMethod())
{ {
try try
@ -436,6 +455,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
public void updateMoneyCache(final BigDecimal value) public void updateMoneyCache(final BigDecimal value)
{ {
if (ess.getSettings().isEcoDisabled())
{
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Internal economy functions disabled, aborting balance sync.");
}
return;
}
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value) if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
{ {
super.setMoney(value); super.setMoney(value);
@ -765,14 +792,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
{ {
this.recipeSee = recipeSee; this.recipeSee = recipeSee;
} }
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message)
if (!message.isEmpty()) { {
if (!message.isEmpty())
{
base.sendMessage(message); base.sendMessage(message);
} }
} }
@Override @Override
public void setReplyTo(final CommandSender user) public void setReplyTo(final CommandSender user)
{ {