mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
fix wildcard and add back some beloved commands
This commit is contained in:
parent
e1e046b16b
commit
e3a6f5127f
@ -0,0 +1,35 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Send a chat message as someone else.", usage = "/<command> <fromname> <outmessage>")
|
||||
public class Command_gchat extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player = getPlayer(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String outMessage = StringUtils.join(args, " ", 1, args.length);
|
||||
msg("Sending message as " + player.getName() + ": " + outMessage);
|
||||
player.chat(outMessage);
|
||||
msg("Message sent.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Send a command as someone else.", usage = "/<command> <fromname> <outcommand>")
|
||||
public class Command_gcmd extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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 (plugin.cb.isCommandBlocked(outCommand, sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
msg("Sending command as " + player.getName() + ": " + outCommand);
|
||||
if (server.dispatchCommand(player, outCommand))
|
||||
{
|
||||
msg("Command sent.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Unknown error sending command.");
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
msg("Error sending command: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -14,12 +14,11 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Run any command on all users, username placeholder = ?.", usage = "/<command> [fluff] ? [fluff] ?")
|
||||
public class Command_wildcard extends FreedomCommand
|
||||
{
|
||||
|
||||
public static final List<String> BLOCKED_COMMANDS = Arrays.asList(
|
||||
"wildcard",
|
||||
"gtfo",
|
||||
"doom",
|
||||
"saconfig",
|
||||
"slconfig",
|
||||
"smite"
|
||||
);
|
||||
|
||||
@ -52,15 +51,15 @@ public class Command_wildcard extends FreedomCommand
|
||||
aliases = Arrays.asList(fCmd.getAliases().split(","));
|
||||
}
|
||||
|
||||
for (String blockedCommand : BLOCKED_COMMANDS)
|
||||
for (String arg : args)
|
||||
{
|
||||
if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand))
|
||||
String strCommand = StringUtils.strip(arg, "/");
|
||||
if (BLOCKED_COMMANDS.contains(strCommand.toLowerCase()) || aliases.contains(strCommand.toLowerCase()))
|
||||
{
|
||||
msg("Did you really think that was going to work?", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String baseCommand = StringUtils.join(args, " ");
|
||||
|
||||
if (plugin.cb.isCommandBlocked(baseCommand, sender))
|
||||
@ -75,7 +74,6 @@ public class Command_wildcard extends FreedomCommand
|
||||
msg("Running Command: " + runCommand);
|
||||
server.dispatchCommand(sender, runCommand);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user