Add economic entity interfaces

I decided to add these interfaces, instead of just building upon the User & UserData interface, as support for commerce between clans & users might be something that we want to add in the future in Clans.
This commit is contained in:
Allink
2023-05-20 04:54:55 +01:00
parent 2fd2008f65
commit 2f18e4d8ef
5 changed files with 68 additions and 4 deletions

View File

@ -26,6 +26,7 @@ public class SimpleUserData implements UserData
private boolean frozen;
private boolean canInteract;
private boolean caged;
private long balance;
public SimpleUserData(final Player player)
{
@ -42,7 +43,8 @@ public class SimpleUserData implements UserData
final long playtime,
final boolean frozen,
final boolean canInteract,
final boolean caged)
final boolean caged,
final long balance)
{
this.uuid = uuid;
this.username = username;
@ -52,6 +54,7 @@ public class SimpleUserData implements UserData
this.frozen = frozen;
this.canInteract = canInteract;
this.caged = caged;
this.balance = balance;
}
public static SimpleUserData fromSQL(SQL sql, String uuid)
@ -82,7 +85,8 @@ public class SimpleUserData implements UserData
boolean frozen = result.getBoolean("frozen");
boolean canInteract = result.getBoolean("canInteract");
boolean caged = result.getBoolean("caged");
return new SimpleUserData(u, username, user, group, playtime, frozen, canInteract, caged);
long balance = result.getLong("balance");
return new SimpleUserData(u, username, user, group, playtime, frozen, canInteract, caged, balance);
}
} catch (SQLException ex)
{
@ -197,4 +201,28 @@ public class SimpleUserData implements UserData
{
this.caged = caged;
}
@Override
public long getBalance()
{
return balance;
}
@Override
public void addToBalance(long amount)
{
this.balance += amount;
}
@Override
public void removeFromBalance(long amount)
{
this.balance -= amount;
}
@Override
public void setBalance(long newBalance)
{
this.balance = newBalance;
}
}