Improve econ debugging

This commit is contained in:
Magnus Ulf 2019-01-22 15:48:56 +01:00
parent 80b86a5b52
commit 2204cd2321
2 changed files with 15 additions and 8 deletions

View File

@ -97,7 +97,7 @@ public class Money
public static boolean exists(Object account)
{
if (disabled()) return false;
return mixin.exists(accountId(account).toString());
return mixin.exists(accountId(account));
}
public static boolean create(Object account)

View File

@ -115,7 +115,7 @@ public class MoneyMixinVault extends MoneyMixinAbstract
@Override
public boolean exists(String accountId)
{
return this.getEconomy().hasAccount(IdUtil.getOfflinePlayer(accountId));
return this.getEconomy().hasAccount(getOfflinePlayer(accountId));
}
@Override
@ -132,14 +132,14 @@ public class MoneyMixinVault extends MoneyMixinAbstract
public double get(String accountId)
{
this.ensureExists(accountId);
return this.getEconomy().getBalance(IdUtil.getOfflinePlayer(accountId));
return this.getEconomy().getBalance(getOfflinePlayer(accountId));
}
@Override
public boolean has(String accountId, double amount)
{
this.ensureExists(accountId);
return this.getEconomy().has(IdUtil.getOfflinePlayer(accountId), amount);
return this.getEconomy().has(getOfflinePlayer(accountId), amount);
}
// -------------------------------------------- //
@ -201,16 +201,23 @@ public class MoneyMixinVault extends MoneyMixinAbstract
{
Economy economy = this.getEconomy();
if (economy.hasAccount(IdUtil.getOfflinePlayer(accountId))) return true;
if (economy.hasAccount(getOfflinePlayer(accountId))) return true;
if (!economy.createPlayerAccount(IdUtil.getOfflinePlayer(accountId))) return false;
if (!economy.createPlayerAccount(getOfflinePlayer(accountId))) return false;
if (MUtil.isUuid(accountId)) return true;
double balance = economy.getBalance(IdUtil.getOfflinePlayer(accountId));
economy.withdrawPlayer(IdUtil.getOfflinePlayer(accountId), balance);
double balance = economy.getBalance(getOfflinePlayer(accountId));
economy.withdrawPlayer(getOfflinePlayer(accountId), balance);
return true;
}
public static OfflinePlayer getOfflinePlayer(String accountId)
{
OfflinePlayer ret = IdUtil.getOfflinePlayer(accountId);
if (ret == null) throw new RuntimeException("couldn't get offlineplayer for: " + accountId);
return ret;
}
}