mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-23 12:39:24 +08:00
Make sudo a loop command. Adds #23.
This commit is contained in:
parent
4169996e7a
commit
20f79f117f
@ -1,49 +1,56 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.ChargeException;
|
||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import net.ess3.api.MaxMoneyException;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
|
||||||
|
|
||||||
public class Commandsudo extends EssentialsCommand {
|
public class Commandsudo extends EssentialsLoopCommand {
|
||||||
public Commandsudo() {
|
public Commandsudo() {
|
||||||
super("sudo");
|
super("sudo");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final User user = getPlayer(server, sender, args, 0);
|
|
||||||
if (args[1].toLowerCase(Locale.ENGLISH).startsWith("c:")) {
|
|
||||||
if (user.isAuthorized("essentials.sudo.exempt") && sender.isPlayer()) {
|
|
||||||
throw new Exception(tl("sudoExempt"));
|
|
||||||
}
|
|
||||||
user.getBase().chat(getFinalArg(args, 1).substring(2));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final String[] arguments = new String[args.length - 1];
|
final String[] arguments = new String[args.length - 1];
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.isAuthorized("essentials.sudo.exempt") && sender.isPlayer()) {
|
final String command = getFinalArg(arguments, 0);
|
||||||
throw new Exception(tl("sudoExempt"));
|
boolean multiple = sender.getSender().hasPermission("essentials.sudo.multiple");
|
||||||
|
|
||||||
|
sender.sendMessage(tl("sudoRun", args[0], command, ""));
|
||||||
|
loopOnlinePlayers(server, sender, multiple, multiple, args[0], new String[]{command});
|
||||||
}
|
}
|
||||||
|
|
||||||
final String command = getFinalArg(arguments, 0);
|
@Override
|
||||||
|
protected void updatePlayer(final Server server, final CommandSource sender, final User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||||
|
if (user.getName().equals(sender.getSender().getName())) {
|
||||||
|
return; // Silently don't do anything.
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(tl("sudoRun", user.getDisplayName(), command, ""));
|
if (user.isAuthorized("essentials.sudo.exempt") && sender.isPlayer()) {
|
||||||
|
sender.sendMessage(tl("sudoExempt", user.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].toLowerCase(Locale.ENGLISH).startsWith("c:")) {
|
||||||
|
user.getBase().chat(getFinalArg(args, 0).substring(2));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String command = getFinalArg(args, 0);
|
||||||
if (command != null && command.length() > 0) {
|
if (command != null && command.length() > 0) {
|
||||||
class SudoCommandTask implements Runnable {
|
class SudoCommandTask implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
|
@ -403,7 +403,7 @@ socialSpy=\u00a76SocialSpy for \u00a7c{0}\u00a76\: \u00a7c{1}
|
|||||||
soloMob=\u00a74That mob likes to be alone.
|
soloMob=\u00a74That mob likes to be alone.
|
||||||
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
||||||
spawned=spawned
|
spawned=spawned
|
||||||
sudoExempt=\u00a74You cannot sudo this user.
|
sudoExempt=\u00a74You cannot sudo \u00a7c{0}.
|
||||||
sudoRun=\u00a76Forcing\u00a7c {0} \u00a76to run\:\u00a7r /{1}
|
sudoRun=\u00a76Forcing\u00a7c {0} \u00a76to run\:\u00a7r /{1}
|
||||||
suicideMessage=\u00a76Goodbye cruel world...
|
suicideMessage=\u00a76Goodbye cruel world...
|
||||||
suicideSuccess=\u00a76Player \u00a7c{0} \u00a76took their own life.
|
suicideSuccess=\u00a76Player \u00a7c{0} \u00a76took their own life.
|
||||||
|
Loading…
Reference in New Issue
Block a user