mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-07 08:39:13 +00:00
New randoms system
This commit is contained in:
@@ -5,20 +5,20 @@ import org.parabot.core.Directories;
|
|||||||
import org.parabot.core.asm.ASMClassLoader;
|
import org.parabot.core.asm.ASMClassLoader;
|
||||||
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.desc.ServerProviderInfo;
|
|
||||||
import org.parabot.core.ui.components.VerboseLoader;
|
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
import org.parabot.environment.scripts.Script;
|
import org.parabot.environment.scripts.Script;
|
||||||
import org.parabot.environment.servers.ServerManifest;
|
import org.parabot.environment.servers.ServerManifest;
|
||||||
import org.parabot.environment.servers.ServerProvider;
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
import org.parabot.environment.servers.Type;
|
import org.parabot.environment.servers.Type;
|
||||||
import org.rev317.min.accessors.Client;
|
import org.rev317.min.accessors.Client;
|
||||||
|
import org.rev317.min.randoms.Downloader;
|
||||||
import org.rev317.min.script.ScriptEngine;
|
import org.rev317.min.script.ScriptEngine;
|
||||||
import org.rev317.min.ui.BotMenu;
|
import org.rev317.min.ui.BotMenu;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +27,7 @@ import java.net.URL;
|
|||||||
@ServerManifest(author = "Everel & Paradox", name = "Server name here", type = Type.INJECTION, version = 2.1)
|
@ServerManifest(author = "Everel & Paradox", name = "Server name here", type = Type.INJECTION, version = 2.1)
|
||||||
public class Loader extends ServerProvider {
|
public class Loader extends ServerProvider {
|
||||||
private Applet applet;
|
private Applet applet;
|
||||||
private HookFile hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getExtendedHookFile(), HookFile.TYPE_XML);
|
private HookFile hookFile; //= new HookFile(new File(Directories.getCachePath() + "/ikov-hooks.xml"), HookFile.TYPE_XML);
|
||||||
|
|
||||||
public static Client getClient() {
|
public static Client getClient() {
|
||||||
return (Client) Context.getInstance().getClient();
|
return (Client) Context.getInstance().getClient();
|
||||||
@@ -38,7 +38,7 @@ public class Loader extends ServerProvider {
|
|||||||
try {
|
try {
|
||||||
final Context context = Context.getInstance();
|
final Context context = Context.getInstance();
|
||||||
final ASMClassLoader classLoader = context.getASMClassLoader();
|
final ASMClassLoader classLoader = context.getASMClassLoader();
|
||||||
final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
|
final Class<?> clientClass = classLoader.loadClass("b");
|
||||||
Object instance = clientClass.newInstance();
|
Object instance = clientClass.newInstance();
|
||||||
applet = (Applet) instance;
|
applet = (Applet) instance;
|
||||||
return applet;
|
return applet;
|
||||||
@@ -50,11 +50,11 @@ public class Loader extends ServerProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getJar() {
|
public URL getJar() {
|
||||||
ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo();
|
//ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo();
|
||||||
|
|
||||||
File target = new File(Directories.getCachePath(), serverProvider.getClientCRC32() + ".jar");
|
File target = new File(Directories.getCachePath(), "3672181877.jar");
|
||||||
if (!target.exists()) {
|
if (!target.exists()) {
|
||||||
WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get());
|
//WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return WebUtil.toURL(target);
|
return WebUtil.toURL(target);
|
||||||
@@ -72,7 +72,11 @@ public class Loader extends ServerProvider {
|
|||||||
super.injectHooks();
|
super.injectHooks();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML);
|
try {
|
||||||
|
this.hookFile = new HookFile(new File(Directories.getCachePath() + "/ikov-hooks.xml"), HookFile.TYPE_XML);
|
||||||
|
} catch (MalformedURLException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
super.injectHooks();
|
super.injectHooks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,4 +96,8 @@ public class Loader extends ServerProvider {
|
|||||||
ScriptEngine.getInstance().unload();
|
ScriptEngine.getInstance().unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
new Downloader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package org.rev317.min.randoms;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.Directories;
|
||||||
|
import org.parabot.core.io.ProgressListener;
|
||||||
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JKetelaar
|
||||||
|
*/
|
||||||
|
public class Downloader {
|
||||||
|
|
||||||
|
public Downloader(){
|
||||||
|
parseRandoms();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseRandoms(){
|
||||||
|
File myJar = new File(Directories.getCachePath() + "/" + /* Context.getInstance().getServerProviderInfo().getCRC32() + "-randoms.jar"*/ "randoms.jar");
|
||||||
|
try {
|
||||||
|
URL url = myJar.toURI().toURL();
|
||||||
|
URL[] urls = new URL[]{url};
|
||||||
|
URLClassLoader child = new URLClassLoader(urls, this.getClass().getClassLoader());
|
||||||
|
Class<?> classToLoad = Class.forName("org.parabot.randoms.Core", true, child);
|
||||||
|
Method method = classToLoad.getDeclaredMethod("init");
|
||||||
|
Object instance = classToLoad.newInstance();
|
||||||
|
Object result = method.invoke(instance);
|
||||||
|
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException | ClassNotFoundException | MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadRandoms(){
|
||||||
|
try {
|
||||||
|
WebUtil.downloadFile(new URL("http://sdn.parabot.org/providers/getRandom.php?id=" + Context.getInstance().getServerProviderInfo().getCRC32()), new File(Directories.getCachePath() + "/" + Context.getInstance().getServerProviderInfo().getCRC32() + "-randoms.jar"), new ProgressListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgressUpdate(double v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDownloadSpeed(double v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,19 @@ package org.rev317.min.ui;
|
|||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.PaintDebugger;
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
|
import org.parabot.environment.scripts.randoms.Random;
|
||||||
import org.rev317.min.debug.*;
|
import org.rev317.min.debug.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
public class BotMenu implements ActionListener {
|
public class BotMenu implements ActionListener {
|
||||||
|
|
||||||
|
private RandomUI randomUI;
|
||||||
|
|
||||||
public BotMenu(JMenuBar bar) {
|
public BotMenu(JMenuBar bar) {
|
||||||
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
||||||
|
|
||||||
@@ -52,6 +56,23 @@ public class BotMenu implements ActionListener {
|
|||||||
debug.add(bank);
|
debug.add(bank);
|
||||||
debug.add(mouse);
|
debug.add(mouse);
|
||||||
|
|
||||||
|
JMenuItem randoms = new JMenuItem("Randoms");
|
||||||
|
bar.getMenu(0).add(randoms, 0);
|
||||||
|
|
||||||
|
randoms.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (randomUI == null){
|
||||||
|
randomUI = new RandomUI();
|
||||||
|
}
|
||||||
|
ArrayList<String> randoms = new ArrayList<>();
|
||||||
|
for (Random r : Context.getInstance().getRandomHandler().getRandoms()){
|
||||||
|
randoms.add(r.getName());
|
||||||
|
}
|
||||||
|
randomUI.openFrame(randoms);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bar.add(debug);
|
bar.add(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package org.rev317.min.ui;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.environment.scripts.randoms.Random;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
public class RandomUI implements ActionListener {
|
||||||
|
|
||||||
|
private JFrame frame;
|
||||||
|
private ArrayList<JCheckBox> checkBoxes;
|
||||||
|
|
||||||
|
public void openFrame(ArrayList<String> randoms) {
|
||||||
|
frame = new JFrame();
|
||||||
|
frame.setBounds(100, 100, 351, 150);
|
||||||
|
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
frame.getContentPane().setLayout(null);
|
||||||
|
|
||||||
|
JButton btnSubmit = new JButton("Submit");
|
||||||
|
btnSubmit.setBounds(228, 93, 117, 29);
|
||||||
|
frame.getContentPane().add(btnSubmit);
|
||||||
|
|
||||||
|
JLabel lblRandoms = new JLabel("Randoms");
|
||||||
|
lblRandoms.setBounds(6, 6, 61, 16);
|
||||||
|
frame.getContentPane().add(lblRandoms);
|
||||||
|
|
||||||
|
checkBoxes = new ArrayList<>();
|
||||||
|
for (int i = 0; i < randoms.size(); i++){
|
||||||
|
JCheckBox checkBox = new JCheckBox(randoms.get(i));
|
||||||
|
checkBox.setBounds(6, 34 + (i * 35), 128, 23);
|
||||||
|
frame.getContentPane().add(checkBox);
|
||||||
|
if (isActive(randoms.get(i))){
|
||||||
|
checkBox.setSelected(true);
|
||||||
|
}
|
||||||
|
checkBoxes.add(checkBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
btnSubmit.addActionListener(this);
|
||||||
|
this.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
|
this.frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Context.getInstance().getRandomHandler().clearActiveRandoms();
|
||||||
|
for (JCheckBox checkBox : this.checkBoxes){
|
||||||
|
if (checkBox.isSelected()) {
|
||||||
|
for (Random r : Context.getInstance().getRandomHandler().getRandoms()){
|
||||||
|
if (r.getName().equalsIgnoreCase(checkBox.getText().toLowerCase())){
|
||||||
|
Context.getInstance().getRandomHandler().setActive(r.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.frame.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isActive(String random){
|
||||||
|
for (Random r : Context.getInstance().getRandomHandler().getActiveRandoms()){
|
||||||
|
if (r.getName().equalsIgnoreCase(random.toLowerCase())){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user