mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 00:57:37 +00:00
add banlist to plex instead of having it in tfm extras
This commit is contained in:
parent
efcb9b45df
commit
fd19d8417c
61
server/src/main/java/dev/plex/command/impl/BanListCommand.java
Executable file
61
server/src/main/java/dev/plex/command/impl/BanListCommand.java
Executable file
@ -0,0 +1,61 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandParameters(name = "banlist", description = "Manages the banlist", usage = "/<command> [purge]")
|
||||
@CommandPermissions(permission = "plex.banlist")
|
||||
public class BanListCommand extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
plugin.getPunishmentManager().getActiveBans().whenComplete((punishments, throwable) ->
|
||||
{
|
||||
send(sender, mmString("<gold>Active Bans (" + punishments.size() + "): <yellow>" + StringUtils.join(punishments.stream().map(Punishment::getPunishedUsername).collect(Collectors.toList()), ", ")));
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("purge") || args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return messageComponent("noPermissionInGame");
|
||||
}
|
||||
if (!sender.getName().equalsIgnoreCase("console"))
|
||||
{
|
||||
if (!checkPermission(sender, "plex.banlist.clear"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
plugin.getPunishmentManager().getActiveBans().whenComplete((punishments, throwable) ->
|
||||
{
|
||||
punishments.forEach(plugin.getPunishmentManager()::unban);
|
||||
send(sender, mmString("<gold>Unbanned " + punishments.size() + " players."));
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.banlist.clear") ? List.of("purge", "clear") : ImmutableList.of();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user