2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2019-07-28 06:04:16 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Send a command as someone else.", usage = "/<command> <fromname> <outcommand>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_gcmd extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
if (args.length < 2)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
2012-11-24 01:22:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2014-03-18 15:17:00 +00:00
|
|
|
final String outCommand = StringUtils.join(args, " ", 1, args.length);
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
if (plugin.cb.isCommandBlocked(outCommand, sender))
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
try
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Sending command as " + player.getName() + ": " + outCommand);
|
2014-03-18 15:17:00 +00:00
|
|
|
if (server.dispatchCommand(player, outCommand))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Command sent.");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
else
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Unknown error sending command.");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Throwable ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Error sending command: " + ex.getMessage());
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|