From 24075306fd7526923e91b15548bdbe2a6844d655 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Fri, 11 Mar 2022 19:21:29 +0100 Subject: [PATCH 01/18] Fabric Mod Sender Integration. Mod itself is not final --- src/de/steamwar/bungeecore/BungeeCore.java | 2 + .../bungeecore/listeners/mods/Fabric.java | 45 +++++++++++++++++++ src/de/steamwar/bungeecore/sql/Mod.java | 3 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/de/steamwar/bungeecore/listeners/mods/Fabric.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index b7338af..8e9e8fd 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -70,6 +70,7 @@ public class BungeeCore extends Plugin { @Override public void onEnable(){ getProxy().registerChannel("sw:bridge"); + getProxy().registerChannel("fabricmodsender:mods"); setInstance(this); loadConfig(); @@ -86,6 +87,7 @@ public class BungeeCore extends Plugin { new ModLoaderBlocker(); new WorldDownloader(); new BrandListener(); + new Fabric(); new Node.LocalNode(); //new Node.RemoteNode("lx"); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java new file mode 100644 index 0000000..61ae91a --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -0,0 +1,45 @@ +package de.steamwar.bungeecore.listeners.mods; + +import de.steamwar.bungeecore.listeners.BasicListener; +import de.steamwar.bungeecore.sql.Mod; +import io.netty.util.internal.StringUtil; +import net.md_5.bungee.api.connection.PendingConnection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.event.EventHandler; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +public class Fabric extends BasicListener { + + @EventHandler + public void onPluginMessageEvent(PluginMessageEvent e){ + if(!e.getTag().equals("fabricmodsender:mods")) + return; + + String dataString = new String(e.getData()).substring(2); + dataString = StringUtils.chop(dataString); + char x = 34; + dataString = dataString.replace(x, ' '); + dataString = dataString.replaceAll("\\s+",""); + + String[] parts = dataString.split(","); + + List mods = new ArrayList<>(); + + for(String mod : parts) { + mods.add(Mod.get(mod, Mod.Platform.FABRIC)); + } + + if (e.getSender() instanceof ProxiedPlayer) { + ProxiedPlayer player = (ProxiedPlayer) e.getSender(); + + if(!Utils.handleMods(player, mods)) + player.disconnect(""); + } + } + +} diff --git a/src/de/steamwar/bungeecore/sql/Mod.java b/src/de/steamwar/bungeecore/sql/Mod.java index 9aad08b..dcd69ae 100644 --- a/src/de/steamwar/bungeecore/sql/Mod.java +++ b/src/de/steamwar/bungeecore/sql/Mod.java @@ -61,7 +61,8 @@ public class Mod { public enum Platform{ FORGE(0), - LABYMOD(1); + LABYMOD(1), + FABRIC(2); Platform(int value){ this.value = value; From 3ecd31c41e9b7f9b7661188b48dcd797038bc6dd Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 11:56:54 +0100 Subject: [PATCH 02/18] Parsing ist kaputt. --- .../bungeecore/listeners/mods/Fabric.java | 91 ++++++++++++++----- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 61ae91a..6037c6e 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -1,17 +1,40 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + package de.steamwar.bungeecore.listeners.mods; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; -import io.netty.util.internal.StringUtil; -import net.md_5.bungee.api.connection.PendingConnection; +import de.steamwar.bungeecore.sql.Punishment; +import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; -import org.apache.commons.lang3.StringUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; +import java.sql.Timestamp; +import java.time.Instant; +import java.util.*; +import java.util.logging.Level; public class Fabric extends BasicListener { @@ -20,26 +43,50 @@ public class Fabric extends BasicListener { if(!e.getTag().equals("fabricmodsender:mods")) return; - String dataString = new String(e.getData()).substring(2); - dataString = StringUtils.chop(dataString); - char x = 34; - dataString = dataString.replace(x, ' '); - dataString = dataString.replaceAll("\\s+",""); - - String[] parts = dataString.split(","); - - List mods = new ArrayList<>(); - - for(String mod : parts) { - mods.add(Mod.get(mod, Mod.Platform.FABRIC)); + if (!(e.getSender() instanceof ProxiedPlayer)) { + return; } - if (e.getSender() instanceof ProxiedPlayer) { - ProxiedPlayer player = (ProxiedPlayer) e.getSender(); + ProxiedPlayer player = (ProxiedPlayer) e.getSender(); - if(!Utils.handleMods(player, mods)) - player.disconnect(""); + List mods = new LinkedList<>(); + + String dataString = new String(e.getData()).substring(1); + String dataString2 = "{:" + dataString + "}"; + + System.out.println(dataString2); + + try { + JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); + + for(int i = 0; i < array.size(); i++) { + mods.add(Mod.get(array.get(i).getAsString(), Mod.Platform.FABRIC)); + } + + boolean isSorted = isSortedAlphabetically(mods); + + if(!isSorted) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte"); + return; + } + + Utils.handleMods(player,mods); + }catch (Exception ex) { + ex.printStackTrace(); + player.disconnect("§7Mod Verification failed! Contact a Developer"); } } + 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; + } } From 515c6f86f9e3761ad7cb80952776a86c442d5147 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 12:26:34 +0100 Subject: [PATCH 03/18] Parsing ist kaputt. --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 6037c6e..bce0548 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -52,9 +52,8 @@ public class Fabric extends BasicListener { List mods = new LinkedList<>(); String dataString = new String(e.getData()).substring(1); - String dataString2 = "{:" + dataString + "}"; - System.out.println(dataString2); + System.out.println(dataString); try { JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); From 3a6f3fb4c0e1976f00099ac725fc988742c48cf3 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 13:10:54 +0100 Subject: [PATCH 04/18] Parsing ist kaputt. --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index bce0548..2ec7625 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -31,6 +31,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; +import java.nio.charset.StandardCharsets; import java.sql.Timestamp; import java.time.Instant; import java.util.*; @@ -51,7 +52,7 @@ public class Fabric extends BasicListener { List mods = new LinkedList<>(); - String dataString = new String(e.getData()).substring(1); + String dataString = new String(e.getData(), StandardCharsets.UTF_8).substring(1); System.out.println(dataString); From 657c03dff17fce850d309f0e88c18ef6adcd09ad Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 13:35:59 +0100 Subject: [PATCH 05/18] Parsing funktioniert + notwendige mods check --- .../bungeecore/listeners/mods/Fabric.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 2ec7625..6a9c30e 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -39,6 +39,15 @@ import java.util.logging.Level; public class Fabric extends BasicListener { + private final List neededMods = new LinkedList<>(); + + { + neededMods.add("java"); + neededMods.add("minecraft"); + neededMods.add("fabricloader"); + neededMods.add("steamwarmodsender"); + } + @EventHandler public void onPluginMessageEvent(PluginMessageEvent e){ if(!e.getTag().equals("fabricmodsender:mods")) @@ -52,9 +61,12 @@ public class Fabric extends BasicListener { List mods = new LinkedList<>(); - String dataString = new String(e.getData(), StandardCharsets.UTF_8).substring(1); + byte[] data = e.getData(); + Utils.VarInt varInt = Utils.readVarInt(data,0); - System.out.println(dataString); + data = Arrays.copyOfRange(data,varInt.length, data.length); + + String dataString = new String(data, StandardCharsets.UTF_8); try { JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); @@ -68,7 +80,14 @@ public class Fabric extends BasicListener { if(!isSorted) { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte"); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); + return; + } + + if(!modsAreAbsent(mods)) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); return; } @@ -89,4 +108,12 @@ public class Fabric extends BasicListener { } return isSorted; } + + private boolean modsAreAbsent(List mods) { + return mods.stream() + .map(Mod::getModName) + .filter(neededMods::contains) + .distinct() + .count() == neededMods.size(); + } } From c239dc780968b7a8b25e46e468ec59315a70d505 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 12 Mar 2022 13:54:23 +0100 Subject: [PATCH 06/18] Allow Fabric on Fight Servers --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 10 +++++++++- .../bungeecore/listeners/mods/ModLoaderBlocker.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 6a9c30e..2f1c1bb 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -23,11 +23,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; @@ -40,6 +42,7 @@ import java.util.logging.Level; public class Fabric extends BasicListener { private final List neededMods = new LinkedList<>(); + public static final Set checkedPlayers = new HashSet(); { neededMods.add("java"); @@ -91,13 +94,18 @@ public class Fabric extends BasicListener { return; } - Utils.handleMods(player,mods); + if(Utils.handleMods(player,mods)) checkedPlayers.add(player); }catch (Exception ex) { ex.printStackTrace(); player.disconnect("§7Mod Verification failed! Contact a Developer"); } } + @EventHandler + public void onDisconnect(PlayerDisconnectEvent e){ + checkedPlayers.remove(e.getPlayer()); + } + private boolean isSortedAlphabetically(List mods) { boolean isSorted = true; for(int i = 0; i < mods.size() - 1; i++) { diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index a4d54e6..d347d42 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -73,7 +73,7 @@ public class ModLoaderBlocker extends BasicListener { } public static boolean isFabric(ProxiedPlayer player) { - return Storage.fabricPlayers.contains(player); + return Storage.fabricPlayers.contains(player) && !Fabric.checkedPlayers.contains(player); } public static void addServer(String server) { From 72a5027de084cf35c623ebcb929d1bec2bf4320b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 22 Mar 2022 19:07:47 +0100 Subject: [PATCH 07/18] Fix precision Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/TutorialCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/TutorialCommand.java b/src/de/steamwar/bungeecore/commands/TutorialCommand.java index 3a031e5..4f55742 100644 --- a/src/de/steamwar/bungeecore/commands/TutorialCommand.java +++ b/src/de/steamwar/bungeecore/commands/TutorialCommand.java @@ -129,7 +129,7 @@ public class TutorialCommand extends BasicCommand { List lore = new ArrayList<>(); lore.add(Message.parse("TUTORIAL_BY", player, tutorial.creator().getUserName())); - lore.add(Message.parse("TUTORIAL_STARS", player, tutorial.stars())); + lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.stars()))); if (personalHighlights) lore.add(Message.parse("TUTORIAL_DELETE", player)); From d500c376fa30f10d94852480690e3bbdaf8883f4 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 17:02:42 +0100 Subject: [PATCH 08/18] Messages --- .../bungeecore/listeners/mods/Fabric.java | 86 +++++++++++-------- .../listeners/mods/ModLoaderBlocker.java | 2 +- .../steamwar/messages/BungeeCore.properties | 5 ++ 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 2f1c1bb..3119452 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -19,10 +19,9 @@ package de.steamwar.bungeecore.listeners.mods; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.google.gson.*; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; @@ -34,6 +33,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; import java.nio.charset.StandardCharsets; +import java.nio.charset.UnsupportedCharsetException; import java.sql.Timestamp; import java.time.Instant; import java.util.*; @@ -41,8 +41,7 @@ import java.util.logging.Level; public class Fabric extends BasicListener { - private final List neededMods = new LinkedList<>(); - public static final Set checkedPlayers = new HashSet(); + private final Set neededMods = new HashSet<>(); { neededMods.add("java"); @@ -61,6 +60,7 @@ public class Fabric extends BasicListener { } ProxiedPlayer player = (ProxiedPlayer) e.getSender(); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); List mods = new LinkedList<>(); @@ -69,41 +69,46 @@ public class Fabric extends BasicListener { data = Arrays.copyOfRange(data,varInt.length, data.length); - String dataString = new String(data, StandardCharsets.UTF_8); + if(data.length != varInt.length + varInt.value) { + banPlayer(user,player); + } + + String dataString = ""; + + try{ + dataString = new String(data, StandardCharsets.UTF_8); + }catch (UnsupportedCharsetException exception) { + banPlayer(user, player); + } + + JsonArray array = new JsonArray(); try { - JsonArray array = new JsonParser().parse(dataString).getAsJsonArray(); - - for(int i = 0; i < array.size(); i++) { - mods.add(Mod.get(array.get(i).getAsString(), Mod.Platform.FABRIC)); - } - - boolean isSorted = isSortedAlphabetically(mods); - - if(!isSorted) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); - return; - } - - if(!modsAreAbsent(mods)) { - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte."); - return; - } - - if(Utils.handleMods(player,mods)) checkedPlayers.add(player); - }catch (Exception ex) { - ex.printStackTrace(); - player.disconnect("§7Mod Verification failed! Contact a Developer"); + array = new JsonParser().parse(dataString).getAsJsonArray(); + }catch (JsonSyntaxException exception) { + banPlayer(user, player); } - } - @EventHandler - public void onDisconnect(PlayerDisconnectEvent e){ - checkedPlayers.remove(e.getPlayer()); + for(JsonElement mod : array) { + mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC)); + } + + boolean isSorted = isSortedAlphabetically(mods); + + if(!isSorted) { + banPlayer(user, player); + return; + } + + if(!modsAreAbsent(mods)) { + banPlayer(user, player); + return; + } + + if(Utils.handleMods(player,mods)) { + Storage.fabricPlayers.remove(player); + Message.send("MODIFICATION_CHECK_SUCCESS", player); + } } private boolean isSortedAlphabetically(List mods) { @@ -124,4 +129,13 @@ public class Fabric extends BasicListener { .distinct() .count() == neededMods.size(); } + + public void banPlayer(SteamwarUser user, ProxiedPlayer player) { + user.punish(Punishment.PunishmentType.Ban, + Timestamp.from(Instant.now()), + Message.parse("MODIFICATION_BAN_MESSAGE", player), + 0, + true); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player)); + } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index d347d42..a4d54e6 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -73,7 +73,7 @@ public class ModLoaderBlocker extends BasicListener { } public static boolean isFabric(ProxiedPlayer player) { - return Storage.fabricPlayers.contains(player) && !Fabric.checkedPlayers.contains(player); + return Storage.fabricPlayers.contains(player); } public static void addServer(String server) { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 19226ef..00c88de 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -583,3 +583,8 @@ RANK_UNPLACED=§eunplatziert RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8. RANK_EMBLEM=§eEmblem§8: {0} RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) + +#Fabric Mod Sender +MODIFICATION_BAN_MESSAGE = "Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" +MODIFICATION_BAN_LOG = " hat probiert den Fabric Mod Sender zu editieren / umzugehen!" +MODIFICATION_CHECK_SUCCESS = "§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" From 1675b1dc9cd29312806655e33a7bea15b9db7078 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 17:03:31 +0100 Subject: [PATCH 09/18] Fix Error --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 3119452..19e53a2 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -67,12 +67,12 @@ public class Fabric extends BasicListener { byte[] data = e.getData(); Utils.VarInt varInt = Utils.readVarInt(data,0); - data = Arrays.copyOfRange(data,varInt.length, data.length); - if(data.length != varInt.length + varInt.value) { banPlayer(user,player); } + data = Arrays.copyOfRange(data,varInt.length, data.length); + String dataString = ""; try{ From a7525dd8a1b6ae2050c24828a2fe616c3e57c6eb Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 17:04:38 +0100 Subject: [PATCH 10/18] Fix Error --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index 19e53a2..e80cfce 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -28,7 +28,6 @@ import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; @@ -69,24 +68,27 @@ public class Fabric extends BasicListener { if(data.length != varInt.length + varInt.value) { banPlayer(user,player); + return; } data = Arrays.copyOfRange(data,varInt.length, data.length); - String dataString = ""; + String dataString; try{ dataString = new String(data, StandardCharsets.UTF_8); }catch (UnsupportedCharsetException exception) { banPlayer(user, player); + return; } - JsonArray array = new JsonArray(); + JsonArray array; try { array = new JsonParser().parse(dataString).getAsJsonArray(); }catch (JsonSyntaxException exception) { banPlayer(user, player); + return; } for(JsonElement mod : array) { From 98326fcaa0ea1301833773dca3fd12c826e47a2b Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Wed, 23 Mar 2022 19:24:44 +0100 Subject: [PATCH 11/18] Fix Errors --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 9 ++++----- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index e80cfce..afff053 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -102,7 +102,7 @@ public class Fabric extends BasicListener { return; } - if(!modsAreAbsent(mods)) { + if(!neededModsContained(mods)) { banPlayer(user, player); return; } @@ -124,20 +124,19 @@ public class Fabric extends BasicListener { return isSorted; } - private boolean modsAreAbsent(List mods) { + private boolean neededModsContained(List mods) { return mods.stream() .map(Mod::getModName) .filter(neededMods::contains) - .distinct() .count() == neededMods.size(); } public void banPlayer(SteamwarUser user, ProxiedPlayer player) { user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), - Message.parse("MODIFICATION_BAN_MESSAGE", player), + Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()), 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player)); + BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 00c88de..cba41eb 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -585,6 +585,6 @@ RANK_EMBLEM=§eEmblem§8: {0} RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) #Fabric Mod Sender -MODIFICATION_BAN_MESSAGE = "Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" -MODIFICATION_BAN_LOG = " hat probiert den Fabric Mod Sender zu editieren / umzugehen!" -MODIFICATION_CHECK_SUCCESS = "§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" +MODIFICATION_BAN_MESSAGE="Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" +MODIFICATION_BAN_LOG= "{0} hat probiert den Fabric Mod Sender zu editieren / umzugehen!" +MODIFICATION_CHECK_SUCCESS="§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" From 756b4da84e63215377ef1ab9823b572142d61f03 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 24 Mar 2022 13:59:14 +0100 Subject: [PATCH 12/18] Fix Errors --- src/de/steamwar/bungeecore/listeners/mods/Fabric.java | 2 +- src/de/steamwar/messages/BungeeCore.properties | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java index afff053..90365cd 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Fabric.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Fabric.java @@ -137,6 +137,6 @@ public class Fabric extends BasicListener { Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()), 0, true); - BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); + BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index cba41eb..d8b87bf 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -585,6 +585,6 @@ RANK_EMBLEM=§eEmblem§8: {0} RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8) #Fabric Mod Sender -MODIFICATION_BAN_MESSAGE="Du hast probiert den FabricModSender zu umgehen / zu modifizieren!" -MODIFICATION_BAN_LOG= "{0} hat probiert den Fabric Mod Sender zu editieren / umzugehen!" -MODIFICATION_CHECK_SUCCESS="§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!" +MODIFICATION_BAN_MESSAGE=Du hast probiert den FabricModSender zu umgehen / zu modifizieren! +MODIFICATION_BAN_LOG={0} hat probiert den Fabric Mod Sender zu editieren / umzugehen! +MODIFICATION_CHECK_SUCCESS=§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen! From d2d8e8af6ded6caa955644063cbd19748267f2f9 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 27 Mar 2022 21:08:52 +0200 Subject: [PATCH 13/18] Hotfix name issue Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ServerStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 622b7a4..7d63fb7 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -46,7 +46,7 @@ public class ServerStarter { public ServerStarter arena(ArenaMode mode, String map) { portrange = ARENA_PORTS; - serverNameProvider = port -> mode.getChatName() + (port - portrange.start); + serverNameProvider = port -> mode.getDisplayName() + (port - portrange.start); serverJar = mode.serverJar(); directory = new File(SERVER_PATH, mode.getFolder()); arguments.put("config", mode.getConfig()); From 9a17bb87f65e6dbadff55f4105230839a7647fea Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 30 Mar 2022 10:39:47 +0200 Subject: [PATCH 14/18] Remove unrequired commands Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 2 - .../bungeecore/commands/DenyCommand.java | 39 ------------------- .../commands/ResourcereloadCommand.java | 36 ----------------- 3 files changed, 77 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/commands/DenyCommand.java delete mode 100644 src/de/steamwar/bungeecore/commands/ResourcereloadCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 6ba5f08..7b9d428 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -104,7 +104,6 @@ public class BungeeCore extends Plugin { new JoinmeCommand(); new TpCommand(); new HelpCommand(); - new DenyCommand("watchcat", "wc"); new TeamCommand(); new ServerTeamchatCommand(); new DevCommand(); @@ -118,7 +117,6 @@ public class BungeeCore extends Plugin { new IgnoreCommand(); new UnIgnoreCommand(); new PollresultCommand(); - new ResourcereloadCommand(); new ListCommand(); new StatCommand(); new VerifyCommand(); diff --git a/src/de/steamwar/bungeecore/commands/DenyCommand.java b/src/de/steamwar/bungeecore/commands/DenyCommand.java deleted file mode 100644 index b6738d8..0000000 --- a/src/de/steamwar/bungeecore/commands/DenyCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bungeecore.commands; - -import de.steamwar.bungeecore.Message; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class DenyCommand extends BasicCommand { - - public DenyCommand(String cmd, String ...aliases) { - super(cmd, "", aliases); - } - - @Override - public void execute(CommandSender sender, String[] args) { - if(sender instanceof ProxiedPlayer){ - ProxiedPlayer player = (ProxiedPlayer) sender; - Message.send("UNKNOWN_COMMAND", player); - } - } -} diff --git a/src/de/steamwar/bungeecore/commands/ResourcereloadCommand.java b/src/de/steamwar/bungeecore/commands/ResourcereloadCommand.java deleted file mode 100644 index 0789c48..0000000 --- a/src/de/steamwar/bungeecore/commands/ResourcereloadCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ - -package de.steamwar.bungeecore.commands; - -import net.md_5.bungee.api.CommandSender; - -import java.util.ResourceBundle; - -public class ResourcereloadCommand extends BasicCommand { - - public ResourcereloadCommand() { - super("resourcereload", "bungeecore.softreload", "rr"); - } - - @Override - public void execute(CommandSender commandSender, String[] strings) { - ResourceBundle.clearCache(); - } -} From bc8db04edfc54bd43551f7794b12deb5e0257774 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 30 Mar 2022 11:38:29 +0200 Subject: [PATCH 15/18] 1.18 Bau Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ServerStarter.java | 9 ++ .../bungeecore/commands/BauCommand.java | 151 +++++++++--------- 2 files changed, 88 insertions(+), 72 deletions(-) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 7d63fb7..8b2808f 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -26,6 +26,7 @@ public class ServerStarter { private static final String EVENT_PATH = BACKBONE + "event/"; public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/"; public static final String TUTORIAL_PATH = BACKBONE + "tutorials/"; + public static final String WORLDS18_PATH = BACKBONE + "userworlds18/"; private File directory = null; private String worldDir = null; @@ -100,6 +101,14 @@ public class ServerStarter { return this; } + public ServerStarter build18(UUID owner) { + directory = new File(SERVER_PATH, "Bau18"); + worldDir = WORLDS18_PATH; + worldName = String.valueOf(SteamwarUser.get(owner).getId()); + buildWithWorld(owner, new File(directory, "Bauwelt").getPath()); + return this; + } + public ServerStarter build15(UUID owner) { directory = new File(SERVER_PATH, "Bau15"); worldDir = BungeeCore.USERWORLDS15; diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 5a58a73..93c4866 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -33,7 +33,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; public class BauCommand extends BasicCommand { public BauCommand(){ - super("bau", null, "b", "gs"); + super("bau", null, "b", "build", "gs"); } @Override @@ -44,58 +44,44 @@ public class BauCommand extends BasicCommand { ProxiedPlayer p = (ProxiedPlayer) sender; - if(args.length == 0){ - (bau15(p, args, 0) ? new ServerStarter().build15(p.getUniqueId()) : new ServerStarter().build12(p.getUniqueId())).send(p).start(); - return; - } - - switch(args[0].toLowerCase()){ - case "12": - case "1.12": - new ServerStarter().build12(p.getUniqueId()).send(p).start(); - break; - case "ws": - case "warship": - case "as": - case "airship": - case "mwg": - case "miniwargear": - case "wg": - case "wargear": - case "15": - case "1.15": - new ServerStarter().build15(p.getUniqueId()).send(p).start(); - break; - case "addmember": - addmember(p, args); - break; - case "tp": - case "teleport": - teleport(p, args); - break; - case "info": - p.chat("/bauinfo"); - break; - case "togglewe": - togglewe(p, args); - break; - case "toggleworld": - toggleworld(p, args); - break; - case "delmember": - delmember(p, args); - break; - case "resetall": - case "delete": - delete(p, args); - break; - case "testarena": - case "test": - testarena(p, args); - break; - default: - HelpCommand.sendBauHelp(p); - } + versionSelector(p, args, 0, + () -> new ServerStarter().build18(p.getUniqueId()).send(p).start(), + () -> new ServerStarter().build15(p.getUniqueId()).send(p).start(), + () -> new ServerStarter().build12(p.getUniqueId()).send(p).start(), + () -> { + switch (args[0].toLowerCase()) { + case "addmember": + addmember(p, args); + break; + case "tp": + case "teleport": + teleport(p, args); + break; + case "info": + p.chat("/bauinfo"); + break; + case "togglewe": + togglewe(p, args); + break; + case "toggleworld": + toggleworld(p, args); + break; + case "delmember": + delmember(p, args); + break; + case "resetall": + case "delete": + delete(p, args); + break; + case "testarena": + case "test": + testarena(p, args); + break; + default: + HelpCommand.sendBauHelp(p); + } + } + ); } private static void addmember(ProxiedPlayer p, String[] args){ @@ -140,19 +126,31 @@ public class BauCommand extends BasicCommand { return; } - (bau15(p, args, 2) ? new ServerStarter().build15(worldOwner.getUuid()) : new ServerStarter().build12(worldOwner.getUuid())).send(p).start(); + versionSelector(p, args, 2, + () -> new ServerStarter().build18(worldOwner.getUuid()).send(p).start(), + () -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(), + () -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(), + () -> HelpCommand.sendBauHelp(p)); } - private static boolean bau15(ProxiedPlayer p, String[] args, int pos){ - if(args.length <= pos) - return p.getPendingConnection().getVersion() > 340; // Version > 1.12.2 + private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) { + if(args.length <= pos) { + int version = p.getPendingConnection().getVersion(); + if(version > 340) { // Version > 1.12.2 + run15.run(); + } else { + run12.run(); + } + return; + } - switch(args[pos].toLowerCase()){ + switch (args[pos].toLowerCase()) { + case "18": + case "1.18": + run18.run(); + break; case "ws": case "warship": - case "12": - case "1.12": - return false; case "as": case "airship": case "mwg": @@ -161,9 +159,14 @@ public class BauCommand extends BasicCommand { case "wargear": case "15": case "1.15": - return true; + run15.run(); + break; + case "12": + case "1.12": + run12.run(); + break; default: - return p.getPendingConnection().getVersion() > 340; // Version > 1.12.2 + runElse.run(); } } @@ -225,18 +228,22 @@ public class BauCommand extends BasicCommand { } private static void delete(ProxiedPlayer p, String[] args){ + SteamwarUser user = SteamwarUser.get(p.getUniqueId()); + versionSelector(p, args, 1, + () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS18_PATH + user.getId())), + () -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())), + () -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())), + () -> HelpCommand.sendBauHelp(p)); + } + + private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) { SWInventory inventory = new SWInventory(p, 9, Message.parse("BAU_DELETE_GUI_NAME", p)); inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click -> - inventory.close() + inventory.close() + ); + inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> + worldDeletion.run() ); - inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> { - if(bau15(p, args, 1)){ - SteamwarUser user = SteamwarUser.get(p.getUniqueId()); - deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId()); - }else{ - deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString()); - } - }); inventory.open(); } From 82bd4b752d446064b74f7951b9d825dc314781ee Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 30 Mar 2022 14:43:54 +0200 Subject: [PATCH 16/18] Fix 1.18 Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ServerStarter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 8b2808f..1128b7d 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -103,6 +103,7 @@ public class ServerStarter { public ServerStarter build18(UUID owner) { directory = new File(SERVER_PATH, "Bau18"); + serverJar = "paper-1.18.2.jar"; worldDir = WORLDS18_PATH; worldName = String.valueOf(SteamwarUser.get(owner).getId()); buildWithWorld(owner, new File(directory, "Bauwelt").getPath()); From 385f5a5a369f29cd88ce22f3179287ce49ccc4d0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 30 Mar 2022 18:32:07 +0200 Subject: [PATCH 17/18] Fix concurrency Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/UserElo.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/sql/UserElo.java b/src/de/steamwar/bungeecore/sql/UserElo.java index ca7e723..6740966 100644 --- a/src/de/steamwar/bungeecore/sql/UserElo.java +++ b/src/de/steamwar/bungeecore/sql/UserElo.java @@ -26,15 +26,16 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; public class UserElo { private UserElo() {} public static final int ELO_DEFAULT = 1000; - private static final Map>> gameModeUserEloCache = new HashMap<>(); - private static final Map maxEloCache = new HashMap<>(); - private static final Map emblemCache = new HashMap<>(); + private static final Map>> gameModeUserEloCache = new ConcurrentHashMap<>(); + private static final Map maxEloCache = new ConcurrentHashMap<>(); + private static final Map emblemCache = new ConcurrentHashMap<>(); private static final Statement elo = new Statement("SELECT Elo FROM UserElo WHERE UserID = ? AND GameMode = ? AND Season = ?"); private static final Statement setElo = new Statement("INSERT INTO UserElo (Season, GameMode, UserID, Elo) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)"); From 3b358a86663ca0e4ce87e8ac1f96f35846d1cba8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 30 Mar 2022 18:34:21 +0200 Subject: [PATCH 18/18] Fix GDPRQuery Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/GDPRQuery.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/GDPRQuery.java b/src/de/steamwar/bungeecore/commands/GDPRQuery.java index bb98fca..444a22c 100644 --- a/src/de/steamwar/bungeecore/commands/GDPRQuery.java +++ b/src/de/steamwar/bungeecore/commands/GDPRQuery.java @@ -60,7 +60,7 @@ public class GDPRQuery extends BasicCommand { sqlCSV(user, out, bauweltMember, "BuildMember.csv"); sqlCSV(user, out, bauweltMembers, "BuildMembers.csv"); sqlCSV(user, out, checkedSchems, "SchematicChecksessions.csv"); - sqlCSV(user, out, elo, "Elo.csv"); + sqlCSV(user, out, userElo, "UserElo.csv"); sqlCSV(user, out, fights, "Fights.csv"); sqlCSV(user, out, ignoredPlayers, "IgnoredPlayers.csv"); sqlCSV(user, out, ignoringPlayers, "IgnoringPlayers.csv"); @@ -88,8 +88,8 @@ public class GDPRQuery extends BasicCommand { private static final Statement bauweltMember = new Statement("SELECT BauweltID AS Bauwelt, WorldEdit, World FROM BauweltMember WHERE MemberID = ?"); private static final Statement bauweltMembers = new Statement("SELECT u.UserName AS 'User', m.WorldEdit AS WorldEdit, m.World AS World FROM BauweltMember m INNER JOIN UserData u ON m.MemberID = u.id WHERE m.BauweltID = ?"); private static final Statement checkedSchems = new Statement("SELECT NodeName AS Schematic, StartTime, EndTime, DeclineReason AS Result FROM CheckedSchematic WHERE NodeOwner = ? ORDER BY StartTime ASC"); - private static final Statement elo = new Statement("SELECT GameMode, Elo FROM Elo WHERE UserID = ?"); - private static final Statement fights = new Statement("SELECT p.Team AS Team, p.Kit AS Kit, p.Kills AS Kills, p.IsOut AS Died, f.GameMode AS GameMode, f.Server AS Server, f.Arena AS Arena, f.StartTime AS StartTime, f.Duration AS Duration, (f.BlueLeader = p.UserID) AS IsBlueLeader, (f.RedLeader = p.UserID) AS IsRedLeader, f.Win AS Winner, f.WinCondition AS WinCondition FROM Fight f INNER JOIN FightPlayer p ON f.FightID = p.FightID WHERE p.UserID = ? ORDER BY StartTime ASC"); + private static final Statement userElo = new Statement("SELECT GameMode, Elo, Season FROM Elo WHERE UserID = ?"); + private static final Statement fights = new Statement("SELECT p.Team AS Team, p.Kit AS Kit, p.Kills AS Kills, p.IsOut AS Died, f.GameMode AS GameMode, f.Server AS Server, f.StartTime AS StartTime, f.Duration AS Duration, (f.BlueLeader = p.UserID) AS IsBlueLeader, (f.RedLeader = p.UserID) AS IsRedLeader, f.Win AS Winner, f.WinCondition AS WinCondition FROM Fight f INNER JOIN FightPlayer p ON f.FightID = p.FightID WHERE p.UserID = ? ORDER BY StartTime ASC"); private static final Statement ignoredPlayers = new Statement("SELECT u.UserName AS IgnoredPlayer FROM IgnoredPlayers i INNER JOIN UserData u ON i.Ignored = u.id WHERE Ignorer = ?"); private static final Statement ignoringPlayers = new Statement("SELECT Ignorer AS IgnoringPlayers FROM IgnoredPlayers WHERE Ignored = ?"); private static final Statement schematicMember = new Statement("SELECT s.NodeName AS SchematicName, u.UserName AS SchematicOwner FROM NodeMember m INNER JOIN SchematicNode s ON m.NodeId = s.NodeId INNER JOIN UserData u ON s.NodeOwner = u.id WHERE m.UserId = ?");