Log setting the offline UUID on Bungee

Related #344
This commit is contained in:
games647
2020-05-15 14:05:00 +02:00
parent 30a763dbc4
commit b9cf8f0498
2 changed files with 6 additions and 1 deletions

View File

@ -45,7 +45,9 @@ public class ConnectionListener implements Listener {
// cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already // cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already
// having the login session from the login process // having the login session from the login process
BukkitLoginSession session = plugin.getSession(player.getAddress()); BukkitLoginSession session = plugin.getSession(player.getAddress());
if (session != null) { if (session == null) {
plugin.getLog().info("No on-going login session for player: {}", player);
} else {
Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session); Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask); Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
} }

View File

@ -82,6 +82,7 @@ public class ConnectListener implements Listener {
//bungeecord will do this automatically so override it on disabled option //bungeecord will do this automatically so override it on disabled option
if (!plugin.getCore().getConfig().get("premiumUuid", true)) { if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
try { try {
UUID oldPremiumId = connection.getUniqueId();
UUID offlineUUID = UUIDAdapter.generateOfflineId(username); UUID offlineUUID = UUIDAdapter.generateOfflineId(username);
// BungeeCord only allows setting the UUID in PreLogin events and before requesting online mode // BungeeCord only allows setting the UUID in PreLogin events and before requesting online mode
@ -90,6 +91,8 @@ public class ConnectListener implements Listener {
Field idField = InitialHandler.class.getDeclaredField("uniqueId"); Field idField = InitialHandler.class.getDeclaredField("uniqueId");
idField.setAccessible(true); idField.setAccessible(true);
idField.set(connection, offlineUUID); idField.set(connection, offlineUUID);
plugin.getLog().info("Overriding UUID to {} from {} on {}", offlineUUID, oldPremiumId, connection);
} catch (NoSuchFieldException | IllegalAccessException ex) { } catch (NoSuchFieldException | IllegalAccessException ex) {
plugin.getLog().error("Failed to set offline uuid of {}", username, ex); plugin.getLog().error("Failed to set offline uuid of {}", username, ex);
} }