Video cec506f148 Too much shit to list in the commit name
- Removes ancient unused code
- General code cleanup in some places
- Rewrites a few components to use Adventure (testing needed)
- Rewrites a few commands to use more modern Java features like Streams
- Fixes oversight where vanishing still worked by names and not UUIDs
- Removes unused Pterodactyl integration
- Removes AutoEject's IP range banning functionality
- Does some minor cleanup to HTTPD's list & players modules
- Fixes ages-old bug in the AntiSpam that caused it to falsely mute players
2023-07-11 12:06:59 -05:00

61 lines
2.0 KiB
Java

package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH, cooldown = 5)
@CommandParameters(description = "OP a player", usage = "/<command> <partialname>")
public class Command_op extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
boolean silent = false;
if (args.length == 2)
{
silent = args[1].equalsIgnoreCase("-s");
}
final String targetName = args[0].toLowerCase();
List<String> matchedPlayerNames = new ArrayList<>();
for (final Player player : server.getOnlinePlayers())
{
if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName)) &&
!player.isOp() && !plugin.al.isVanished(player.getUniqueId()))
{
matchedPlayerNames.add(player.getName());
player.setOp(true);
msg(player, YOU_ARE_OP);
plugin.rm.updateDisplay(player);
}
}
if (!matchedPlayerNames.isEmpty())
{
if (!silent)
{
FUtil.adminAction(sender.getName(), "Opping " + StringUtils.join(matchedPlayerNames, ", "), false);
}
}
else
{
msg("Either the player is already opped, or the player could not be found.");
}
return true;
}
}