From 66d832d058886908198f289488f24350857cef3c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 29 Feb 2020 09:24:15 +0100 Subject: [PATCH] Fix error messages Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/ErrorLogger.java | 3 ++- src/de/steamwar/bungeecore/sql/SteamwarUser.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/ErrorLogger.java b/src/de/steamwar/bungeecore/ErrorLogger.java index 12304db..39db043 100644 --- a/src/de/steamwar/bungeecore/ErrorLogger.java +++ b/src/de/steamwar/bungeecore/ErrorLogger.java @@ -3,6 +3,7 @@ package de.steamwar.bungeecore; import de.steamwar.bungeecore.sql.SWException; import net.md_5.bungee.api.ProxyServer; +import java.text.MessageFormat; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -35,7 +36,7 @@ public class ErrorLogger extends Handler { thrown = thrown.getCause(); } - SWException.log("Bungee", record.getMessage(), stacktrace.toString()); + SWException.log("Bungee", MessageFormat.format(record.getMessage(), record.getParameters()), stacktrace.toString()); } @Override diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 2447fd8..6e01fff 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -47,7 +47,14 @@ public class SteamwarUser { } public static SteamwarUser getOrCreate(PendingConnection connection){ - SteamwarUser user = SteamwarUser.get(connection.getUniqueId()); + SteamwarUser user; + try{ + user = SteamwarUser.get(connection.getUniqueId()); + }catch(SecurityException e){ + //Exception only thrown for first time users + //Reason: java.sql.SQLException: Invalid utf8mb4 character string: 'ACED00' + user = null; + } if(user != null){ String userName = connection.getName(); @@ -75,7 +82,7 @@ public class SteamwarUser { public static SteamwarUser get(UUID uuid){ if(usersByUUID.containsKey(uuid)) return usersByUUID.get(uuid); - return dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = '" + uuid.toString() + "'")); //Fix getOrCreate exceptions for first time users + return dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", uuid.toString())); } public static SteamwarUser get(ProxiedPlayer player){