2011-11-16 03:00:31 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.User;
|
2012-02-21 21:39:25 +00:00
|
|
|
import com.earth2me.essentials.Util;
|
2011-11-16 03:00:31 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.command.PluginCommand;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandsudo extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandsudo()
|
|
|
|
{
|
|
|
|
super("sudo");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
|
|
|
{
|
|
|
|
if (args.length < 2)
|
|
|
|
{
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
|
2011-11-16 03:26:24 +00:00
|
|
|
final User user = getPlayer(server, args, 0, false);
|
2011-11-16 03:00:31 +00:00
|
|
|
final String command = args[1];
|
2011-11-16 03:26:24 +00:00
|
|
|
final String[] arguments = new String[args.length - 2];
|
2011-11-21 01:55:26 +00:00
|
|
|
if (arguments.length > 0)
|
|
|
|
{
|
2011-11-16 03:26:24 +00:00
|
|
|
System.arraycopy(args, 2, arguments, 0, args.length - 2);
|
|
|
|
}
|
2011-11-16 03:00:31 +00:00
|
|
|
|
|
|
|
//TODO: Translate this.
|
2012-02-09 22:11:46 +00:00
|
|
|
if (user.isAuthorized("essentials.sudo.exempt"))
|
|
|
|
{
|
|
|
|
throw new Exception("You cannot sudo this user");
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: Translate this.
|
2012-02-21 21:39:25 +00:00
|
|
|
sender.sendMessage("Forcing " + user.getDisplayName() + " to run: /" + command + " " + getFinalArg(arguments, 0));
|
2011-11-16 03:00:31 +00:00
|
|
|
|
2011-11-18 19:30:05 +00:00
|
|
|
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
|
|
|
|
if (execCommand != null)
|
2011-11-16 03:00:31 +00:00
|
|
|
{
|
2011-11-18 19:30:05 +00:00
|
|
|
execCommand.execute(user.getBase(), command, arguments);
|
2011-11-16 03:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|