2016-07-26 17:23:34 +02:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2020-08-11 20:09:22 +02:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2016-07-26 17:23:34 +02:00
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import org.bukkit.Server;
|
|
|
|
|
2020-04-25 14:08:57 +02:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
2020-08-11 20:09:22 +02:00
|
|
|
public class Commandpaytoggle extends EssentialsToggleCommand {
|
2016-07-26 17:23:34 +02:00
|
|
|
|
|
|
|
public Commandpaytoggle() {
|
2020-08-11 20:09:22 +02:00
|
|
|
super("paytoggle", "essentials.paytoggle.others");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-10-03 19:46:05 +02:00
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
2020-08-11 20:09:22 +02:00
|
|
|
toggleOtherPlayers(server, sender, args);
|
2016-07-26 17:23:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-10-03 19:46:05 +02:00
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
2016-07-26 17:23:34 +02:00
|
|
|
if (commandLabel.contains("payon")) {
|
2020-08-11 20:09:22 +02:00
|
|
|
togglePlayer(user.getSource(), user, true);
|
2016-07-26 17:23:34 +02:00
|
|
|
} else if (commandLabel.contains("payoff")) {
|
2020-08-11 20:09:22 +02:00
|
|
|
togglePlayer(user.getSource(), user, false);
|
2016-07-26 17:23:34 +02:00
|
|
|
} else {
|
2020-08-11 20:09:22 +02:00
|
|
|
handleToggleWithArgs(server, user, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-10-03 19:46:05 +02:00
|
|
|
void togglePlayer(final CommandSource sender, final User user, Boolean enabled) {
|
2020-08-11 20:09:22 +02:00
|
|
|
if (enabled == null) {
|
|
|
|
enabled = !user.isAcceptingPay();
|
|
|
|
}
|
|
|
|
|
|
|
|
user.setAcceptingPay(enabled);
|
|
|
|
|
2020-09-07 17:53:16 +02:00
|
|
|
user.sendMessage(enabled ? tl("payToggleOn") : tl("payToggleOff"));
|
2020-08-11 20:09:22 +02:00
|
|
|
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
2020-09-07 17:53:16 +02:00
|
|
|
sender.sendMessage(enabled ? tl("payEnabledFor", user.getDisplayName()) : tl("payDisabledFor", user.getDisplayName()));
|
2016-07-26 17:23:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|