Option to not use UUIDFetcher for the time being.

This commit is contained in:
boy0001 2014-12-23 02:12:40 +11:00
parent 8e03638d8d
commit d0876c60b0
4 changed files with 34 additions and 5 deletions

View File

@ -776,8 +776,9 @@ import java.util.concurrent.TimeUnit;
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
Settings.API_URL = config.getString("api.location"); Settings.API_URL = config.getString("uuid.api.location");
Settings.CUSTOM_API = config.getBoolean("api.custom"); Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
} }
if (Settings.DEBUG) { if (Settings.DEBUG) {
final Map<String, String> settings = new HashMap<>(); final Map<String, String> settings = new HashMap<>();
@ -864,8 +865,9 @@ import java.util.concurrent.TimeUnit;
options.put("clear.on.ban", false); options.put("clear.on.ban", false);
options.put("max_plots", Settings.MAX_PLOTS); options.put("max_plots", Settings.MAX_PLOTS);
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
options.put("api.location", Settings.API_URL); options.put("uuid.api.location", Settings.API_URL);
options.put("api.custom", Settings.CUSTOM_API); options.put("uuid.api.custom", Settings.CUSTOM_API);
options.put("uuid.fecthing", Settings.UUID_FECTHING);
options.put("titles", Settings.TITLES); options.put("titles", Settings.TITLES);
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED); options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED);
@ -1533,13 +1535,21 @@ import java.util.concurrent.TimeUnit;
{ {
if (Settings.OFFLINE_MODE) { if (Settings.OFFLINE_MODE) {
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
Settings.OFFLINE_MODE = true;
} }
else if (checkVersion() && Bukkit.getOnlineMode()) { else if (checkVersion() && Bukkit.getOnlineMode()) {
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
Settings.OFFLINE_MODE = false;
} }
else { else {
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); 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()); setUUIDSaver(new PlotUUIDSaver());
// Looks really cool xD // Looks really cool xD
getUUIDSaver().globalPopulate(); getUUIDSaver().globalPopulate();

View File

@ -219,7 +219,7 @@ import java.util.UUID;
private String getPlayerName(final UUID uuid) { private String getPlayerName(final UUID uuid) {
if (uuid == null) { if (uuid == null) {
return "unknown"; return uuid.toString();
} }
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
return "everyone"; return "everyone";

View File

@ -28,6 +28,10 @@ package com.intellectualcrafters.plot.config;
* @author Empire92 * @author Empire92
*/ */
public class Settings { public class Settings {
/**
* Default UUID_FECTHING: false
*/
public static boolean UUID_FECTHING = false;
/** /**
* *
*/ */

View File

@ -111,6 +111,9 @@ import java.util.UUID;
* @param uuid to cache * @param uuid to cache
*/ */
public static void add(final StringWrapper name, final UUID uuid) { public static void add(final StringWrapper name, final UUID uuid) {
if (uuid == null || name == null) {
return;
}
if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) { if (!uuidMap.containsKey(name) && !uuidMap.inverse().containsKey(uuid)) {
uuidMap.put(name, uuid); uuidMap.put(name, uuid);
} }
@ -190,6 +193,10 @@ import java.util.UUID;
return name; return name;
} }
if (online && !Settings.OFFLINE_MODE) { if (online && !Settings.OFFLINE_MODE) {
if (!Settings.UUID_FECTHING) {
name = getNameOfflineFromOnlineUUID(uuid);
return name;
}
if (!Settings.CUSTOM_API) { if (!Settings.CUSTOM_API) {
try { try {
final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid)); final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
@ -272,6 +279,14 @@ import java.util.UUID;
return name; 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 * @param name to use as key
* *