diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 37282140f..d27b3bca6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -776,8 +776,9 @@ import java.util.concurrent.TimeUnit; Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); - Settings.API_URL = config.getString("api.location"); - Settings.CUSTOM_API = config.getBoolean("api.custom"); + Settings.API_URL = config.getString("uuid.api.location"); + Settings.CUSTOM_API = config.getBoolean("uuid.api.custom"); + Settings.UUID_FECTHING = config.getBoolean("uuid.fetching"); } if (Settings.DEBUG) { final Map settings = new HashMap<>(); @@ -864,8 +865,9 @@ import java.util.concurrent.TimeUnit; options.put("clear.on.ban", false); options.put("max_plots", Settings.MAX_PLOTS); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); - options.put("api.location", Settings.API_URL); - options.put("api.custom", Settings.CUSTOM_API); + options.put("uuid.api.location", Settings.API_URL); + options.put("uuid.api.custom", Settings.CUSTOM_API); + options.put("uuid.fecthing", Settings.UUID_FECTHING); options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED); @@ -1533,13 +1535,21 @@ import java.util.concurrent.TimeUnit; { if (Settings.OFFLINE_MODE) { UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + Settings.OFFLINE_MODE = true; } else if (checkVersion() && Bukkit.getOnlineMode()) { UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); + Settings.OFFLINE_MODE = false; } else { UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + Settings.OFFLINE_MODE = true; } + + if (Settings.OFFLINE_MODE) { + sendConsoleSenderMessage(C.PREFIX.s()+" &6PlotSquared &cis using Offline Mode UUIDs either because of user preference, or because of the version of the Bukkit API"); + } + setUUIDSaver(new PlotUUIDSaver()); // Looks really cool xD getUUIDSaver().globalPopulate(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 3db811c69..2d3012df3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -219,7 +219,7 @@ import java.util.UUID; private String getPlayerName(final UUID uuid) { if (uuid == null) { - return "unknown"; + return uuid.toString(); } if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { return "everyone"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 1eb39bd94..ef3bf019f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -28,6 +28,10 @@ package com.intellectualcrafters.plot.config; * @author Empire92 */ public class Settings { + /** + * Default UUID_FECTHING: false + */ + public static boolean UUID_FECTHING = false; /** * */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index aa3805689..e9d97de0e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -111,6 +111,9 @@ import java.util.UUID; * @param uuid to cache */ public static void add(final StringWrapper name, final UUID uuid) { + if (uuid == null || name == null) { + return; + } if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) { uuidMap.put(name, uuid); } @@ -190,6 +193,10 @@ import java.util.UUID; return name; } if (online && !Settings.OFFLINE_MODE) { + if (!Settings.UUID_FECTHING) { + name = getNameOfflineFromOnlineUUID(uuid); + return name; + } if (!Settings.CUSTOM_API) { try { final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid)); @@ -272,6 +279,14 @@ import java.util.UUID; return name; } + private static UUID getUuidOnlineFromOfflinePlayer(final StringWrapper name) { + return getUUID(Bukkit.getOfflinePlayer(name.toString())); + } + + private static String getNameOfflineFromOnlineUUID(final UUID uuid) { + return uuidWrapper.getOfflinePlayer(uuid).getName(); + } + /** * @param name to use as key *