2011-11-16 03:00:31 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2012-03-12 15:35:20 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-11-16 03:00:31 +00:00
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
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
|
|
|
|
2012-02-09 22:11:46 +00:00
|
|
|
if (user.isAuthorized("essentials.sudo.exempt"))
|
|
|
|
{
|
2012-03-12 15:35:20 +00:00
|
|
|
throw new Exception(_("sudoExempt"));
|
2012-02-09 22:11:46 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 15:35:20 +00:00
|
|
|
sender.sendMessage(_("sudoRun", user.getDisplayName(), 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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|