From 32a3a013aac93a5fbedd92aef4c2558baca1cc0c Mon Sep 17 00:00:00 2001 From: Shadowrs Date: Fri, 7 Sep 2018 13:51:59 +0100 Subject: [PATCH] Improve comments --- src/main/java/org/parabot/core/desc/ServerProviderInfo.java | 6 ++++++ .../org/parabot/core/parsers/randoms/PublicRandoms.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/parabot/core/desc/ServerProviderInfo.java b/src/main/java/org/parabot/core/desc/ServerProviderInfo.java index 9eca6eb..a4e8c98 100644 --- a/src/main/java/org/parabot/core/desc/ServerProviderInfo.java +++ b/src/main/java/org/parabot/core/desc/ServerProviderInfo.java @@ -164,16 +164,22 @@ public class ServerProviderInfo { return settings; } + /** + * Gets the URL to download the Randoms JAR from. + * @return The provided URL in the server config JSON (denoted by 'randoms:') or, fallback to the default BDN URL. + */ public URL getRandoms() { try { String randomsUrl = properties.getProperty("randoms_jar"); if (randomsUrl == null || randomsUrl.length() == 0) { + // Fallback to default BDN URL if there is no 'randoms' specified in the server JSON configuration. randomsUrl = Configuration.GET_RANDOMS + (Configuration.BOT_VERSION.isNightly() ? Configuration.NIGHTLY_APPEND : ""); } return new URL(randomsUrl); } catch (MalformedURLException e) { e.printStackTrace(); } + // Will never return null, unless the BDN URL is changed. It shouldn't be. return null; } } diff --git a/src/main/java/org/parabot/core/parsers/randoms/PublicRandoms.java b/src/main/java/org/parabot/core/parsers/randoms/PublicRandoms.java index e8cea40..158c907 100644 --- a/src/main/java/org/parabot/core/parsers/randoms/PublicRandoms.java +++ b/src/main/java/org/parabot/core/parsers/randoms/PublicRandoms.java @@ -27,7 +27,7 @@ public class PublicRandoms extends RandomParser { final File destination = new File(Directories.getCachePath() + File.separator + fileName); final URL overrideDownload = Context.getInstance().getServerProviderInfo().getRandoms(); if (overrideDownload == null) { - throw new NullPointerException("randoms() URL is null - expected to default to BDN URL!"); + throw new NullPointerException("Unable to grab URL for Randoms jar. Default URL for BDN randoms must have changed!"); } Core.verbose(String.format("[%s] Destination: %s | dl: %s", getClass().getName(), destination, overrideDownload));