mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-04 04:51:41 +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
|
@ -23,16 +23,14 @@ public class Commandnick extends EssentialsCommand
|
|||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
user.sendMessage(Util.i18n("nickDisplayName"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickDisplayName"));
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (!user.isAuthorized("essentials.nick.others"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickOthersPermission"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickOthersPermission"));
|
||||
}
|
||||
|
||||
setOthersNickname(server, user, args);
|
||||
|
@ -51,8 +49,7 @@ public class Commandnick extends EssentialsCommand
|
|||
|
||||
if (nick.matches("[^a-zA-Z_0-9]"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickNamesAlpha"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickNamesAlpha"));
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
|
@ -66,12 +63,10 @@ public class Commandnick extends EssentialsCommand
|
|||
String nk = nick.toLowerCase();
|
||||
if (nk.equals(dn) || nk.equals(n))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickInUse"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickInUse"));
|
||||
}
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setNickname(nick);
|
||||
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue