From c2a962a86591e0c90d09e6bc8d327b3776873d87 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sun, 1 Jan 2023 16:19:57 +0100 Subject: [PATCH 01/18] Initial whois Fabric Mod Implementation --- .../bungeecore/commands/WhoisCommand.java | 10 +++++++++ .../bungeecore/listeners/mods/Fabric.java | 22 ++----------------- .../steamwar/bungeecore/sql/SteamwarUser.java | 8 +++++++ .../steamwar/messages/BungeeCore.properties | 3 +++ .../messages/BungeeCore_de.properties | 3 +++ 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index bf016c3..b020b2e 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; +import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; @@ -103,6 +104,15 @@ public class WhoisCommand extends SWCommand { Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); + if(!user.getActiveMods().isEmpty()) { + Message.send("WHOIS_ACTIVE_MODS",player); + for(Mod mod : user.getActiveMods()) { + Message.sendPrefixless("WHOIS_ACTIVE_MOD", player,mod.getModName()); + } + }else { + Message.send("WHOIS_NO_ACTIVE_MODS",player); + } + Message.send("WHOIS_PUNISHMENTS", player); List punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId()); Set found = new HashSet<>(); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index c8990a7..6947a12 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; @@ -148,6 +139,7 @@ public class Fabric extends BasicListener { Storage.fabricCheckedPlayers.put(player, dataString.hashCode()); } Storage.fabricPlayers.remove(player); + user.setActiveMods(mods); } } @@ -159,17 +151,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) @@ -183,6 +164,7 @@ public class Fabric extends BasicListener { public static void remove(ProxiedPlayer player) { Storage.fabricCheckedPlayers.remove(player); + SteamwarUser.get(player.getUniqueId()).setActiveMods(new LinkedList<>()); synchronized (Storage.fabricExpectPluginMessage) { Storage.fabricExpectPluginMessage.remove(player); } diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 150ccf4..dbafd60 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -80,6 +80,8 @@ public class SteamwarUser { private Locale locale; private boolean manualLocale; + private List activeMods = new LinkedList<>(); + static { try { LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43}); @@ -392,4 +394,10 @@ public class SteamwarUser { updateLocale.update(locale.toLanguageTag(), manualLocale, id); NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(id)); } + + public void setActiveMods(List activeMods) { + this.activeMods = activeMods; + } + + public List getActiveMods() {return this.activeMods;} } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 314f26d..8f0580b 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -596,6 +596,9 @@ WHOIS_PUNISHMENTS=§7Punish: WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4} WHOIS_NO_PUNISHMENT=§a✓ §7This player has no active punishment. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet. +WHOIS_ACTIVE_MODS=§7Active Mods: +WHOIS_NO_ACTIVE_MODS=§7This player has no active mods. +WHOIS_ACTIVE_MOD=§7{0} #VerifyCommand VERIFY_USAGE=§c/verify [Code] diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 97de4ee..b72c275 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -575,6 +575,9 @@ WHOIS_PUNISHMENTS=§7Strafen: WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4} WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan. +WHOIS_ACTIVE_MODS=§7Aktive Mods: +WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods. +WHOIS_ACTIVE_MOD=§7{0} #VerifyCommand VERIFY_USAGE=§c/verify [Code] -- 2.39.2 From abe45da57dd3502a0a547655eaa78689b3ef3a9f Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sun, 1 Jan 2023 21:05:34 +0100 Subject: [PATCH 02/18] Fix mod list array --- src/de/steamwar/bungeecore/commands/WhoisCommand.java | 2 +- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 6 +++--- src/de/steamwar/bungeecore/sql/SteamwarUser.java | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index b020b2e..1690f54 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -107,7 +107,7 @@ public class WhoisCommand extends SWCommand { if(!user.getActiveMods().isEmpty()) { Message.send("WHOIS_ACTIVE_MODS",player); for(Mod mod : user.getActiveMods()) { - Message.sendPrefixless("WHOIS_ACTIVE_MOD", player,mod.getModName()); + Message.send("WHOIS_ACTIVE_MOD", player,mod.getModName()); } }else { Message.send("WHOIS_NO_ACTIVE_MODS",player); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 6947a12..7258e34 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -89,7 +89,7 @@ public class Fabric extends BasicListener { } Storage.fabricExpectPluginMessage.remove(player); - List mods = new LinkedList<>(); + ArrayList mods = new ArrayList<>(); Utils.VarInt varInt = Utils.readVarInt(data,0); @@ -127,6 +127,8 @@ public class Fabric extends BasicListener { return; } + user.setActiveMods(mods); + if(Utils.handleMods(player,mods)) { if (Storage.fabricCheckedPlayers.containsKey(player)) { long current = Storage.fabricCheckedPlayers.get(player); @@ -139,7 +141,6 @@ public class Fabric extends BasicListener { Storage.fabricCheckedPlayers.put(player, dataString.hashCode()); } Storage.fabricPlayers.remove(player); - user.setActiveMods(mods); } } @@ -164,7 +165,6 @@ public class Fabric extends BasicListener { public static void remove(ProxiedPlayer player) { Storage.fabricCheckedPlayers.remove(player); - SteamwarUser.get(player.getUniqueId()).setActiveMods(new LinkedList<>()); synchronized (Storage.fabricExpectPluginMessage) { Storage.fabricExpectPluginMessage.remove(player); } diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index dbafd60..bb87728 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -39,6 +39,7 @@ 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; @@ -80,7 +81,7 @@ public class SteamwarUser { private Locale locale; private boolean manualLocale; - private List activeMods = new LinkedList<>(); + private List activeMods = new CopyOnWriteArrayList<>(); static { try { @@ -396,8 +397,11 @@ public class SteamwarUser { } public void setActiveMods(List activeMods) { - this.activeMods = activeMods; + this.activeMods.clear(); + this.activeMods.addAll(activeMods); } - public List getActiveMods() {return this.activeMods;} + public List getActiveMods() { + return new ArrayList<>(activeMods); + } } -- 2.39.2 From b6365d32f7c15222b043f452db8ef5530c6c5734 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 2 Jan 2023 13:05:52 +0100 Subject: [PATCH 03/18] Rework whois command --- .../bungeecore/commands/WhoisCommand.java | 86 +++++++++++++++---- .../steamwar/messages/BungeeCore.properties | 2 +- .../messages/BungeeCore_de.properties | 2 +- 3 files changed, 71 insertions(+), 19 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 1690f54..840365a 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -19,36 +19,40 @@ package de.steamwar.bungeecore.commands; +import com.google.common.reflect.TypeParameter; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; -import de.steamwar.bungeecore.sql.Mod; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.Team; +import de.steamwar.bungeecore.sql.*; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; +import lombok.AllArgsConstructor; +import lombok.Getter; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.command.ConsoleCommandSender; import java.net.InetSocketAddress; +import java.sql.Array; import java.sql.Timestamp; import java.text.DecimalFormat; import java.time.Instant; -import java.util.HashSet; -import java.util.List; -import java.util.Set; + +import java.util.*; +import java.util.function.Supplier; import java.util.stream.Collectors; +import java.util.stream.Stream; + public class WhoisCommand extends SWCommand { public WhoisCommand() { super("whois", "bungeecore.teamchat"); } - @Register(description = "WHOIS_USAGE") - public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue(value = {"", "-all", "-a"}, allowISE = true) boolean all) { + @Register(description = "WHOIS_COMMAND") + public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, WhoisParameterTypes... parameters) { SteamwarUser user = SteamwarUser.get(target); if (user == null) { try { @@ -69,7 +73,7 @@ public class WhoisCommand extends SWCommand { if (user == null) { Message.send("UNKNOWN_PLAYER", player); } else { - sendUserinfo(player, user, all); + sendUserinfo(player, user, new HashSet<>(Arrays.asList(parameters))); } } @@ -78,7 +82,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, boolean all) { + private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, Set 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()); @@ -104,19 +108,25 @@ public class WhoisCommand extends SWCommand { Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); - if(!user.getActiveMods().isEmpty()) { - Message.send("WHOIS_ACTIVE_MODS",player); - for(Mod mod : user.getActiveMods()) { - Message.send("WHOIS_ACTIVE_MOD", player,mod.getModName()); + if(parameterTypes.contains(WhoisParameterTypes.MOD)) { + if(!user.getActiveMods().isEmpty()) { + Message.send("WHOIS_ACTIVE_MODS",player); + StringBuilder msg = new StringBuilder(); + for(Mod mod : user.getActiveMods()) { + msg.append(mod.getModName()).append(","); + } + msg.deleteCharAt(msg.length() - 1); + Message.send("WHOIS_ACTIVE_MOD", player,msg.toString()); + }else { + Message.send("WHOIS_NO_ACTIVE_MODS",player); } - }else { - Message.send("WHOIS_NO_ACTIVE_MODS",player); } Message.send("WHOIS_PUNISHMENTS", player); List punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId()); Set found = new HashSet<>(); boolean isPunished = false; + boolean all = parameterTypes.contains(WhoisParameterTypes.ALL); for (Punishment punishment : punishmentList) { if (!all && !punishment.getType().isMulti() && !found.add(punishment.getType())) { continue; @@ -131,4 +141,46 @@ public class WhoisCommand extends SWCommand { Message.send(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT", player); } } + + @ClassMapper(value = WhoisParameterTypes.class, local = true) + public TypeMapper argument() { + WhoisParameterTypes[] values = WhoisParameterTypes.values(); + + return new TypeMapper() { + @Override + public WhoisParameterTypes map(CommandSender commandSender, String[] previousArguments, String s) { + UserGroup userGroup = (commandSender instanceof ConsoleCommandSender) ? UserGroup.Admin : SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup(); + return Stream.of(values) + .filter(p -> p.userGroupSet.contains(userGroup)) + .filter(p -> p.getTabCompletes().contains(s)) + .findFirst() + .orElse(null); + } + + @Override + public Collection tabCompletes(CommandSender commandSender, String[] previousArguments, String s) { + UserGroup userGroup = (commandSender instanceof ConsoleCommandSender) ? UserGroup.Admin : SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup(); + return Stream.of(values) + .filter(p -> p.userGroupSet.contains(userGroup)) + .flatMap(p -> p.getTabCompletes().stream()) + .collect(Collectors.toList()); + } + }; + } + + 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); + + private final Set userGroupSet; + + @Getter + private List tabCompletes; + + + WhoisParameterTypes(List tabCompletes,UserGroup... userGroups) { + this.userGroupSet = new HashSet<>(Arrays.asList(userGroups)); + this.tabCompletes = tabCompletes; + } + } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 8f0580b..7d2e1c9 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -578,7 +578,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed. #WhoisCommand -WHOIS_USAGE=§c/whois [player/ID] <-a> +WHOIS_USAGE=§c/whois [player/ID] <-a>,<-m> WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index b72c275..b4f126b 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -557,7 +557,7 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen. #WhoisCommand -WHOIS_USAGE=§c/whois [Spieler/ID] <-a> +WHOIS_USAGE=§c/whois [Spieler/ID] <-a>,<-m> WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_GROUP=§7Gruppe§8: {0}{1} WHOIS_UUID=§7UUID§8: §e{0} -- 2.39.2 From ed55af8952a02af809ec9f4116b7b4f06f6a0fae Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Mon, 2 Jan 2023 23:54:24 +0100 Subject: [PATCH 04/18] Make it use more mod loader + add modloader + color coding --- .../bungeecore/commands/WhoisCommand.java | 26 +++++++++++-------- .../listeners/ConnectionListener.java | 3 +++ .../bungeecore/listeners/mods/Fabric.java | 4 +-- .../bungeecore/listeners/mods/LabyMod.java | 5 +--- .../bungeecore/listeners/mods/Utils.java | 15 ++++++----- src/de/steamwar/bungeecore/sql/Mod.java | 18 ++++++++----- .../steamwar/bungeecore/sql/SteamwarUser.java | 11 -------- .../steamwar/messages/BungeeCore.properties | 3 ++- .../messages/BungeeCore_de.properties | 3 ++- 9 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 840365a..807dbbc 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands; import com.google.common.reflect.TypeParameter; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; +import de.steamwar.bungeecore.listeners.mods.Utils; import de.steamwar.bungeecore.sql.*; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; @@ -108,15 +109,18 @@ public class WhoisCommand extends SWCommand { Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); + if(Utils.synchronizedPlayerModMap.containsKey(user.getUuid())) { + Mod.Platform modPlatform = Utils.synchronizedPlayerModMap.get(user.getUuid()).get(0).getPlatform(); + Message.send("WHOIS_PLATFORM",player,modPlatform.toString()); + } + if(parameterTypes.contains(WhoisParameterTypes.MOD)) { - if(!user.getActiveMods().isEmpty()) { - Message.send("WHOIS_ACTIVE_MODS",player); - StringBuilder msg = new StringBuilder(); - for(Mod mod : user.getActiveMods()) { - msg.append(mod.getModName()).append(","); - } - msg.deleteCharAt(msg.length() - 1); - Message.send("WHOIS_ACTIVE_MOD", player,msg.toString()); + List activeMods = Utils.synchronizedPlayerModMap.get(user.getUuid()); + + if(!activeMods.isEmpty()) { + Message.send("WHOIS_ACTIVE_MODS",player); + String result = activeMods.stream().map(mod -> mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); + Message.send("WHOIS_ACTIVE_MOD", player,result); }else { Message.send("WHOIS_NO_ACTIVE_MODS",player); } @@ -143,13 +147,13 @@ public class WhoisCommand extends SWCommand { } @ClassMapper(value = WhoisParameterTypes.class, local = true) - public TypeMapper argument() { + public TypeMapper argumentTypeMapper() { WhoisParameterTypes[] values = WhoisParameterTypes.values(); return new TypeMapper() { @Override public WhoisParameterTypes map(CommandSender commandSender, String[] previousArguments, String s) { - UserGroup userGroup = (commandSender instanceof ConsoleCommandSender) ? UserGroup.Admin : SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup(); + UserGroup userGroup = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup(); return Stream.of(values) .filter(p -> p.userGroupSet.contains(userGroup)) .filter(p -> p.getTabCompletes().contains(s)) @@ -159,7 +163,7 @@ public class WhoisCommand extends SWCommand { @Override public Collection tabCompletes(CommandSender commandSender, String[] previousArguments, String s) { - UserGroup userGroup = (commandSender instanceof ConsoleCommandSender) ? UserGroup.Admin : SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup(); + UserGroup userGroup = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup(); return Stream.of(values) .filter(p -> p.userGroupSet.contains(userGroup)) .flatMap(p -> p.getTabCompletes().stream()) diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 44bba9f..851e0af 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -28,8 +28,10 @@ import de.steamwar.bungeecore.bot.util.DiscordRanks; import de.steamwar.bungeecore.commands.ChallengeCommand; import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.commands.MsgCommand; +import de.steamwar.bungeecore.listeners.mods.Utils; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserGroup; +import net.md_5.bungee.Util; import net.md_5.bungee.api.AbstractReconnectHandler; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ClickEvent; @@ -135,6 +137,7 @@ public class ConnectionListener extends BasicListener { public void onDisconnect(PlayerDisconnectEvent e){ ChallengeCommand.remove(e.getPlayer()); MsgCommand.remove(e.getPlayer()); + Utils.synchronizedPlayerModMap.remove(e.getPlayer().getUniqueId()); } @EventHandler diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 7258e34..440ab12 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -89,7 +89,7 @@ public class Fabric extends BasicListener { } Storage.fabricExpectPluginMessage.remove(player); - ArrayList mods = new ArrayList<>(); + List mods = new ArrayList<>(); Utils.VarInt varInt = Utils.readVarInt(data,0); @@ -127,8 +127,6 @@ public class Fabric extends BasicListener { return; } - user.setActiveMods(mods); - if(Utils.handleMods(player,mods)) { if (Storage.fabricCheckedPlayers.containsKey(player)) { long current = Storage.fabricCheckedPlayers.get(player); diff --git a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java index e659b4d..6a447dd 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java +++ b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java @@ -33,10 +33,7 @@ import net.md_5.bungee.event.EventHandler; import java.io.IOException; import java.io.StringReader; import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; +import java.util.*; public class LabyMod extends BasicListener { diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index 36256b6..b63b514 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -33,15 +33,15 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.sql.Timestamp; import java.time.Instant; import java.time.temporal.ChronoUnit; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.UUID; +import java.util.*; import java.util.function.Consumer; import java.util.logging.Level; import java.util.stream.Collectors; -class Utils { +public class Utils { + + public static final Map> synchronizedPlayerModMap = new HashMap<>(); + private Utils(){} static VarInt readVarInt(byte[] array, int startPos) { @@ -69,6 +69,7 @@ class Utils { static boolean handleMods(UUID uuid, Locale locale, Consumer disconnect, List mods){ SteamwarUser user = SteamwarUser.get(uuid); boolean privileged = user.getUserGroup().privilegedMods(); + synchronizedPlayerModMap.put(uuid,new ArrayList<>(mods)); ModType max = ModType.YELLOW; Iterator it = mods.iterator(); @@ -80,8 +81,10 @@ class Utils { max = ModType.RED; } - if(mods.isEmpty()) + if(mods.isEmpty()) { return true; + } + ModType finalMax = max; String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n")); diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index dcd69ae..039d930 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -74,11 +74,11 @@ public class Mod { } public enum ModType { - UNKLASSIFIED(0), - GREEN(1), - YELLOW(2), - RED(3), - YOUTUBER_ONLY(4); + UNKLASSIFIED(0,"§7 "), + GREEN(1,"§a "), + YELLOW(2,"§e "), + RED(3,"§c "), + YOUTUBER_ONLY(4,"§6 "); static ModType valueOf(int value){ for(ModType mt : values()){ @@ -88,9 +88,15 @@ public class Mod { throw new EnumConstantNotPresentException(ModType.class, Integer.toString(value)); } - ModType(int value){ + ModType(int value,String colorcode){ this.value = value; + this.colorcode = colorcode; } int value; + String colorcode; + + public String getColorCode() { + return colorcode; + } } } diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index bb87728..2c11fdb 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -81,8 +81,6 @@ public class SteamwarUser { private Locale locale; private boolean manualLocale; - private List activeMods = new CopyOnWriteArrayList<>(); - static { try { LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43}); @@ -395,13 +393,4 @@ public class SteamwarUser { updateLocale.update(locale.toLanguageTag(), manualLocale, id); NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(id)); } - - public void setActiveMods(List activeMods) { - this.activeMods.clear(); - this.activeMods.addAll(activeMods); - } - - public List getActiveMods() { - return new ArrayList<>(activeMods); - } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 7d2e1c9..80b9e97 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -598,7 +598,8 @@ WHOIS_NO_PUNISHMENT=§a✓ §7This player has no active punishment. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet. WHOIS_ACTIVE_MODS=§7Active Mods: WHOIS_NO_ACTIVE_MODS=§7This player has no active mods. -WHOIS_ACTIVE_MOD=§7{0} +WHOIS_ACTIVE_MOD={0} +WHOIS_PLATFORM=§7Modloader: §e{0} #VerifyCommand VERIFY_USAGE=§c/verify [Code] diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index b4f126b..5ba1edf 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -577,7 +577,8 @@ WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan. WHOIS_ACTIVE_MODS=§7Aktive Mods: WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods. -WHOIS_ACTIVE_MOD=§7{0} +WHOIS_ACTIVE_MOD={0} +WHOIS_PLATFORM=§7Modloader:§e{0} #VerifyCommand VERIFY_USAGE=§c/verify [Code] -- 2.39.2 From 798009176c327e0d207c7bff721cd4215912701f Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 13:13:19 +0100 Subject: [PATCH 05/18] fix a few small things --- .../bungeecore/commands/WhoisCommand.java | 18 ++++++------------ .../listeners/ConnectionListener.java | 3 +-- .../bungeecore/listeners/mods/Utils.java | 4 ++-- src/de/steamwar/bungeecore/sql/Mod.java | 10 +++++----- .../steamwar/messages/BungeeCore_de.properties | 2 -- 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 807dbbc..9ee5c10 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -19,7 +19,6 @@ package de.steamwar.bungeecore.commands; -import com.google.common.reflect.TypeParameter; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.mods.Utils; @@ -27,22 +26,17 @@ import de.steamwar.bungeecore.sql.*; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; -import lombok.AllArgsConstructor; import lombok.Getter; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.command.ConsoleCommandSender; -import java.net.InetSocketAddress; -import java.sql.Array; import java.sql.Timestamp; import java.text.DecimalFormat; import java.time.Instant; import java.util.*; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -74,7 +68,7 @@ public class WhoisCommand extends SWCommand { if (user == null) { Message.send("UNKNOWN_PLAYER", player); } else { - sendUserinfo(player, user, new HashSet<>(Arrays.asList(parameters))); + sendUserinfo(player, user, Arrays.asList(parameters)); } } @@ -83,7 +77,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, Set parameterTypes) { + private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, List 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()); @@ -109,17 +103,17 @@ public class WhoisCommand extends SWCommand { Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); - if(Utils.synchronizedPlayerModMap.containsKey(user.getUuid())) { - Mod.Platform modPlatform = Utils.synchronizedPlayerModMap.get(user.getUuid()).get(0).getPlatform(); + if(Utils.playerModMap.containsKey(user.getUuid())) { + Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform(); Message.send("WHOIS_PLATFORM",player,modPlatform.toString()); } if(parameterTypes.contains(WhoisParameterTypes.MOD)) { - List activeMods = Utils.synchronizedPlayerModMap.get(user.getUuid()); + List activeMods = Utils.playerModMap.get(user.getUuid()); if(!activeMods.isEmpty()) { Message.send("WHOIS_ACTIVE_MODS",player); - String result = activeMods.stream().map(mod -> mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); + String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); Message.send("WHOIS_ACTIVE_MOD", player,result); }else { Message.send("WHOIS_NO_ACTIVE_MODS",player); diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 851e0af..5256709 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -31,7 +31,6 @@ import de.steamwar.bungeecore.commands.MsgCommand; import de.steamwar.bungeecore.listeners.mods.Utils; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserGroup; -import net.md_5.bungee.Util; import net.md_5.bungee.api.AbstractReconnectHandler; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ClickEvent; @@ -137,7 +136,7 @@ public class ConnectionListener extends BasicListener { public void onDisconnect(PlayerDisconnectEvent e){ ChallengeCommand.remove(e.getPlayer()); MsgCommand.remove(e.getPlayer()); - Utils.synchronizedPlayerModMap.remove(e.getPlayer().getUniqueId()); + Utils.playerModMap.remove(e.getPlayer().getUniqueId()); } @EventHandler diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index b63b514..db569c1 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -40,7 +40,7 @@ import java.util.stream.Collectors; public class Utils { - public static final Map> synchronizedPlayerModMap = new HashMap<>(); + public static final Map> playerModMap = new HashMap<>(); private Utils(){} @@ -69,7 +69,7 @@ public class Utils { static boolean handleMods(UUID uuid, Locale locale, Consumer disconnect, List mods){ SteamwarUser user = SteamwarUser.get(uuid); boolean privileged = user.getUserGroup().privilegedMods(); - synchronizedPlayerModMap.put(uuid,new ArrayList<>(mods)); + playerModMap.put(uuid,new ArrayList<>(mods)); ModType max = ModType.YELLOW; Iterator it = mods.iterator(); diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index 039d930..6825565 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -74,11 +74,11 @@ public class Mod { } public enum ModType { - UNKLASSIFIED(0,"§7 "), - GREEN(1,"§a "), - YELLOW(2,"§e "), - RED(3,"§c "), - YOUTUBER_ONLY(4,"§6 "); + UNKLASSIFIED(0,"7"), + GREEN(1,"a"), + YELLOW(2,"e"), + RED(3,"c"), + YOUTUBER_ONLY(4,"6"); static ModType valueOf(int value){ for(ModType mt : values()){ diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 5ba1edf..10996eb 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -577,8 +577,6 @@ WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan. WHOIS_ACTIVE_MODS=§7Aktive Mods: WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods. -WHOIS_ACTIVE_MOD={0} -WHOIS_PLATFORM=§7Modloader:§e{0} #VerifyCommand VERIFY_USAGE=§c/verify [Code] -- 2.39.2 From 99deeeb173edf22424a96ffcb2bfddd154251cf8 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 13:33:09 +0100 Subject: [PATCH 06/18] Fix formatting error + revert deletion of old code --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 11 +++++++++++ src/de/steamwar/messages/BungeeCore.properties | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 440ab12..441c4c7 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -150,6 +150,17 @@ 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/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 80b9e97..156cf63 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -578,7 +578,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed. #WhoisCommand -WHOIS_USAGE=§c/whois [player/ID] <-a>,<-m> +WHOIS_USAGE=§c/whois [Spieler/ID] <-a>,<-m> WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID -- 2.39.2 From cabac4f53352618b3788d70589d7fbed605c9811 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 13:35:11 +0100 Subject: [PATCH 07/18] Revert deletion of more old unused code --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 441c4c7..02b939a 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -122,6 +122,15 @@ 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; -- 2.39.2 From 1189ee9d7745cda318e3ec2d1fa3d9acbe4a3109 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 13:37:45 +0100 Subject: [PATCH 08/18] Correct message formatting --- src/de/steamwar/messages/BungeeCore.properties | 2 +- src/de/steamwar/messages/BungeeCore_de.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 156cf63..87b925f 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -578,7 +578,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed. #WhoisCommand -WHOIS_USAGE=§c/whois [Spieler/ID] <-a>,<-m> +WHOIS_USAGE=§c§c/whois [Player/ID] [-a/-m] WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 10996eb..5adb908 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -557,7 +557,7 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen. #WhoisCommand -WHOIS_USAGE=§c/whois [Spieler/ID] <-a>,<-m> +WHOIS_USAGE=§c/whois [Spieler/ID] [-a/-m] WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_GROUP=§7Gruppe§8: {0}{1} WHOIS_UUID=§7UUID§8: §e{0} -- 2.39.2 From 391859b61ffbe1d7deffa9f9883cf0c007a595ed Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 13:39:06 +0100 Subject: [PATCH 09/18] Correct message formatting --- src/de/steamwar/messages/BungeeCore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 87b925f..f655e97 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -578,7 +578,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed. #WhoisCommand -WHOIS_USAGE=§c§c/whois [Player/ID] [-a/-m] +WHOIS_USAGE=§c/whois [Player/ID] [-a/-m] WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID -- 2.39.2 From 62484dfea26a985e8b5a692cd94222422ee7e509 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 13:41:21 +0100 Subject: [PATCH 10/18] Correct message formatting --- src/de/steamwar/messages/BungeeCore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index f655e97..1267bc6 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -578,7 +578,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed. #WhoisCommand -WHOIS_USAGE=§c/whois [Player/ID] [-a/-m] +WHOIS_USAGE=§c/whois [player/ID] [-a/-m] WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID -- 2.39.2 From b12e1ee1fa25bdafc39b810f2992a8d3d89512d3 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 16:18:07 +0100 Subject: [PATCH 11/18] 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; -- 2.39.2 From 9f6db3d639c624c67d9ebaf5cc907e717c7110dd Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 3 Jan 2023 18:22:19 +0100 Subject: [PATCH 12/18] Fix some stuff --- CommonCore | 2 +- .../bungeecore/commands/WhoisCommand.java | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CommonCore b/CommonCore index c6da22f..bf480f6 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit c6da22f0bee3865b7b3283bc17275e12c5de14af +Subproject commit bf480f6e6fc212362da34620385d4dee84250698 diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 9c426e9..6cd2570 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -104,20 +104,20 @@ public class WhoisCommand extends SWCommand { Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); - if(Utils.playerModMap.containsKey(user.getUuid())) { + if (Utils.playerModMap.containsKey(user.getUuid())) { Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform(); - Message.send("WHOIS_PLATFORM",player,modPlatform.toString()); + Message.send("WHOIS_PLATFORM", player, modPlatform.toString()); } - if(parameterTypes.contains(WhoisParameterTypes.MOD)) { + if (parameterTypes.contains(WhoisParameterTypes.MOD)) { List activeMods = Utils.playerModMap.get(user.getUuid()); - if(!activeMods.isEmpty()) { - Message.send("WHOIS_ACTIVE_MODS",player); - String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); - Message.send("WHOIS_ACTIVE_MOD", player,result); - }else { - Message.send("WHOIS_NO_ACTIVE_MODS",player); + if (!activeMods.isEmpty()) { + Message.send("WHOIS_ACTIVE_MODS", player); + String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); + Message.send("WHOIS_ACTIVE_MOD", player, result); + } else { + Message.send("WHOIS_NO_ACTIVE_MODS", player); } } @@ -168,8 +168,8 @@ 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 EnumSet userGroupSet; @@ -177,7 +177,7 @@ public class WhoisCommand extends SWCommand { private List tabCompletes; - WhoisParameterTypes(List tabCompletes,UserGroup... userGroups) { + WhoisParameterTypes(List tabCompletes, UserGroup... userGroups) { this.userGroupSet = EnumSet.copyOf(Arrays.asList(userGroups)); this.tabCompletes = tabCompletes; } -- 2.39.2 From d8d1f97790172d489959f1a873662f1ddaad5774 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 18:28:47 +0100 Subject: [PATCH 13/18] Count total size of modlist --- src/de/steamwar/bungeecore/commands/WhoisCommand.java | 2 +- src/de/steamwar/messages/BungeeCore.properties | 2 +- src/de/steamwar/messages/BungeeCore_de.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 6cd2570..c12b7ef 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -113,7 +113,7 @@ public class WhoisCommand extends SWCommand { List activeMods = Utils.playerModMap.get(user.getUuid()); if (!activeMods.isEmpty()) { - Message.send("WHOIS_ACTIVE_MODS", player); + Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size()); String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); Message.send("WHOIS_ACTIVE_MOD", player, result); } else { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 1267bc6..23060c2 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -596,7 +596,7 @@ WHOIS_PUNISHMENTS=§7Punish: WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4} WHOIS_NO_PUNISHMENT=§a✓ §7This player has no active punishment. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet. -WHOIS_ACTIVE_MODS=§7Active Mods: +WHOIS_ACTIVE_MODS=§7Active Mods ({0}): WHOIS_NO_ACTIVE_MODS=§7This player has no active mods. WHOIS_ACTIVE_MOD={0} WHOIS_PLATFORM=§7Modloader: §e{0} diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 5adb908..f9b11af 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -575,7 +575,7 @@ WHOIS_PUNISHMENTS=§7Strafen: WHOIS_PUNISHMENT=§7{0}§8» §f§l{1}: §e{2} - {3} §f{4} WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen. WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan. -WHOIS_ACTIVE_MODS=§7Aktive Mods: +WHOIS_ACTIVE_MODS=§7Aktive Mods ({0}): WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods. #VerifyCommand -- 2.39.2 From 8b96e5d853a84b3eeed700aa2bbae161d7cb89cc Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 21:33:37 +0100 Subject: [PATCH 14/18] fix lang --- src/de/steamwar/bungeecore/commands/WhoisCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index c12b7ef..b891362 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -46,7 +46,7 @@ public class WhoisCommand extends SWCommand { super("whois", "bungeecore.teamchat"); } - @Register(description = "WHOIS_COMMAND") + @Register(description = "WHOIS_USAGE") public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, WhoisParameterTypes... parameters) { SteamwarUser user = SteamwarUser.get(target); if (user == null) { -- 2.39.2 From 93d530830d93e858721b2ec661279e121e39cb3c Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 3 Jan 2023 21:38:30 +0100 Subject: [PATCH 15/18] fix nullpointer --- src/de/steamwar/bungeecore/commands/WhoisCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index b891362..8507457 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -112,7 +112,7 @@ public class WhoisCommand extends SWCommand { if (parameterTypes.contains(WhoisParameterTypes.MOD)) { List activeMods = Utils.playerModMap.get(user.getUuid()); - if (!activeMods.isEmpty()) { + if (activeMods != null && !activeMods.isEmpty()) { Message.send("WHOIS_ACTIVE_MODS", player,activeMods.size()); String result = activeMods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")); Message.send("WHOIS_ACTIVE_MOD", player, result); -- 2.39.2 From a39544abc6d05584647ee6bc29b7219b08ee5301 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 10 Jan 2023 13:34:35 +0100 Subject: [PATCH 16/18] Fix a minor unnecessary change --- src/de/steamwar/bungeecore/commands/WhoisCommand.java | 2 +- src/de/steamwar/bungeecore/listeners/mods/LabyMod.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 8507457..3ce0d2b 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -68,7 +68,7 @@ public class WhoisCommand extends SWCommand { if (user == null) { Message.send("UNKNOWN_PLAYER", player); } else { - EnumSet set = parameters.length == 0 ? EnumSet.noneOf(WhoisParameterTypes.class) : EnumSet.copyOf(Arrays.asList(parameters)); + EnumSet set = EnumSet.copyOf(Arrays.asList(parameters)); sendUserinfo(player, user, set); } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java index 6a447dd..e659b4d 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java +++ b/src/de/steamwar/bungeecore/listeners/mods/LabyMod.java @@ -33,7 +33,10 @@ import net.md_5.bungee.event.EventHandler; import java.io.IOException; import java.io.StringReader; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; public class LabyMod extends BasicListener { -- 2.39.2 From 3303362f48e67b5f67e100008b75bd782db2f318 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 13 Jan 2023 22:16:37 +0100 Subject: [PATCH 17/18] Revert CommonCore --- CommonCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommonCore b/CommonCore index bf480f6..c6da22f 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit bf480f6e6fc212362da34620385d4dee84250698 +Subproject commit c6da22f0bee3865b7b3283bc17275e12c5de14af -- 2.39.2 From 184d157276e1eb9147f276fce6fe6ac1c4e7a119 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sun, 15 Jan 2023 16:19:43 +0100 Subject: [PATCH 18/18] fix illegal argument exception --- src/de/steamwar/bungeecore/commands/WhoisCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 3ce0d2b..8507457 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -68,7 +68,7 @@ public class WhoisCommand extends SWCommand { if (user == null) { Message.send("UNKNOWN_PLAYER", player); } else { - EnumSet set = EnumSet.copyOf(Arrays.asList(parameters)); + EnumSet set = parameters.length == 0 ? EnumSet.noneOf(WhoisParameterTypes.class) : EnumSet.copyOf(Arrays.asList(parameters)); sendUserinfo(player, user, set); } } -- 2.39.2