2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2014-03-18 15:17:00 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
|
|
|
|
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Send a command as someone else.", usage = "/<command> <fromname> <outcommand>")
|
2011-10-19 00:37:00 +00:00
|
|
|
public class Command_gcmd extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
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
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
Player player;
|
2012-11-24 01:22:52 +00:00
|
|
|
try
|
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
player = getPlayer(args[0]);
|
2012-11-24 01:22:52 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (PlayerNotFoundException ex)
|
2012-11-24 01:22:52 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
sender.sendMessage(ex.getMessage());
|
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);
|
|
|
|
|
|
|
|
if (TFM_CommandBlocker.getInstance().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
|
|
|
|
{
|
2014-03-18 15:17:00 +00:00
|
|
|
playerMsg("Sending command as " + player.getName() + ": " + outCommand);
|
|
|
|
if (server.dispatchCommand(player, outCommand))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("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
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("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
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
playerMsg("Error sending command: " + ex.getMessage());
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|