Ability to disable the usage of the custom UUID API

This commit is contained in:
Sauilitired 2014-10-27 22:00:24 +01:00
parent e3ce39eff4
commit dea069ca52
3 changed files with 46 additions and 10 deletions

View File

@ -940,6 +940,7 @@ public class PlotMain extends JavaPlugin {
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");
}
if (Settings.DEBUG) {
Map<String, String> settings = new HashMap<>();
@ -1087,6 +1088,7 @@ public class PlotMain extends JavaPlugin {
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);
for (Entry<String, Object> node : options.entrySet()) {
if (!config.contains(node.getKey())) {

View File

@ -61,6 +61,7 @@ public class Settings {
public static boolean AUTO_CLEAR = false;
public static int AUTO_CLEAR_DAYS = 365;
public static String API_URL = "http://www.intellectualsites.com/minecraft.php";
public static boolean CUSTOM_API = true;
public static class Update {
/**

View File

@ -73,6 +73,7 @@ public class UUIDHandler {
}
UUID uuid;
if (online) {
if(Settings.CUSTOM_API) {
if ((uuid = getUuidOnlinePlayer(nameWrap)) != null) {
return uuid;
}
@ -89,6 +90,15 @@ public class UUIDHandler {
ex.printStackTrace();
}
}
} else {
try {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name);
add(nameWrap, uuid);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
else {
return getUuidOfflineMode(nameWrap);
@ -120,6 +130,16 @@ public class UUIDHandler {
return name;
}
if (online) {
if(!Settings.CUSTOM_API) {
try {
NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid);
add(new StringWrapper(name), uuid);
return name;
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
try {
return PlotMain.getUUIDSaver().mojangName(uuid);
} catch(Exception e) {
@ -133,6 +153,19 @@ public class UUIDHandler {
}
}
}
try {
return PlotMain.getUUIDSaver().mojangName(uuid);
} catch(Exception e) {
try {
NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid);
add(new StringWrapper(name), uuid);
return name;
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
else {
return "unknown";
}