2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
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-07-28 23:08:44 +00:00
|
|
|
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
if (args.length < 2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player p;
|
2011-10-19 02:52:32 +00:00
|
|
|
try
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
p = getPlayer(args[0]);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2011-10-19 02:52:32 +00:00
|
|
|
catch (CantFindPlayerException ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
sender.sendMessage(ex.getMessage());
|
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String outcommand = "";
|
|
|
|
try
|
|
|
|
{
|
|
|
|
StringBuilder outcommand_bldr = new StringBuilder();
|
|
|
|
for (int i = 1; i < args.length; i++)
|
|
|
|
{
|
|
|
|
outcommand_bldr.append(args[i]).append(" ");
|
|
|
|
}
|
|
|
|
outcommand = outcommand_bldr.toString().trim();
|
|
|
|
}
|
2011-10-19 02:52:32 +00:00
|
|
|
catch (Throwable ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
sender.sendMessage(ChatColor.GRAY + "Error building command: " + ex.getMessage());
|
2011-10-21 04:17:02 +00:00
|
|
|
return true;
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sender.sendMessage(ChatColor.GRAY + "Sending command as " + p.getName() + ": " + outcommand);
|
2012-03-06 19:25:22 +00:00
|
|
|
if (server.dispatchCommand(p, outcommand))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
sender.sendMessage(ChatColor.GRAY + "Command sent.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sender.sendMessage(ChatColor.GRAY + "Unknown error sending command.");
|
|
|
|
}
|
|
|
|
}
|
2011-10-19 02:52:32 +00:00
|
|
|
catch (Throwable ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2011-10-19 02:52:32 +00:00
|
|
|
sender.sendMessage(ChatColor.GRAY + "Error sending command: " + ex.getMessage());
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|