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-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
|
2021-02-20 17:37:16 +01:00
|
|
|
protected 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);
|
|
|
|
|
2024-02-03 21:38:14 +01:00
|
|
|
user.sendTl(enabled ? "payToggleOn" : "payToggleOff");
|
2020-08-11 20:09:22 +02:00
|
|
|
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
2024-02-10 05:01:20 +01:00
|
|
|
sender.sendTl(enabled ? "payEnabledFor" : "payDisabledFor", user.getDisplayName());
|
2016-07-26 17:23:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|