mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Merge pull request #135 from Parabot/feature/issue-134
[FEATURE] Added nightly support for randoms
This commit is contained in:
@@ -73,7 +73,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.parabot</groupId>
|
<groupId>org.parabot</groupId>
|
||||||
<artifactId>internal-api</artifactId>
|
<artifactId>internal-api</artifactId>
|
||||||
<version>1.4.4</version>
|
<version>1.4.41</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public final class Landing {
|
|||||||
|
|
||||||
parseArgs(args);
|
parseArgs(args);
|
||||||
|
|
||||||
|
Directories.validate();
|
||||||
|
|
||||||
Core.verbose(TranslationHelper.translate("DEBUG_MODE") + Core.inDebugMode());
|
Core.verbose(TranslationHelper.translate("DEBUG_MODE") + Core.inDebugMode());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -48,9 +50,6 @@ public final class Landing {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.verbose(TranslationHelper.translate("VALIDATING_DIRECTORIES"));
|
|
||||||
Directories.validate();
|
|
||||||
|
|
||||||
Core.verbose(TranslationHelper.translate("VALIDATION_ACCOUNT_MANAGER"));
|
Core.verbose(TranslationHelper.translate("VALIDATION_ACCOUNT_MANAGER"));
|
||||||
AccountManager.validate();
|
AccountManager.validate();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class Configuration extends org.parabot.api.Configuration {
|
|||||||
public static final String GET_SCRIPTS = "http://bdn.parabot.org/api/get.php?action=scripts_scripts&server=";
|
public static final String GET_SCRIPTS = "http://bdn.parabot.org/api/get.php?action=scripts_scripts&server=";
|
||||||
public static final String GET_SCRIPT = "http://bdn.parabot.org/api/get.php?action=scripts_script&id=";
|
public static final String GET_SCRIPT = "http://bdn.parabot.org/api/get.php?action=scripts_script&id=";
|
||||||
public static final String GET_SERVER_PROVIDERS = "http://bdn.parabot.org/api/get.php?action=server_providers";
|
public static final String GET_SERVER_PROVIDERS = "http://bdn.parabot.org/api/get.php?action=server_providers";
|
||||||
public static final String GET_SERVER_PROVIDER = "http://bdn.parabot.org/api/get.php?action=server_provider&name=";
|
public static final String GET_SERVER_PROVIDER = "http://v3.bdn.parabot.org/api/bot/download/provider?nightly=%s";
|
||||||
public static final String GET_SERVER_PROVIDER_INFO = "http://bdn.parabot.org/api/get.php?action=server_information&name=";
|
public static final String GET_SERVER_PROVIDER_INFO = "http://bdn.parabot.org/api/get.php?action=server_information&name=";
|
||||||
public static final String GET_SERVER_SETTINGS = "http://bdn.parabot.org/api/get.php?action=get_settings";
|
public static final String GET_SERVER_SETTINGS = "http://bdn.parabot.org/api/get.php?action=get_settings";
|
||||||
public static final String GET_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
public static final String GET_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
||||||
@@ -24,6 +24,4 @@ public class Configuration extends org.parabot.api.Configuration {
|
|||||||
public static final String ITEM_API = DATA_API + "items/";
|
public static final String ITEM_API = DATA_API + "items/";
|
||||||
|
|
||||||
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
||||||
|
|
||||||
public static final String NIGHTLY_APPEND = "?nightly=true";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package org.parabot.core.parsers.randoms;
|
package org.parabot.core.parsers.randoms;
|
||||||
|
|
||||||
|
import org.parabot.api.io.WebUtil;
|
||||||
import org.parabot.core.Configuration;
|
import org.parabot.core.Configuration;
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
import org.parabot.core.io.NoProgressListener;
|
import org.parabot.core.io.NoProgressListener;
|
||||||
import org.parabot.core.io.ProgressListener;
|
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -20,9 +19,11 @@ import java.net.URLClassLoader;
|
|||||||
*/
|
*/
|
||||||
public class PublicRandoms extends RandomParser {
|
public class PublicRandoms extends RandomParser {
|
||||||
|
|
||||||
|
private String fileName = ((Configuration.BOT_VERSION.isNightly()) ? "randoms-nightly.jar" : "randoms.jar");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parse() {
|
public void parse() {
|
||||||
File myJar = new File(Directories.getCachePath() + "/randoms.jar");
|
File myJar = new File(Directories.getCachePath() + File.separator + fileName);
|
||||||
if (!myJar.exists() || !myJar.canRead()) {
|
if (!myJar.exists() || !myJar.canRead()) {
|
||||||
download();
|
download();
|
||||||
}
|
}
|
||||||
@@ -46,12 +47,14 @@ public class PublicRandoms extends RandomParser {
|
|||||||
|
|
||||||
private void download() {
|
private void download() {
|
||||||
try {
|
try {
|
||||||
File random = new File(Directories.getCachePath() + "/randoms.jar");
|
File random = new File(Directories.getCachePath() + File.separator + fileName);
|
||||||
if (random.exists()) {
|
if (random.exists()) {
|
||||||
Core.verbose("Public random dependency already exists, no need to download it...");
|
Core.verbose("Public random dependency already exists, no need to download it...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String downloadLink = Configuration.GET_RANDOMS;
|
|
||||||
|
String downloadLink = ((Configuration.BOT_VERSION.isNightly()) ? Configuration.GET_RANDOMS + Configuration.NIGHTLY_APPEND : Configuration.GET_RANDOMS);
|
||||||
|
|
||||||
WebUtil.downloadFile(new URL(downloadLink), random, new NoProgressListener());
|
WebUtil.downloadFile(new URL(downloadLink), random, new NoProgressListener());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
|||||||
|
|
||||||
final File destination = new File(Directories.getCachePath(),
|
final File destination = new File(Directories.getCachePath(),
|
||||||
serverProviderInfo.getCRC32() + ".jar");
|
serverProviderInfo.getCRC32() + ".jar");
|
||||||
final String jarUrl = Configuration.GET_SERVER_PROVIDER
|
final String jarUrl = String.format(Configuration.GET_SERVER_PROVIDER, Configuration.BOT_VERSION.isNightly());
|
||||||
+ this.serverName;
|
|
||||||
|
|
||||||
Core.verbose("Downloading: " + jarUrl + " ...");
|
Core.verbose("Downloading: " + jarUrl + " ...");
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
|||||||
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
||||||
} else {
|
} else {
|
||||||
WebUtil.downloadFile(new URL(jarUrl), destination,
|
WebUtil.downloadFile(new URL(jarUrl), destination,
|
||||||
VerboseLoader.get(), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
VerboseLoader.get());
|
||||||
Core.verbose("Server provider downloaded...");
|
Core.verbose("Server provider downloaded...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user