mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-02 16:49:09 +00:00
Added for tweaks for randoms
This commit is contained in:
+1
-1
@@ -10,4 +10,4 @@
|
||||
out
|
||||
*.iml
|
||||
.idea
|
||||
Loader2.java
|
||||
DeprecatedLoader.java
|
||||
@@ -14,6 +14,7 @@ import org.parabot.environment.servers.ServerManifest;
|
||||
import org.parabot.environment.servers.ServerProvider;
|
||||
import org.parabot.environment.servers.Type;
|
||||
import org.rev317.min.accessors.Client;
|
||||
import org.rev317.min.randoms.Executer;
|
||||
import org.rev317.min.script.ScriptEngine;
|
||||
import org.rev317.min.ui.BotMenu;
|
||||
|
||||
@@ -23,8 +24,8 @@ import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Everel, JKetelaar
|
||||
*/
|
||||
* @author Everel, JKetelaar
|
||||
*/
|
||||
@ServerManifest(author = "Everel & JKetelaar", name = "Server name here", type = Type.INJECTION, version = 2.1)
|
||||
public class Loader extends ServerProvider {
|
||||
private boolean extended = true;
|
||||
@@ -101,6 +102,7 @@ public class Loader extends ServerProvider {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
//new Downloader();
|
||||
Executer executer = new Executer();
|
||||
executer.getRandoms();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public class Bank {
|
||||
public static int INV_PARENT_ID = 5064;
|
||||
public static int BANK_OPEN_INDEX = 1;
|
||||
static {
|
||||
|
||||
Properties p = Context.getInstance().getServerProviderInfo().getProperties();
|
||||
if (p.containsKey("bankInterface"))
|
||||
BANK_INTERFACE = Integer.parseInt(p.getProperty("bankInterface"));
|
||||
|
||||
+18
-18
@@ -15,27 +15,27 @@ import java.net.URLClassLoader;
|
||||
/**
|
||||
* @author JKetelaar
|
||||
*/
|
||||
public class Downloader {
|
||||
//TODO: Move to parabot itself
|
||||
public class Executer {
|
||||
/* TODO Move to Parabot client */
|
||||
|
||||
public Downloader(){
|
||||
if (downloadRandoms()) {
|
||||
Core.verbose("Parsing random(s)...");
|
||||
parseRandoms();
|
||||
}else{
|
||||
Core.verbose("There do not seem to be any randoms for this server...");
|
||||
}
|
||||
public void getRandoms() {
|
||||
Core.verbose("Downloading randoms");
|
||||
downloadRandoms();
|
||||
Core.verbose("Parsing random(s)");
|
||||
parseRandoms();
|
||||
}
|
||||
|
||||
private void parseRandoms(){
|
||||
private void parseRandoms() {
|
||||
File myJar = new File(Directories.getCachePath() + "/randoms.jar");
|
||||
if (!myJar.exists() || !myJar.canRead()){
|
||||
if (!myJar.exists() || !myJar.canRead()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
URL url = myJar.toURI().toURL();
|
||||
URL[] urls = new URL[]{url};
|
||||
String server = "ikov";
|
||||
// String server = Context.getInstance().getServerProviderInfo().getServerName();
|
||||
String server = "pkhonor";
|
||||
|
||||
URLClassLoader child = new URLClassLoader(urls, this.getClass().getClassLoader());
|
||||
Class<?> classToLoad = Class.forName("org.parabot.randoms.Core", true, child);
|
||||
Method method = classToLoad.getDeclaredMethod("init", String.class);
|
||||
@@ -44,17 +44,18 @@ public class Downloader {
|
||||
Core.verbose("Parsed random(s)!");
|
||||
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException | ClassNotFoundException | MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
Core.verbose("Failed to random(s)...");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean downloadRandoms(){
|
||||
private void downloadRandoms() {
|
||||
try {
|
||||
File random = new File(Directories.getCachePath() + "/randoms.jar");
|
||||
if (random.exists()){
|
||||
if (random.exists()) {
|
||||
Core.verbose("Random already exists, no need to download it.");
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
String downloadLink = "http://sdn.parabot.org/randoms.php";
|
||||
String downloadLink = "http://bdn.parabot.org/api/get.php?action=randoms";
|
||||
WebUtil.downloadFile(new URL(downloadLink), random, new ProgressListener() {
|
||||
@Override
|
||||
public void onProgressUpdate(double v) {
|
||||
@@ -66,9 +67,8 @@ public class Downloader {
|
||||
|
||||
}
|
||||
});
|
||||
return random.exists();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.rev317.min.ui;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.environment.scripts.randoms.Random;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -60,6 +61,7 @@ public class RandomUI implements ActionListener {
|
||||
if (checkBox.isSelected()) {
|
||||
for (Random r : Context.getInstance().getRandomHandler().getRandoms()) {
|
||||
if (r.getName().equalsIgnoreCase(checkBox.getText().toLowerCase())) {
|
||||
Core.verbose("Actived random '" + r.getName() + "'");
|
||||
Context.getInstance().getRandomHandler().setActive(r.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user