EssentialsX

EssentialsX

2M Downloads

Loans Permissions Issue

theianspence opened this issue · 7 comments

commented

Type of bug

Error in console, Other unexpected behaviour

/ess dump all output

https://essentialsx.net/dump.html?id=06b4742153244f14844a2a722d6fd751

Error log (if applicable)

No response

Bug description

I'm using EssentialsX as my Eco and QuickShop to allow users to buy and sell items from each other. QuickShop allows me to create a tax account, using a fake player name. In our case, "Treasury."
All of that works well, on a $100 sale $10 goes to the Treasury and its hunky dory.
However, the server is just starting to get going, and I am loaning money from the Treasury account to our players, so the current balance of the Treasury is $-2000. I noticed that there is an issue where when the Treasury account is below zero, no money gets added to the account.

I talked with the QuickShop support, and we dug around a bit and found this error message:

[2022-01-17 02:00:31.010] {"success":false,"from":"00000000-0000-0000-0009-01fe53f930f2","to":"a811a16e-339e-4fa7-bda2-37d965459b22","currency":null,"tax":52.0,"taxAccount":"2c5f00ba-902c-411b-b9b9-9261cf43aee1","amount":520.0,"lastError":"Failed to deposit tax account: 52.0 error:Loan was not permitted!"}

We determined that it is the loan permission causing the problem. However, I am not sure how to circumvent this. I can't give that Treasury account the loan permission because it's not a real user. Giving it OP didn't work either.

Upon enabling /ess debug, when the transaction takes place, I see this in the console

[Essentials] checking if Tax has essentials.eco.loan - false

I then tried this with a real account, rather than a fake one created with QuickShop, and I'm experiencing the same issue with the loan permission.

Setting the user as an NPC does nothing to solve this.

This is related to the essentials.eco.loan but I'm not sure how to circumvent this.

Steps to reproduce

  1. Install QuickShop and EssentialsX
  2. Make sure tax is enabled and set to a fake account, in our case it's "Treasury"
  3. Ensure that the Treasury account has less than $0 in it. e.g. $-2000
  4. Have two people online, one to make a store and one to buy from the store
  5. Create a store and have the other player purchase something from the store
  6. Money transfers accounts and a tax should be collected (e.g. $5)
  7. Check balance of Treasury, it will still be $-2000 rather than being $-1995.

Expected behaviour

When the Treasury account is in the negatives, an incoming deposit in the form of a tax from QuickShop should increase the balance the Treasury account making it closer to zero.

Say we have an incoming tax of $5 to the Treasury account while the account is at $-2000. We'd expect that the treasury account now has a balance $-1995.

Actual behaviour

When the Treasury account is in the negatives, an incoming tax deposit fails, and thus the balance of the Treasury remains unchanged.

Say we have an incoming tax of $5 to the Treasury account while the account is at $-2000. The account will still have a balance $-2000.

commented

I'm willing to provide a video if you guys think it will assist.

commented

I can confirm this issue with [13:16:38 INFO]: [Essentials] Using Vault based permissions (LuckPerms)
屏幕截图 2022-01-18 132603

commented

It just returns false for all OfflinePlayer hummm....
屏幕截图 2022-01-18 134514

commented

@Override
public boolean isAuthorized(final String node) {
final boolean result = isAuthorizedCheck(node);
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node + " - " + result);
}
return result;
}

private boolean isAuthorizedCheck(final String node) {
if (base instanceof OfflinePlayer) {
return false;
}
try {
return ess.getPermissionsHandler().hasPermission(base, node);
} catch (final Exception ex) {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage(), ex);
} else {
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
}
return false;
}
}
private boolean isPermSetCheck(final String node) {
if (base instanceof OfflinePlayer) {
return false;
}

commented
npc: true
last-account-name: tax
money: '-1000.0'
teleportenabled: true
teleportauto: false
godmode: false
muted: false
jailed: false
ip-address: ''
afk: false
socialspy: false
powertoolsenabled: true
accepting-pay: true
baltop-exempt: false
timestamps:
  lastteleport: 0
  lastheal: 0
  mute: 0
  jail: 0
  onlinejail: 0
  logout: 0
  login: 0
commented

Interesting find!
So it’s always going to be false, as long as the player is offline?

commented

It just returns false for all OfflinePlayer hummm.... 屏幕截图 2022-01-18 134514

Many permission plugins historically haven't supported checking permissions of offline players. Some plugins however do support it, so there may be a reason to revisit that logic.