From c2a962a86591e0c90d09e6bc8d327b3776873d87 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sun, 1 Jan 2023 16:19:57 +0100 Subject: [PATCH] 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]