From b12e1ee1fa25bdafc39b810f2992a8d3d89512d3 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 16:18:07 +0100 Subject: [PATCH] Fix a few things --- .../bungeecore/commands/WhoisCommand.java | 13 ++++++------ .../bungeecore/listeners/mods/Fabric.java | 20 ------------------- .../steamwar/bungeecore/sql/SteamwarUser.java | 1 - 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 9ee5c10..9c426e9 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -68,7 +68,8 @@ public class WhoisCommand extends SWCommand { if (user == null) { Message.send("UNKNOWN_PLAYER", player); } else { - sendUserinfo(player, user, Arrays.asList(parameters)); + EnumSet set = parameters.length == 0 ? EnumSet.noneOf(WhoisParameterTypes.class) : EnumSet.copyOf(Arrays.asList(parameters)); + sendUserinfo(player, user, set); } } @@ -77,7 +78,7 @@ public class WhoisCommand extends SWCommand { return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList())); } - private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, List parameterTypes) { + private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, EnumSet parameterTypes) { Message.send("WHOIS_USERNAME", player, user.getUserName()); Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString()); Message.send("WHOIS_ID", player, user.getId()); @@ -167,17 +168,17 @@ public class WhoisCommand extends SWCommand { } private enum WhoisParameterTypes { - ALL(Arrays.asList("-a","-all"),UserGroup.Admin,UserGroup.Moderator,UserGroup.Developer,UserGroup.Supporter,UserGroup.Builder), - MOD(Arrays.asList("-m","-mod","-mods"),UserGroup.Admin,UserGroup.Moderator,UserGroup.Developer); + ALL(Arrays.asList("-a","-all"), UserGroup.Admin, UserGroup.Moderator, UserGroup.Developer, UserGroup.Supporter, UserGroup.Builder), + MOD(Arrays.asList("-m","-mod","-mods"), UserGroup.Admin, UserGroup.Moderator, UserGroup.Developer); - private final Set userGroupSet; + private final EnumSet userGroupSet; @Getter private List tabCompletes; WhoisParameterTypes(List tabCompletes,UserGroup... userGroups) { - this.userGroupSet = new HashSet<>(Arrays.asList(userGroups)); + this.userGroupSet = EnumSet.copyOf(Arrays.asList(userGroups)); this.tabCompletes = tabCompletes; } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 02b939a..440ab12 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -122,15 +122,6 @@ public class Fabric extends BasicListener { mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC)); } - /* - boolean isSorted = isSortedAlphabetically(mods); - - if(!isSorted) { - banPlayer(user, player, "Mods are not sorted alphabetically: " + mods.stream().map(Mod::getModName).collect(Collectors.joining(", "))); - return; - } - */ - if(!neededModsContained(mods)) { logMessage(user, "Needed mods are not contained", dataString); return; @@ -159,17 +150,6 @@ public class Fabric extends BasicListener { } } - /*private boolean isSortedAlphabetically(List mods) { - boolean isSorted = true; - for(int i = 0; i < mods.size() - 1; i++) { - if(mods.get(i).getModName().compareToIgnoreCase(mods.get(i + 1).getModName()) > 0) { - isSorted = false; - break; - } - } - return isSorted; - }*/ - private boolean neededModsContained(List mods) { return mods.stream() .map(Mod::getModName) diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 2c11fdb..150ccf4 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -39,7 +39,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; import java.util.stream.Collectors;