From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Fri, 5 Aug 2016 01:03:08 +0200 Subject: [PATCH] Add setting for proxy online mode status TODO: Add isProxyOnlineMode check to Metrics diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java index 1b8e5671c9dc8c15ce33d351c1bb20f28919b9a2..c52dc0346f93527965ef29a0ccdc4bf3debe302e 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -23,6 +23,7 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import co.aikar.timings.Timings; import co.aikar.timings.TimingsManager; +import org.spigotmc.SpigotConfig; public class PaperConfig { @@ -242,4 +243,13 @@ public class PaperConfig { private static void saveEmptyScoreboardTeams() { saveEmptyScoreboardTeams = getBoolean("settings.save-empty-scoreboard-teams", false); } + + public static boolean bungeeOnlineMode = true; + private static void bungeeOnlineMode() { + bungeeOnlineMode = getBoolean("settings.bungee-online-mode", true); + } + + public static boolean isProxyOnlineMode() { + return Bukkit.getOnlineMode() || (SpigotConfig.bungee && bungeeOnlineMode); + } } diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java index f3e05fac1b5248ca4ee2cac03263e96c166ed343..e8af352f813a5015d216fc590190ae8fdb03f77d 100644 --- a/src/main/java/net/minecraft/server/players/GameProfileCache.java +++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java @@ -89,6 +89,7 @@ public class GameProfileCache { } }; + if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode()) // Paper - only run in online mode - 100 COL repository.findProfilesByNames(new String[]{name}, Agent.MINECRAFT, profilelookupcallback); GameProfile gameprofile = (GameProfile) atomicreference.get(); @@ -106,7 +107,7 @@ public class GameProfileCache { } private static boolean usesAuthentication() { - return GameProfileCache.usesAuthentication; + return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper } public synchronized void add(GameProfile gameprofile) { // Paper - synchronize diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java index 09c5fa2dbcbed05da51ef2d63e6d6112d22d7877..e6a26c274616947329a6164e4648486452819b0c 100644 --- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java +++ b/src/main/java/net/minecraft/server/players/OldUsersConverter.java @@ -63,7 +63,8 @@ public class OldUsersConverter { return new String[i]; }); - if (server.usesAuthentication() || org.spigotmc.SpigotConfig.bungee) { // Spigot: bungee = online mode, for now. + if (server.usesAuthentication() + || (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode())) { // Spigot: bungee = online mode, for now. // Paper - Handle via setting server.getProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback); } else { String[] astring1 = astring; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 2828936fe294d9d6750a8838da49ec8398835214..bbe0978f56d23b7defce765d381d4a7c20acd75c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1515,7 +1515,8 @@ public final class CraftServer implements Server { // Spigot Start GameProfile profile = null; // Only fetch an online UUID in online mode - if ( getOnlineMode() || org.spigotmc.SpigotConfig.bungee ) + if ( getOnlineMode() + || com.destroystokyo.paper.PaperConfig.isProxyOnlineMode() ) // Paper - Handle via setting { profile = console.getProfileCache().get( name ); }