mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-05 13:31:37 +00:00
Correctly charge for the use of commands.
We now first test, if the user could pay it, do the stuff and then charge him. If the command throws an exception, the user will not be charged.
This commit is contained in:
parent
610a713997
commit
6427a93d14
66 changed files with 40 additions and 347 deletions
|
@ -79,7 +79,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
|||
@Override
|
||||
public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
run(server, user, commandLabel, args);
|
||||
charge.charge(user);
|
||||
}
|
||||
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
|
@ -111,13 +114,4 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
|||
}
|
||||
return bldr.toString();
|
||||
}
|
||||
|
||||
protected void charge(final CommandSender sender) throws ChargeException
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.charge(ess.getUser((Player)sender));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue