TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gcmd.java

74 lines
2.2 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
2012-11-13 01:42:30 +00:00
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
2011-10-19 00:37:00 +00:00
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-11-13 01:42:30 +00:00
if (senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender))
2011-10-19 00:37:00 +00:00
{
if (args.length < 2)
{
return false;
}
Player p;
try
2011-10-19 00:37:00 +00:00
{
p = getPlayer(args[0]);
2011-10-19 00:37:00 +00:00
}
catch (CantFindPlayerException ex)
2011-10-19 00:37:00 +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();
}
catch (Throwable ex)
2011-10-19 00:37:00 +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);
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.");
}
}
catch (Throwable ex)
2011-10-19 00:37:00 +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;
}
}