mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-26 16:39:45 +00:00
Switch sudo to command dispatch, this will allow vanilla commands to be executed.
This commit is contained in:
parent
0b925e6fc0
commit
a131527a15
3 changed files with 16 additions and 18 deletions
|
@ -4,10 +4,8 @@ import com.earth2me.essentials.CommandSource;
|
|||
import static com.earth2me.essentials.I18n.tl;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public class Commandsudo extends EssentialsCommand
|
||||
|
@ -36,11 +34,10 @@ public class Commandsudo extends EssentialsCommand
|
|||
user.getBase().chat(getFinalArg(args, 1).substring(2));
|
||||
return;
|
||||
}
|
||||
final String command = args[1];
|
||||
final String[] arguments = new String[args.length - 2];
|
||||
final String[] arguments = new String[args.length - 1];
|
||||
if (arguments.length > 0)
|
||||
{
|
||||
System.arraycopy(args, 2, arguments, 0, args.length - 2);
|
||||
System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
||||
}
|
||||
|
||||
if (user.isAuthorized("essentials.sudo.exempt") && sender.isPlayer())
|
||||
|
@ -48,25 +45,28 @@ public class Commandsudo extends EssentialsCommand
|
|||
throw new Exception(tl("sudoExempt"));
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("sudoRun", user.getDisplayName(), command, getFinalArg(arguments, 0)));
|
||||
final String command = getFinalArg(arguments, 0);
|
||||
|
||||
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
|
||||
if (execCommand != null)
|
||||
sender.sendMessage(tl("sudoRun", user.getDisplayName(), command, ""));
|
||||
|
||||
if (command != null && command.length() > 0)
|
||||
{
|
||||
class SudoCommandTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
LOGGER.log(Level.INFO, String.format("[Sudo] %s issued server command: /%s %s", user.getName(), command, getFinalArg(arguments, 0)));
|
||||
execCommand.execute(user.getBase(), command, arguments);
|
||||
try
|
||||
{
|
||||
ess.getServer().dispatchCommand(user.getBase(), command);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
sender.sendMessage(tl("errorCallingCommand", command));
|
||||
}
|
||||
}
|
||||
}
|
||||
ess.scheduleSyncDelayedTask(new SudoCommandTask());
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(tl("errorCallingCommand", command));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ soloMob=\u00a74That mob likes to be alone.
|
|||
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
||||
spawned=spawned
|
||||
sudoExempt=\u00a74You cannot sudo this user.
|
||||
sudoRun=\u00a76Forcing\u00a7c {0} \u00a76to run\:\u00a7r /{1} {2}
|
||||
sudoRun=\u00a76Forcing\u00a7c {0} \u00a76to run\:\u00a7r /{1}
|
||||
suicideMessage=\u00a76Goodbye cruel world...
|
||||
suicideSuccess=\u00a76Player \u00a7c{0} \u00a76took their own life.
|
||||
survival=survival
|
||||
|
@ -548,7 +548,6 @@ mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
|||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
|
||||
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||
|
||||
itemsConverted=\u00a76Converted all items into blocks.
|
||||
itemsNotConverted=\u00a74You have no items that can be converted into blocks.
|
||||
mailSentTo=\u00a7c{0}\u00a76 has been sent the following mail:
|
||||
|
|
|
@ -404,7 +404,7 @@ soloMob=\u00a74That mob likes to be alone.
|
|||
spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
||||
spawned=spawned
|
||||
sudoExempt=\u00a74You cannot sudo this user.
|
||||
sudoRun=\u00a76Forcing\u00a7c {0} \u00a76to run\:\u00a7r /{1} {2}
|
||||
sudoRun=\u00a76Forcing\u00a7c {0} \u00a76to run\:\u00a7r /{1}
|
||||
suicideMessage=\u00a76Goodbye cruel world...
|
||||
suicideSuccess=\u00a76Player \u00a7c{0} \u00a76took their own life.
|
||||
survival=survival
|
||||
|
@ -548,7 +548,6 @@ mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
|
|||
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
|
||||
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
|
||||
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
|
||||
|
||||
itemsConverted=\u00a76Converted all items into blocks.
|
||||
itemsNotConverted=\u00a74You have no items that can be converted into blocks.
|
||||
mailSentTo=\u00a7c{0}\u00a76 has been sent the following mail:
|
||||
|
|
Loading…
Reference in a new issue