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

View File

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

View File

@ -73,19 +73,29 @@ public class UUIDHandler {
} }
UUID uuid; UUID uuid;
if (online) { if (online) {
if ((uuid = getUuidOnlinePlayer(nameWrap)) != null) { if(Settings.CUSTOM_API) {
return uuid; if ((uuid = getUuidOnlinePlayer(nameWrap)) != null) {
} return uuid;
try { }
return PlotMain.getUUIDSaver().mojangUUID(name); try {
} return PlotMain.getUUIDSaver().mojangUUID(name);
catch(Exception e) { }
catch(Exception e) {
try {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name);
add(nameWrap, uuid);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
} else {
try { try {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name)); UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name); uuid = fetcher.call().get(name);
add(nameWrap, uuid); add(nameWrap, uuid);
} } catch (Exception ex) {
catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@ -120,6 +130,29 @@ public class UUIDHandler {
return name; return name;
} }
if (online) { 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) {
try {
NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid);
add(new StringWrapper(name), uuid);
return name;
} catch (Exception ex) {
e.printStackTrace();
}
}
}
try { try {
return PlotMain.getUUIDSaver().mojangName(uuid); return PlotMain.getUUIDSaver().mojangName(uuid);
} catch(Exception e) { } catch(Exception e) {
@ -129,7 +162,7 @@ public class UUIDHandler {
add(new StringWrapper(name), uuid); add(new StringWrapper(name), uuid);
return name; return name;
} catch (Exception ex) { } catch (Exception ex) {
e.printStackTrace(); ex.printStackTrace();
} }
} }
} }