TFM-4.3-Reloaded/src/main/java/me/StevenLawson/TotalFreedomMod/commands/Command_gcmd.java

59 lines
1.7 KiB
Java
Raw Normal View History

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;
import org.apache.commons.lang3.StringUtils;
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;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
2022-03-20 12:35:43 +00:00
public class Command_gcmd extends FreedomCommand {
2022-03-31 01:46:24 +00:00
@Override
public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd,
String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length < 2) {
return false;
}
String arguments = String.join(" ", args);
if (arguments.toLowerCase().contains("wildcard") || arguments.toLowerCase().contains("gcmd")
|| arguments.toLowerCase().contains("moles") || arguments.toLowerCase()
.contains("sudo")) {
2022-03-31 01:46:24 +00:00
playerMsg("What the hell are you trying to do, you stupid idiot...", ChatColor.RED);
if (sender_p != null) {
Command_smite.smite(sender_p);
}
return true;
}
final Player player = getPlayer(args[0]);
if (player == null) {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
final String outCommand = StringUtils.join(args, " ", 1, args.length);
if (CommandBlocker.isCommandBlocked(outCommand, sender)) {
return true;
}
try {
playerMsg(sender, "Sending command as " + player.getName() + ": " + outCommand);
if (server.dispatchCommand(player, outCommand)) {
playerMsg(sender, "Command sent.");
} else {
playerMsg(sender, "Unknown error sending command.");
}
} catch (Throwable ex) {
playerMsg(sender, "Error sending command: " + ex.getMessage());
}
return true;
}
2011-10-19 00:37:00 +00:00
}