From 7639a6ad467bf7f3874d3cd4e875cdb6cce3e965 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 13 May 2022 20:47:02 +0200 Subject: [PATCH 01/14] New 1.18 crash detector --- .../src/de/steamwar/core/Core.java | 5 ++ .../src/de/steamwar/core/CrashDetector.java | 64 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 SpigotCore_Main/src/de/steamwar/core/CrashDetector.java diff --git a/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java index 1ef9272..5bc007c 100644 --- a/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -84,6 +84,7 @@ public class Core extends JavaPlugin{ } private ErrorHandler errorHandler; + private CrashDetector crashDetector; @Override public void onLoad() { @@ -94,6 +95,8 @@ public class Core extends JavaPlugin{ public void onEnable() { setSqlConfig(); errorHandler = new ErrorHandler(); + if(VERSION > 15) + crashDetector = new CrashDetector(); Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this); Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this); @@ -112,6 +115,8 @@ public class Core extends JavaPlugin{ @Override public void onDisable() { TinyProtocol.instance.close(); + if(VERSION > 15) + crashDetector.stop(); errorHandler.unregister(); if(!standalone) { Statement.close(); diff --git a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java new file mode 100644 index 0000000..f62070a --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java @@ -0,0 +1,64 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 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.core; + +import de.steamwar.sql.SWException; +import org.bukkit.Bukkit; + +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +public class CrashDetector { + + private static final long TIMEOUT = 20000; + private final AtomicLong lastTick = new AtomicLong(Long.MAX_VALUE); + private final Thread mainThread = Thread.currentThread(); + private final Thread watchdog; + + private boolean run = true; + + public CrashDetector () { + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> lastTick.set(System.currentTimeMillis()), 0, 1); + watchdog = new Thread(this::run, "SteamWar Watchdog"); + watchdog.setDaemon(true); + watchdog.start(); + } + + public void stop() { + run = false; + watchdog.interrupt(); + } + + private void run() { + while (run) { + long curTime = System.currentTimeMillis(); + if(curTime + TIMEOUT > lastTick.get()) { + SWException.log(Bukkit.getServer().getVersion() + " server hung for " + (curTime - lastTick.get()) + "ms, ", Arrays.stream(mainThread.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n"))); + lastTick.set(curTime); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + } +} From b673dffe4c7cab346745e383e02a54970cdf9ae0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 13 May 2022 21:06:15 +0200 Subject: [PATCH 02/14] Fix crash detector --- SpigotCore_Main/src/de/steamwar/core/CrashDetector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java index f62070a..be02e4f 100644 --- a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java +++ b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java @@ -50,7 +50,7 @@ public class CrashDetector { private void run() { while (run) { long curTime = System.currentTimeMillis(); - if(curTime + TIMEOUT > lastTick.get()) { + if(curTime > lastTick.get() + TIMEOUT) { SWException.log(Bukkit.getServer().getVersion() + " server hung for " + (curTime - lastTick.get()) + "ms, ", Arrays.stream(mainThread.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n"))); lastTick.set(curTime); } From d2a4f1a3296cc2a65ad96b06c856768655afd54c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 13 May 2022 21:17:41 +0200 Subject: [PATCH 03/14] Small crash detector overflow fix --- SpigotCore_Main/src/de/steamwar/core/CrashDetector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java index be02e4f..76cd8a8 100644 --- a/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java +++ b/SpigotCore_Main/src/de/steamwar/core/CrashDetector.java @@ -50,7 +50,7 @@ public class CrashDetector { private void run() { while (run) { long curTime = System.currentTimeMillis(); - if(curTime > lastTick.get() + TIMEOUT) { + if(curTime - TIMEOUT > lastTick.get()) { SWException.log(Bukkit.getServer().getVersion() + " server hung for " + (curTime - lastTick.get()) + "ms, ", Arrays.stream(mainThread.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n"))); lastTick.set(curTime); } From fec1265a9b7d59a44a796cc03c748ee3f725171c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 20 May 2022 14:26:09 +0200 Subject: [PATCH 04/14] Fix locale conversion --- SpigotCore_12/src/de/steamwar/core/WorldOfColorWrapper12.java | 2 +- SpigotCore_8/src/de/steamwar/core/WorldOfColorWrapper8.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SpigotCore_12/src/de/steamwar/core/WorldOfColorWrapper12.java b/SpigotCore_12/src/de/steamwar/core/WorldOfColorWrapper12.java index f6c5050..8214a6c 100644 --- a/SpigotCore_12/src/de/steamwar/core/WorldOfColorWrapper12.java +++ b/SpigotCore_12/src/de/steamwar/core/WorldOfColorWrapper12.java @@ -27,6 +27,6 @@ public class WorldOfColorWrapper12 implements WorldOfColorWrapper.IWorldOfColorW @Override public Locale getLocale(Player player){ - return Locale.forLanguageTag(player.getLocale()); + return Locale.forLanguageTag(player.getLocale().replace('_', '-')); } } diff --git a/SpigotCore_8/src/de/steamwar/core/WorldOfColorWrapper8.java b/SpigotCore_8/src/de/steamwar/core/WorldOfColorWrapper8.java index 73cf7fd..457dea2 100644 --- a/SpigotCore_8/src/de/steamwar/core/WorldOfColorWrapper8.java +++ b/SpigotCore_8/src/de/steamwar/core/WorldOfColorWrapper8.java @@ -27,6 +27,6 @@ public class WorldOfColorWrapper8 implements WorldOfColorWrapper.IWorldOfColorWr @Override public Locale getLocale(Player player){ - return Locale.forLanguageTag(player.spigot().getLocale()); + return Locale.forLanguageTag(player.spigot().getLocale().replace('_', '-')); } } From e62ad60dded1e28e351be9c393633ac5fd04ada6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 20 May 2022 17:46:06 +0200 Subject: [PATCH 05/14] Add initial english --- SpigotCore_Main/src/SpigotCore.properties | 88 +++++++-------- SpigotCore_Main/src/SpigotCore_de.properties | 106 +++++++++++++++++++ SpigotCore_Main/src/SpigotCore_en.properties | 0 3 files changed, 147 insertions(+), 47 deletions(-) create mode 100644 SpigotCore_Main/src/SpigotCore_de.properties delete mode 100644 SpigotCore_Main/src/SpigotCore_en.properties diff --git a/SpigotCore_Main/src/SpigotCore.properties b/SpigotCore_Main/src/SpigotCore.properties index 894dbf0..ca1a62c 100644 --- a/SpigotCore_Main/src/SpigotCore.properties +++ b/SpigotCore_Main/src/SpigotCore.properties @@ -36,30 +36,30 @@ SCHEM_SELECTOR_FILTER=§7Filter SCHEM_SELECTOR_SORTING=§7Sortierung SCHEM_SELECTOR_SORTING_CURRENT=§7Aktuell: §e{0} SCHEM_SELECTOR_SORTING_NAME=Name -SCHEM_SELECTOR_SORTING_TYPE=Schematic-Typ -SCHEM_SELECTOR_SORTING_UPDATE=Letztes Update -SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0} -SCHEM_SELECTOR_SORTING_ASC=Aufsteigend -SCHEM_SELECTOR_SORTING_DSC=Absteigend +SCHEM_SELECTOR_SORTING_TYPE=Schematic-Type +SCHEM_SELECTOR_SORTING_UPDATE=Last update +SCHEM_SELECTOR_SORTING_DIRECTION=§7Ordering: §e{0} +SCHEM_SELECTOR_SORTING_ASC=Ascending +SCHEM_SELECTOR_SORTING_DSC=Descending SCHEM_SELECTOR_ITEM_NAME=§e{0} SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0} SCHEM_SELECTOR_ITEM_REPLACE=§e{0}§7 SCHEM_SELECTOR_ITEM_LORE_TYPE=§7{0} -SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen +SCHEM_SELECTOR_CREATE_DIR_TITLE=Create directory SCHEM_SELECTOR_FILTER_TITLE=Filter -SCHEM_SELECTOR_FILTER_ENTER_NAME=Name eingeben -SCHEM_SELECTOR_FILTER_NAME=§7Nach Namen suchen... -SCHEM_SELECTOR_FILTER_NAME_SEARCH=§7Suchbegriff: §e{0} -SCHEM_SELECTOR_FILTER_ENTER_OWNER=Besitzer eingeben -SCHEM_SELECTOR_FILTER_OWNER=§7Nach Besitzer suchen... -SCHEM_SELECTOR_FILTER_OWNER_SEARCH=§7Besitzer: §e{0} -SCHEM_SELECTOR_FILTER_SEL_TYPE=Typ wählen... -SCHEM_SELECTOR_FILTER_TYPE=§7Nach Typ filtern... -SCHEM_SELECTOR_FILTER_TYPE_SEARCH=§7Typ: §e{0} -SCHEM_SELECTOR_FILTER_MAT=§7Nach Item filtern... +SCHEM_SELECTOR_FILTER_ENTER_NAME=Insert name +SCHEM_SELECTOR_FILTER_NAME=§7Search by name... +SCHEM_SELECTOR_FILTER_NAME_SEARCH=§7Search term: §e{0} +SCHEM_SELECTOR_FILTER_ENTER_OWNER=Choose owner +SCHEM_SELECTOR_FILTER_OWNER=§7Search by owner... +SCHEM_SELECTOR_FILTER_OWNER_SEARCH=§7Owner: §e{0} +SCHEM_SELECTOR_FILTER_SEL_TYPE=Choose type... +SCHEM_SELECTOR_FILTER_TYPE=§7Search by type... +SCHEM_SELECTOR_FILTER_TYPE_SEARCH=§7Type: §e{0} +SCHEM_SELECTOR_FILTER_MAT=§7Filter by item... SCHEM_SELECTOR_FILTER_MAT_SEARCH=§7Item: §e{0} SCHEM_SELECTOR_CANCEL=§eAbbrechen SCHEM_SELECTOR_GO=§eSuchen... @@ -69,38 +69,32 @@ SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Ordner MATERIAL_SELECTOR_TITLE=Material auswählen -BAN_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4} -BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0} -BAN_UNTIL=§7Du bist §ebis zum {0} §e§lgebannt§8. §7Grund§8: §e{1} -UNBAN_ERROR=§cDer Spieler ist nicht gebannt. -UNBAN=§7Du hast §e{0} §e§lentbannt. +BAN_TEAM={0} §e{1} §7Was §e§lbanned§7 by §e{2} {3}§8. §7Reason§8: §f{4} +BAN_PERMA=§7You are §e§lbannedt§8. §7permanently. Reason§8: §e{0} +BAN_UNTIL=§7You are §e§lbanned §euntil {0} §8. §7Reason§8: §e{1} +UNBAN_ERROR=§cThe player isn't banned. +UNBAN=§7You have §e§lunbanned §e{0}. -MUTE_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgemuted§8. §7Grund§8: §f{4} -MUTE_PERMA=§7Du bist §epermanent §e§lgemuted§8. §7Grund§8: §e{0} -MUTE_UNTIL=§7Du bist §ebis zum {0} §e§lgemuted§8. §7Grund§8: §e{1} -UNMUTE_ERROR=§cDer Spieler ist nicht gemuted. -UNMUTE=§7Du hast §e{0} §e§lentmuted. +MUTE_TEAM={0} §e{1} §7was §e§lmuted§7 by §e{2} {3}§8. §7Reason§8: §f{4} +MUTE_PERMA=§7You are §epermanently §e§lmuted§8. §7Reason§8: §e{0} +MUTE_UNTIL=§7You are §e§lmuted §euntil {0}§8. §7Grund§8: §e{1} +UNMUTE_ERROR=§cThe player isn't muted. +UNMUTE=§7You have §e§lmuted §e{0}. -NOSCHEMRECEIVING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicerhalten ausgeschlossen§8. §7Grund§8: §f{4} -NOSCHEMRECEIVING_PERMA=§7Du bist §epermanent §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{0} -NOSCHEMRECEIVING_UNTIL=§7Du bist §ebis zum {0} §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{1} -UNNOSCHEMRECEIVING_ERROR=§cDer Spieler ist nicht vom Erhalten von Schematics ausgeschlossen. -UNNOSCHEMRECEIVING=§e{0} §7darf nun wieder §e§lSchematics erhalten§8. +NOSCHEMRECEIVING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lrecieving Schematics§8. §7Reason§8: §f{4} +NOSCHEMRECEIVING_PERMA=§7You are §permanently excluded from receiving §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMRECEIVING_UNTIL=§7You are §excluded from receiving §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} +UNNOSCHEMRECEIVING_ERROR=§cThe player is not excluded from receiving schematics. +UNNOSCHEMRECEIVING=§e{0} §7may now receive §e§lschematics§7 again§8. -NOSCHEMSHARING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicverteilen ausgeschlossen§8. §7Grund§8: §f{4} -NOSCHEMSHARING_PERMA=§7Du bist §epermanent §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} -NOSCHEMSHARING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} -UNNOSCHEMSHARING_ERROR=§cDer Spieler ist nicht vom Verteilen von Schematics ausgeschlossen. -UNNOSCHEMSHARING=§e{0} §7darf nun wieder §e§lSchematics verteilen§8. +NOSCHEMSHARING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lsharing schematics§8. §7Reason§8: §f{4} +NOSCHEMSHARING_PERMA=§7You are §permanently excluded from sharing §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMSHARING_UNTIL=§7You are §excluded from sharing §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} +UNNOSCHEMSHARING_ERROR=§cThe player is not excluded from sharing schematics. +UNNOSCHEMSHARING=§e{0} §7may now share §e§lschematics§7 again§8. -NOSCHEMSUBMITTING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematiceinsenden ausgeschlossen§8. §7Grund§8: §f{4} -NOSCHEMSUBMITTING_PERMA=§7Du bist §epermanent §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} -NOSCHEMSUBMITTING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} -UNNOSCHEMSUBMITTING_ERROR=§cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen. -UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis einsenden§8. - -NODEVSERVER_TEAM={0} §e{1} §7hat §e{2} §7mit Grund §f{4}§7 zu generft und hat daher §e§lDevserververbot §7erhalten§8, §e{3} -NODEVSERVER_PERMA=§7Du bist §epermanent §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{0} -NODEVSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{1} -UNNODEVSERVER_ERROR=§cDer Spieler ist nicht vom Devserver ausgeschlossen. -UNNODEVSERVER=§e{0} §7darf nun wieder dem §e§lDevserver beitreten§8. \ No newline at end of file +NOSCHEMSUBMITTING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lsubmitting schematics§8. §7Reason§8: §f{4} +NOSCHEMSUBMITTING_PERMA=§7You are §permanently excluded from submitting §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMSUBMITTING_UNTIL=§7You are §permanently excluded from submitting §e§lschematics§8. §7Reason§8: §e{0} +UNNOSCHEMSUBMITTING_ERROR=§cThe player is not excluded from submitting schematics. +UNNOSCHEMSUBMITTING=§e{0} §7may now submit §e§lschematics§7 again§8. \ No newline at end of file diff --git a/SpigotCore_Main/src/SpigotCore_de.properties b/SpigotCore_Main/src/SpigotCore_de.properties new file mode 100644 index 0000000..894dbf0 --- /dev/null +++ b/SpigotCore_Main/src/SpigotCore_de.properties @@ -0,0 +1,106 @@ +# +# This file is a part of the SteamWar software. +# +# Copyright (C) 2021 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 . +# + +COMMAND_SYSTEM_ERROR = §cFehler beim Ausführen des Befehls! + +SWLISINV_NEXT_PAGE_ACTIVE = §eSeite vor +SWLISINV_NEXT_PAGE_INACTIVE = §7Seite vor +SWLISINV_PREVIOUS_PAGE_ACTIVE = §eSeite zurück +SWLISINV_PREVIOUS_PAGE_INACTIVE = §7Seite zurück + +SCHEM_SELECTOR_TITLE={0} auswählen: {1} +SCHEM_SELECTOR_BACK=§eZurück +SCHEM_SELECTOR_DIR=§9Ordner +SCHEM_SELECTOR_RANK=§8Rang {0} +SCHEM_SELECTOR_OWN=§7Eigene Schematics +SCHEM_SELECTOR_PUB=§7Public Schematics +SCHEM_SELECTOR_SEL_DIR=§7Ordner auswählen +SCHEM_SELECTOR_NEW_DIR=§7Neuer Ordner +SCHEM_SELECTOR_FILTER=§7Filter +SCHEM_SELECTOR_SORTING=§7Sortierung +SCHEM_SELECTOR_SORTING_CURRENT=§7Aktuell: §e{0} +SCHEM_SELECTOR_SORTING_NAME=Name +SCHEM_SELECTOR_SORTING_TYPE=Schematic-Typ +SCHEM_SELECTOR_SORTING_UPDATE=Letztes Update +SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0} +SCHEM_SELECTOR_SORTING_ASC=Aufsteigend +SCHEM_SELECTOR_SORTING_DSC=Absteigend + +SCHEM_SELECTOR_ITEM_NAME=§e{0} +SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0} +SCHEM_SELECTOR_ITEM_REPLACE=§e{0}§7 +SCHEM_SELECTOR_ITEM_LORE_TYPE=§7{0} + +SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen + +SCHEM_SELECTOR_FILTER_TITLE=Filter +SCHEM_SELECTOR_FILTER_ENTER_NAME=Name eingeben +SCHEM_SELECTOR_FILTER_NAME=§7Nach Namen suchen... +SCHEM_SELECTOR_FILTER_NAME_SEARCH=§7Suchbegriff: §e{0} +SCHEM_SELECTOR_FILTER_ENTER_OWNER=Besitzer eingeben +SCHEM_SELECTOR_FILTER_OWNER=§7Nach Besitzer suchen... +SCHEM_SELECTOR_FILTER_OWNER_SEARCH=§7Besitzer: §e{0} +SCHEM_SELECTOR_FILTER_SEL_TYPE=Typ wählen... +SCHEM_SELECTOR_FILTER_TYPE=§7Nach Typ filtern... +SCHEM_SELECTOR_FILTER_TYPE_SEARCH=§7Typ: §e{0} +SCHEM_SELECTOR_FILTER_MAT=§7Nach Item filtern... +SCHEM_SELECTOR_FILTER_MAT_SEARCH=§7Item: §e{0} +SCHEM_SELECTOR_CANCEL=§eAbbrechen +SCHEM_SELECTOR_GO=§eSuchen... +SCHEM_SELECTOR_SCHEMATIC=Schematic +SCHEM_SELECTOR_DIRECTORY=Ordner +SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Ordner + +MATERIAL_SELECTOR_TITLE=Material auswählen + +BAN_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4} +BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0} +BAN_UNTIL=§7Du bist §ebis zum {0} §e§lgebannt§8. §7Grund§8: §e{1} +UNBAN_ERROR=§cDer Spieler ist nicht gebannt. +UNBAN=§7Du hast §e{0} §e§lentbannt. + +MUTE_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgemuted§8. §7Grund§8: §f{4} +MUTE_PERMA=§7Du bist §epermanent §e§lgemuted§8. §7Grund§8: §e{0} +MUTE_UNTIL=§7Du bist §ebis zum {0} §e§lgemuted§8. §7Grund§8: §e{1} +UNMUTE_ERROR=§cDer Spieler ist nicht gemuted. +UNMUTE=§7Du hast §e{0} §e§lentmuted. + +NOSCHEMRECEIVING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicerhalten ausgeschlossen§8. §7Grund§8: §f{4} +NOSCHEMRECEIVING_PERMA=§7Du bist §epermanent §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{0} +NOSCHEMRECEIVING_UNTIL=§7Du bist §ebis zum {0} §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{1} +UNNOSCHEMRECEIVING_ERROR=§cDer Spieler ist nicht vom Erhalten von Schematics ausgeschlossen. +UNNOSCHEMRECEIVING=§e{0} §7darf nun wieder §e§lSchematics erhalten§8. + +NOSCHEMSHARING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicverteilen ausgeschlossen§8. §7Grund§8: §f{4} +NOSCHEMSHARING_PERMA=§7Du bist §epermanent §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} +NOSCHEMSHARING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} +UNNOSCHEMSHARING_ERROR=§cDer Spieler ist nicht vom Verteilen von Schematics ausgeschlossen. +UNNOSCHEMSHARING=§e{0} §7darf nun wieder §e§lSchematics verteilen§8. + +NOSCHEMSUBMITTING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematiceinsenden ausgeschlossen§8. §7Grund§8: §f{4} +NOSCHEMSUBMITTING_PERMA=§7Du bist §epermanent §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} +NOSCHEMSUBMITTING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} +UNNOSCHEMSUBMITTING_ERROR=§cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen. +UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis einsenden§8. + +NODEVSERVER_TEAM={0} §e{1} §7hat §e{2} §7mit Grund §f{4}§7 zu generft und hat daher §e§lDevserververbot §7erhalten§8, §e{3} +NODEVSERVER_PERMA=§7Du bist §epermanent §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{0} +NODEVSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{1} +UNNODEVSERVER_ERROR=§cDer Spieler ist nicht vom Devserver ausgeschlossen. +UNNODEVSERVER=§e{0} §7darf nun wieder dem §e§lDevserver beitreten§8. \ No newline at end of file diff --git a/SpigotCore_Main/src/SpigotCore_en.properties b/SpigotCore_Main/src/SpigotCore_en.properties deleted file mode 100644 index e69de29..0000000 From 26090836975a6f0ee71df32e42aeb2787e32738e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 20 May 2022 17:46:14 +0200 Subject: [PATCH 06/14] Add initial english --- SpigotCore_Main/src/SpigotCore.properties | 40 +++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/SpigotCore_Main/src/SpigotCore.properties b/SpigotCore_Main/src/SpigotCore.properties index ca1a62c..5aa5ff0 100644 --- a/SpigotCore_Main/src/SpigotCore.properties +++ b/SpigotCore_Main/src/SpigotCore.properties @@ -17,24 +17,24 @@ # along with this program. If not, see . # -COMMAND_SYSTEM_ERROR = §cFehler beim Ausführen des Befehls! +COMMAND_SYSTEM_ERROR = §cError executing the command! -SWLISINV_NEXT_PAGE_ACTIVE = §eSeite vor -SWLISINV_NEXT_PAGE_INACTIVE = §7Seite vor -SWLISINV_PREVIOUS_PAGE_ACTIVE = §eSeite zurück -SWLISINV_PREVIOUS_PAGE_INACTIVE = §7Seite zurück +SWLISINV_NEXT_PAGE_ACTIVE = §eNext Page +SWLISINV_NEXT_PAGE_INACTIVE = §7Next Page +SWLISINV_PREVIOUS_PAGE_ACTIVE = §ePrevious Page +SWLISINV_PREVIOUS_PAGE_INACTIVE = §7Previous Page -SCHEM_SELECTOR_TITLE={0} auswählen: {1} -SCHEM_SELECTOR_BACK=§eZurück -SCHEM_SELECTOR_DIR=§9Ordner -SCHEM_SELECTOR_RANK=§8Rang {0} -SCHEM_SELECTOR_OWN=§7Eigene Schematics -SCHEM_SELECTOR_PUB=§7Public Schematics -SCHEM_SELECTOR_SEL_DIR=§7Ordner auswählen -SCHEM_SELECTOR_NEW_DIR=§7Neuer Ordner +SCHEM_SELECTOR_TITLE={0} select: {1} +SCHEM_SELECTOR_BACK=§eBack +SCHEM_SELECTOR_DIR=§9Directory +SCHEM_SELECTOR_RANK=§8Rank {0} +SCHEM_SELECTOR_OWN=§7Own schematics +SCHEM_SELECTOR_PUB=§7Public schematics +SCHEM_SELECTOR_SEL_DIR=§7select directory +SCHEM_SELECTOR_NEW_DIR=§7New directory SCHEM_SELECTOR_FILTER=§7Filter -SCHEM_SELECTOR_SORTING=§7Sortierung -SCHEM_SELECTOR_SORTING_CURRENT=§7Aktuell: §e{0} +SCHEM_SELECTOR_SORTING=§7Order by +SCHEM_SELECTOR_SORTING_CURRENT=§7Current: §e{0} SCHEM_SELECTOR_SORTING_NAME=Name SCHEM_SELECTOR_SORTING_TYPE=Schematic-Type SCHEM_SELECTOR_SORTING_UPDATE=Last update @@ -61,13 +61,13 @@ SCHEM_SELECTOR_FILTER_TYPE=§7Search by type... SCHEM_SELECTOR_FILTER_TYPE_SEARCH=§7Type: §e{0} SCHEM_SELECTOR_FILTER_MAT=§7Filter by item... SCHEM_SELECTOR_FILTER_MAT_SEARCH=§7Item: §e{0} -SCHEM_SELECTOR_CANCEL=§eAbbrechen -SCHEM_SELECTOR_GO=§eSuchen... +SCHEM_SELECTOR_CANCEL=§eCancel +SCHEM_SELECTOR_GO=§eSearch... SCHEM_SELECTOR_SCHEMATIC=Schematic -SCHEM_SELECTOR_DIRECTORY=Ordner -SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Ordner +SCHEM_SELECTOR_DIRECTORY=Directory +SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Directory -MATERIAL_SELECTOR_TITLE=Material auswählen +MATERIAL_SELECTOR_TITLE=Select Material BAN_TEAM={0} §e{1} §7Was §e§lbanned§7 by §e{2} {3}§8. §7Reason§8: §f{4} BAN_PERMA=§7You are §e§lbannedt§8. §7permanently. Reason§8: §e{0} From d7ad528c9ee07ae37bb742cc013b436cf9ace06d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 21 May 2022 10:39:26 +0200 Subject: [PATCH 07/14] Fix english --- SpigotCore_Main/src/SpigotCore.properties | 38 ++++++++++---------- SpigotCore_Main/src/SpigotCore_de.properties | 7 +--- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/SpigotCore_Main/src/SpigotCore.properties b/SpigotCore_Main/src/SpigotCore.properties index 5aa5ff0..b54f93e 100644 --- a/SpigotCore_Main/src/SpigotCore.properties +++ b/SpigotCore_Main/src/SpigotCore.properties @@ -1,7 +1,7 @@ # # This file is a part of the SteamWar software. # -# Copyright (C) 2021 SteamWar.de-Serverteam +# Copyright (C) 2022 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 @@ -19,26 +19,26 @@ COMMAND_SYSTEM_ERROR = §cError executing the command! -SWLISINV_NEXT_PAGE_ACTIVE = §eNext Page -SWLISINV_NEXT_PAGE_INACTIVE = §7Next Page -SWLISINV_PREVIOUS_PAGE_ACTIVE = §ePrevious Page -SWLISINV_PREVIOUS_PAGE_INACTIVE = §7Previous Page +SWLISINV_NEXT_PAGE_ACTIVE = §eNext page +SWLISINV_NEXT_PAGE_INACTIVE = §7Next page +SWLISINV_PREVIOUS_PAGE_ACTIVE = §ePrevious page +SWLISINV_PREVIOUS_PAGE_INACTIVE = §7Previous page -SCHEM_SELECTOR_TITLE={0} select: {1} +SCHEM_SELECTOR_TITLE={0} selection: {1} SCHEM_SELECTOR_BACK=§eBack SCHEM_SELECTOR_DIR=§9Directory SCHEM_SELECTOR_RANK=§8Rank {0} SCHEM_SELECTOR_OWN=§7Own schematics SCHEM_SELECTOR_PUB=§7Public schematics -SCHEM_SELECTOR_SEL_DIR=§7select directory +SCHEM_SELECTOR_SEL_DIR=§7Select directory SCHEM_SELECTOR_NEW_DIR=§7New directory SCHEM_SELECTOR_FILTER=§7Filter SCHEM_SELECTOR_SORTING=§7Order by SCHEM_SELECTOR_SORTING_CURRENT=§7Current: §e{0} SCHEM_SELECTOR_SORTING_NAME=Name -SCHEM_SELECTOR_SORTING_TYPE=Schematic-Type +SCHEM_SELECTOR_SORTING_TYPE=Schematic type SCHEM_SELECTOR_SORTING_UPDATE=Last update -SCHEM_SELECTOR_SORTING_DIRECTION=§7Ordering: §e{0} +SCHEM_SELECTOR_SORTING_DIRECTION=§e{0} §7order SCHEM_SELECTOR_SORTING_ASC=Ascending SCHEM_SELECTOR_SORTING_DSC=Descending @@ -67,10 +67,10 @@ SCHEM_SELECTOR_SCHEMATIC=Schematic SCHEM_SELECTOR_DIRECTORY=Directory SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Directory -MATERIAL_SELECTOR_TITLE=Select Material +MATERIAL_SELECTOR_TITLE=Select material -BAN_TEAM={0} §e{1} §7Was §e§lbanned§7 by §e{2} {3}§8. §7Reason§8: §f{4} -BAN_PERMA=§7You are §e§lbannedt§8. §7permanently. Reason§8: §e{0} +BAN_TEAM={0} §e{1} §7was §e§lbanned§7 by §e{2} {3}§8. §7Reason§8: §f{4} +BAN_PERMA=§7You are §e§lbanned §7permanently. Reason§8: §e{0} BAN_UNTIL=§7You are §e§lbanned §euntil {0} §8. §7Reason§8: §e{1} UNBAN_ERROR=§cThe player isn't banned. UNBAN=§7You have §e§lunbanned §e{0}. @@ -81,20 +81,20 @@ MUTE_UNTIL=§7You are §e§lmuted §euntil {0}§8. §7Grund§8: §e{1} UNMUTE_ERROR=§cThe player isn't muted. UNMUTE=§7You have §e§lmuted §e{0}. -NOSCHEMRECEIVING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lrecieving Schematics§8. §7Reason§8: §f{4} -NOSCHEMRECEIVING_PERMA=§7You are §permanently excluded from receiving §e§lschematics§8. §7Reason§8: §e{0} -NOSCHEMRECEIVING_UNTIL=§7You are §excluded from receiving §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} +NOSCHEMRECEIVING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lrecieving schematics§8. §7Reason§8: §f{4} +NOSCHEMRECEIVING_PERMA=§7You are §epermanently §7excluded from receiving §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMRECEIVING_UNTIL=§7You are excluded from receiving §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} UNNOSCHEMRECEIVING_ERROR=§cThe player is not excluded from receiving schematics. UNNOSCHEMRECEIVING=§e{0} §7may now receive §e§lschematics§7 again§8. NOSCHEMSHARING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lsharing schematics§8. §7Reason§8: §f{4} -NOSCHEMSHARING_PERMA=§7You are §permanently excluded from sharing §e§lschematics§8. §7Reason§8: §e{0} -NOSCHEMSHARING_UNTIL=§7You are §excluded from sharing §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} +NOSCHEMSHARING_PERMA=§7You are §epermanently $7excluded from sharing §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMSHARING_UNTIL=§7You are excluded from sharing §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} UNNOSCHEMSHARING_ERROR=§cThe player is not excluded from sharing schematics. UNNOSCHEMSHARING=§e{0} §7may now share §e§lschematics§7 again§8. NOSCHEMSUBMITTING_TEAM={0} §e{1} §7was excluded from §e{2} {3} §7from §e§lsubmitting schematics§8. §7Reason§8: §f{4} -NOSCHEMSUBMITTING_PERMA=§7You are §permanently excluded from submitting §e§lschematics§8. §7Reason§8: §e{0} -NOSCHEMSUBMITTING_UNTIL=§7You are §permanently excluded from submitting §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMSUBMITTING_PERMA=§7You are §epermanently §7excluded from submitting §e§lschematics§8. §7Reason§8: §e{0} +NOSCHEMSUBMITTING_UNTIL=§7You are excluded from submitting §e§lschematics §euntil {0}§8. §7Reason§8: §e{1} UNNOSCHEMSUBMITTING_ERROR=§cThe player is not excluded from submitting schematics. UNNOSCHEMSUBMITTING=§e{0} §7may now submit §e§lschematics§7 again§8. \ No newline at end of file diff --git a/SpigotCore_Main/src/SpigotCore_de.properties b/SpigotCore_Main/src/SpigotCore_de.properties index 894dbf0..fcdd340 100644 --- a/SpigotCore_Main/src/SpigotCore_de.properties +++ b/SpigotCore_Main/src/SpigotCore_de.properties @@ -1,7 +1,7 @@ # # This file is a part of the SteamWar software. # -# Copyright (C) 2021 SteamWar.de-Serverteam +# Copyright (C) 2022 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 @@ -42,11 +42,6 @@ SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0} SCHEM_SELECTOR_SORTING_ASC=Aufsteigend SCHEM_SELECTOR_SORTING_DSC=Absteigend -SCHEM_SELECTOR_ITEM_NAME=§e{0} -SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0} -SCHEM_SELECTOR_ITEM_REPLACE=§e{0}§7 -SCHEM_SELECTOR_ITEM_LORE_TYPE=§7{0} - SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen SCHEM_SELECTOR_FILTER_TITLE=Filter From 55fb0b8f47d41d15b88a3d2fdd590d18cf2b0f1d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 21 May 2022 11:11:51 +0200 Subject: [PATCH 08/14] Add language via db --- SpigotCore_Main/src/de/steamwar/message/Message.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/message/Message.java b/SpigotCore_Main/src/de/steamwar/message/Message.java index efdf651..21977e6 100644 --- a/SpigotCore_Main/src/de/steamwar/message/Message.java +++ b/SpigotCore_Main/src/de/steamwar/message/Message.java @@ -21,6 +21,7 @@ package de.steamwar.message; import de.steamwar.core.BountifulWrapper; import de.steamwar.core.WorldOfColorWrapper; +import de.steamwar.sql.UserConfig; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.HoverEvent; @@ -74,6 +75,10 @@ public class Message { } private Locale getLocale(Player player){ + String dbLocale = UserConfig.getConfig(player.getUniqueId(), "language"); + if (dbLocale != null) { + return new Locale(dbLocale); + } return WorldOfColorWrapper.impl.getLocale(player); } From 22e691dcb85df63fb004ecea432cda30b1da88a1 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 21 May 2022 13:21:20 +0200 Subject: [PATCH 09/14] Add LocaleInvalidationHandler --- .../src/de/steamwar/comms/BungeeReceiver.java | 2 ++ .../de/steamwar/comms/PacketIdManager.java | 2 ++ .../handlers/LocaleInvalidationHandler.java | 31 +++++++++++++++++++ .../src/de/steamwar/message/Message.java | 13 ++++---- .../src/de/steamwar/sql/SQLProvider.java | 7 ++++- .../de/steamwar/sql/StandaloneProvider.java | 5 +-- .../src/de/steamwar/sql/SteamwarUser.java | 22 ++++++++++--- 7 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 SpigotCore_Main/src/de/steamwar/comms/handlers/LocaleInvalidationHandler.java diff --git a/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java b/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java index 021414e..e7a0b8c 100644 --- a/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java +++ b/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java @@ -23,6 +23,7 @@ import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; import de.steamwar.comms.handlers.BungeeHandler; import de.steamwar.comms.handlers.InventoryHandler; +import de.steamwar.comms.handlers.LocaleInvalidationHandler; import de.steamwar.core.BountifulWrapper; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; @@ -57,6 +58,7 @@ public class BungeeReceiver implements PluginMessageListener { Player player = Bukkit.getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUUID()); player.closeInventory(); }); + registerHandler(PacketIdManager.LOCALE_INVALIDATION, new LocaleInvalidationHandler()); } @Override diff --git a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java index 6eb462b..7020c68 100644 --- a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java +++ b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java @@ -28,6 +28,8 @@ public class PacketIdManager { public static final byte PREPARE_SCHEM = 0x03; public static final byte BAUMEMBER_UPDATE = 0x04; public static final byte EXECUTE_COMMAND = 0x05; + public static final byte LOCALE_INVALIDATION = 0x06; + //0x1(X) Bungee Inventory public static final byte INVENTORY_PACKET = 0x10; public static final byte INVENTORY_CALLBACK_PACKET = 0x11; diff --git a/SpigotCore_Main/src/de/steamwar/comms/handlers/LocaleInvalidationHandler.java b/SpigotCore_Main/src/de/steamwar/comms/handlers/LocaleInvalidationHandler.java new file mode 100644 index 0000000..3ebaaa1 --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/comms/handlers/LocaleInvalidationHandler.java @@ -0,0 +1,31 @@ +/* + * 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.comms.handlers; + +import com.google.common.io.ByteArrayDataInput; +import de.steamwar.sql.SteamwarUser; + +public class LocaleInvalidationHandler implements BungeeHandler { + + @Override + public void handle(ByteArrayDataInput byteArrayDataInput) { + SteamwarUser.invalidate(byteArrayDataInput.readInt()); + } +} diff --git a/SpigotCore_Main/src/de/steamwar/message/Message.java b/SpigotCore_Main/src/de/steamwar/message/Message.java index 21977e6..9cb9283 100644 --- a/SpigotCore_Main/src/de/steamwar/message/Message.java +++ b/SpigotCore_Main/src/de/steamwar/message/Message.java @@ -21,7 +21,7 @@ package de.steamwar.message; import de.steamwar.core.BountifulWrapper; import de.steamwar.core.WorldOfColorWrapper; -import de.steamwar.sql.UserConfig; +import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.HoverEvent; @@ -75,11 +75,12 @@ public class Message { } private Locale getLocale(Player player){ - String dbLocale = UserConfig.getConfig(player.getUniqueId(), "language"); - if (dbLocale != null) { - return new Locale(dbLocale); - } - return WorldOfColorWrapper.impl.getLocale(player); + Locale locale = SteamwarUser.get(player).getLocale(); + if (locale == null) + locale = WorldOfColorWrapper.impl.getLocale(player); + if (locale == null) + locale = Locale.getDefault(); + return locale; } /* Send a message to one player */ diff --git a/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java b/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java index f84865c..6e71127 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java @@ -331,7 +331,12 @@ public class SQLProvider implements Provider { } private SteamwarUser newSteamwarUser(ResultSet rs) throws SQLException { - return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock")); + String dbLocale = rs.getString("Locale"); + Locale locale = null; + if (dbLocale != null) { + locale = new Locale(dbLocale); + } + return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock"), locale); } private static final Statement insert = new Statement("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)"); diff --git a/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java b/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java index 29b5f95..c70cd1c 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java +++ b/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java @@ -20,6 +20,7 @@ package de.steamwar.sql; import de.steamwar.core.WorldEditWrapper; +import de.steamwar.core.WorldOfColorWrapper; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -168,12 +169,12 @@ public class StandaloneProvider implements Provider { Player player = Bukkit.getPlayer(userName); if(player == null) return null; - return usersByUUID.computeIfAbsent(player.getUniqueId(), uuid -> new SteamwarUser(userId++, uuid, userName, UserGroup.Member, 0, false)); + return usersByUUID.computeIfAbsent(player.getUniqueId(), uuid -> new SteamwarUser(userId++, uuid, userName, UserGroup.Member, 0, false, WorldOfColorWrapper.impl.getLocale(player))); } @Override public SteamwarUser getUserByUUID(UUID uuid) { - return usersByUUID.computeIfAbsent(uuid, uuid1 -> new SteamwarUser(userId++, uuid1, Objects.requireNonNull(Objects.requireNonNull(Bukkit.getOfflinePlayer(uuid1)).getName()), UserGroup.Member, 0, false)); + return usersByUUID.computeIfAbsent(uuid, uuid1 -> new SteamwarUser(userId++, uuid1, Objects.requireNonNull(Objects.requireNonNull(Bukkit.getOfflinePlayer(uuid1)).getName()), UserGroup.Member, 0, false, Locale.getDefault())); } @Override diff --git a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java index 6bac625..9de9c2d 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java @@ -23,10 +23,7 @@ import de.steamwar.core.Core; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; public class SteamwarUser { @@ -43,20 +40,31 @@ public class SteamwarUser { }, 72000, 72000); } + public static void invalidate(int userId) { + if (!byId.containsKey(userId)) + return; + SteamwarUser user = byId.get(userId); + byId.remove(userId); + byName.remove(user.getUserName()); + byUUID.remove(user.getUUID()); + } + private final int id; private final UUID uuid; private final String userName; private final UserGroup userGroup; private final int team; private final boolean bedrock; + private final Locale locale; - public SteamwarUser(int id, UUID uuid, String userName, UserGroup userGroup, int team, boolean bedrock) { + public SteamwarUser(int id, UUID uuid, String userName, UserGroup userGroup, int team, boolean bedrock, Locale locale) { this.id = id; this.uuid = uuid; this.userName = userName; this.userGroup = userGroup; this.team = team; this.bedrock = bedrock; + this.locale = locale; byUUID.put(uuid, this); byName.put(userName.toLowerCase(), this); @@ -87,6 +95,10 @@ public class SteamwarUser { return bedrock; } + public Locale getLocale() { + return locale; + } + public static SteamwarUser get(String userName){ SteamwarUser user = byName.get(userName.toLowerCase()); if(user == null) From 6eb72a3aa25370bae5207109b85e06daa0f6a12f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 21 May 2022 13:23:43 +0200 Subject: [PATCH 10/14] Fix stuff --- SpigotCore_Main/src/de/steamwar/message/Message.java | 7 +------ SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/message/Message.java b/SpigotCore_Main/src/de/steamwar/message/Message.java index 9cb9283..6835e8b 100644 --- a/SpigotCore_Main/src/de/steamwar/message/Message.java +++ b/SpigotCore_Main/src/de/steamwar/message/Message.java @@ -75,12 +75,7 @@ public class Message { } private Locale getLocale(Player player){ - Locale locale = SteamwarUser.get(player).getLocale(); - if (locale == null) - locale = WorldOfColorWrapper.impl.getLocale(player); - if (locale == null) - locale = Locale.getDefault(); - return locale; + return SteamwarUser.get(player).getLocale(); } /* Send a message to one player */ diff --git a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java index 9de9c2d..6020000 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java @@ -20,6 +20,7 @@ package de.steamwar.sql; import de.steamwar.core.Core; +import de.steamwar.core.WorldOfColorWrapper; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -96,6 +97,13 @@ public class SteamwarUser { } public Locale getLocale() { + Locale locale = this.locale; + if (locale == null) { + locale = WorldOfColorWrapper.impl.getLocale(Bukkit.getPlayer(uuid)); + } + if (locale == null) { + locale = Locale.getDefault(); + } return locale; } From f8436026e2345a50884c0e7ff4aa6d574dbe65d0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 21 May 2022 13:43:42 +0200 Subject: [PATCH 11/14] Fix stuff --- SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java b/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java index c70cd1c..b5924e8 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java +++ b/SpigotCore_Main/src/de/steamwar/sql/StandaloneProvider.java @@ -169,12 +169,12 @@ public class StandaloneProvider implements Provider { Player player = Bukkit.getPlayer(userName); if(player == null) return null; - return usersByUUID.computeIfAbsent(player.getUniqueId(), uuid -> new SteamwarUser(userId++, uuid, userName, UserGroup.Member, 0, false, WorldOfColorWrapper.impl.getLocale(player))); + return usersByUUID.computeIfAbsent(player.getUniqueId(), uuid -> new SteamwarUser(userId++, uuid, userName, UserGroup.Member, 0, false, null)); } @Override public SteamwarUser getUserByUUID(UUID uuid) { - return usersByUUID.computeIfAbsent(uuid, uuid1 -> new SteamwarUser(userId++, uuid1, Objects.requireNonNull(Objects.requireNonNull(Bukkit.getOfflinePlayer(uuid1)).getName()), UserGroup.Member, 0, false, Locale.getDefault())); + return usersByUUID.computeIfAbsent(uuid, uuid1 -> new SteamwarUser(userId++, uuid1, Objects.requireNonNull(Objects.requireNonNull(Bukkit.getOfflinePlayer(uuid1)).getName()), UserGroup.Member, 0, false, null)); } @Override From 298aa9d3de5dfab468f94e33dbc0cb41dace0632 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 21 May 2022 16:28:18 +0200 Subject: [PATCH 12/14] Fix stuff --- .../src/de/steamwar/sql/SQLProvider.java | 2 +- .../src/de/steamwar/sql/SteamwarUser.java | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java b/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java index 6e71127..79f2172 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java @@ -334,7 +334,7 @@ public class SQLProvider implements Provider { String dbLocale = rs.getString("Locale"); Locale locale = null; if (dbLocale != null) { - locale = new Locale(dbLocale); + locale = Locale.forLanguageTag(dbLocale); } return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock"), locale); } diff --git a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java index 6020000..04bcbf8 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java @@ -42,10 +42,9 @@ public class SteamwarUser { } public static void invalidate(int userId) { - if (!byId.containsKey(userId)) + SteamwarUser user = byId.remove(userId); + if (user == null) return; - SteamwarUser user = byId.get(userId); - byId.remove(userId); byName.remove(user.getUserName()); byUUID.remove(user.getUUID()); } @@ -98,13 +97,11 @@ public class SteamwarUser { public Locale getLocale() { Locale locale = this.locale; - if (locale == null) { + if (locale == null) locale = WorldOfColorWrapper.impl.getLocale(Bukkit.getPlayer(uuid)); - } - if (locale == null) { - locale = Locale.getDefault(); - } - return locale; + if (locale != null) + return locale; + return Locale.getDefault(); } public static SteamwarUser get(String userName){ From 7b3162ece3010808d930babf7e3ec8dc8a7414a0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 24 May 2022 09:12:43 +0200 Subject: [PATCH 13/14] Improve control flow readability --- SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java | 6 +----- SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java b/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java index 79f2172..b1dfe51 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SQLProvider.java @@ -332,11 +332,7 @@ public class SQLProvider implements Provider { private SteamwarUser newSteamwarUser(ResultSet rs) throws SQLException { String dbLocale = rs.getString("Locale"); - Locale locale = null; - if (dbLocale != null) { - locale = Locale.forLanguageTag(dbLocale); - } - return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock"), locale); + return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock"), dbLocale != null ? Locale.forLanguageTag(dbLocale) : null); } private static final Statement insert = new Statement("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)"); diff --git a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java index 04bcbf8..d289b2a 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java @@ -55,7 +55,7 @@ public class SteamwarUser { private final UserGroup userGroup; private final int team; private final boolean bedrock; - private final Locale locale; + private Locale locale; public SteamwarUser(int id, UUID uuid, String userName, UserGroup userGroup, int team, boolean bedrock, Locale locale) { this.id = id; @@ -96,9 +96,9 @@ public class SteamwarUser { } public Locale getLocale() { - Locale locale = this.locale; - if (locale == null) - locale = WorldOfColorWrapper.impl.getLocale(Bukkit.getPlayer(uuid)); + if(locale != null) + return locale; + locale = WorldOfColorWrapper.impl.getLocale(Bukkit.getPlayer(uuid)); if (locale != null) return locale; return Locale.getDefault(); From 4e10daf826daaeaab3b6e508c298fe23d686a89e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 24 May 2022 09:31:47 +0200 Subject: [PATCH 14/14] Fix locale --- SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java index d289b2a..ff78332 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SteamwarUser.java @@ -98,7 +98,7 @@ public class SteamwarUser { public Locale getLocale() { if(locale != null) return locale; - locale = WorldOfColorWrapper.impl.getLocale(Bukkit.getPlayer(uuid)); + Locale locale = WorldOfColorWrapper.impl.getLocale(Bukkit.getPlayer(uuid)); if (locale != null) return locale; return Locale.getDefault();