2022-03-20 12:35:43 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.commands;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.command.CommandBlocker;
|
2014-11-29 19:16:00 +00:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-03-23 23:15:51 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2011-10-19 00:37:00 +00:00
|
|
|
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)
|
2022-03-20 12:35:43 +00:00
|
|
|
public class Command_gcmd extends FreedomCommand {
|
2011-10-19 00:37:00 +00:00
|
|
|
@Override
|
2022-03-20 12:35:43 +00:00
|
|
|
public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
|
|
|
if (args.length < 2) {
|
2012-11-24 01:22:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2022-03-23 23:15:51 +00:00
|
|
|
String arguments = String.join(" ", args);
|
|
|
|
|
|
|
|
if (arguments.toLowerCase().contains("wildcard") || arguments.toLowerCase().contains("gcmd")) {
|
|
|
|
playerMsg("What the hell are you trying to do, you stupid idiot...", ChatColor.RED);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
if (player == null) {
|
|
|
|
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);
|
|
|
|
|
2022-03-20 12:35:43 +00:00
|
|
|
if (CommandBlocker.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
|
|
|
|
{
|
2022-03-23 23:48:41 +00:00
|
|
|
playerMsg(sender, "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
|
|
|
{
|
2022-03-23 23:48:41 +00:00
|
|
|
playerMsg(sender, "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
|
|
|
{
|
2022-03-23 23:48:41 +00:00
|
|
|
playerMsg(sender, "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
|
|
|
{
|
2022-03-23 23:48:41 +00:00
|
|
|
playerMsg(sender, "Error sending command: " + ex.getMessage());
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|