mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-02 16:49:09 +00:00
@@ -0,0 +1,35 @@
|
||||
package org.rev317.min.api.events;
|
||||
|
||||
public final class ActionEvent{
|
||||
private int index,cmd1,cmd2,cmd3,action;
|
||||
|
||||
public ActionEvent(int action,int cmd1,int cmd2, int cmd3,int index){
|
||||
this.action = action;
|
||||
this.cmd1 = cmd1;
|
||||
this.cmd2 = cmd2;
|
||||
this.cmd3 = cmd3;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getCmd1(){
|
||||
return cmd1;
|
||||
}
|
||||
|
||||
public int getCmd2(){
|
||||
return cmd2;
|
||||
}
|
||||
|
||||
public int getCmd3(){
|
||||
return cmd3;
|
||||
}
|
||||
|
||||
public int getAction(){
|
||||
return action;
|
||||
}
|
||||
|
||||
public int getIndex(){
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.rev317.min.api.events.listeners;
|
||||
|
||||
import org.rev317.min.api.events.ActionEvent;
|
||||
|
||||
public interface ActionListener{
|
||||
|
||||
public void onGameAction(ActionEvent event);
|
||||
|
||||
}
|
||||
@@ -170,23 +170,22 @@ public class Menu {
|
||||
* @param cmd3
|
||||
*/
|
||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3) {
|
||||
sendAction(action, cmd1, cmd2, cmd3, 0);
|
||||
sendAction(action, cmd1, cmd2, cmd3, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends an action to the client
|
||||
* @param action
|
||||
* @param cmd1
|
||||
* @param cmd2
|
||||
* @param cmd3
|
||||
* @param cmd4
|
||||
* @param index
|
||||
*/
|
||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4) {
|
||||
public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int index) {
|
||||
if (constants == null) {
|
||||
constants = Context.getInstance().getHookParser().getConstants();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
Client client = Loader.getClient();
|
||||
|
||||
client.getMenuAction1()[index] = cmd1;
|
||||
|
||||
@@ -9,11 +9,11 @@ import org.rev317.min.Loader;
|
||||
*/
|
||||
public enum Skill {
|
||||
|
||||
ATTACK(0), DEFENSE(1), STRENGTH(2), HITPOINTS(3), CONSTITUTION(3), RANGE(4), PRAYER(
|
||||
5), MAGIC(6), COOKING(7), WOODCUTTING(8), FLETCHING(9), FISHING(10), FIREMAKING(
|
||||
11), CRAFTING(12), SMITHING(13), MINING(14), HERBLORE(15), HERBLAW(
|
||||
15), AGILITY(16), THIEVING(17), SLAYER(18), FARMING(19), RUNECRAFTING(
|
||||
20), HUNTER(21), CONSTRUCTION(22), SUMMONING(23), DUNGEONEERING(24);
|
||||
ATTACK, DEFENSE, STRENGTH, HITPOINTS, CONSTITUTION, RANGE, PRAYER
|
||||
, MAGIC, COOKING, WOODCUTTING, FLETCHING, FISHING, FIREMAKING
|
||||
, CRAFTING, SMITHING, MINING, HERBLORE, HERBLAW
|
||||
, AGILITY, THIEVING, SLAYER, FARMING, RUNECRAFTING
|
||||
, HUNTER, CONSTRUCTION, SUMMONING, DUNGEONEERING;
|
||||
|
||||
private static final int[] EXPERIENCE = { 0, 0, 83, 174, 276, 388, 512,
|
||||
650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,
|
||||
@@ -32,17 +32,12 @@ public enum Skill {
|
||||
42769801, 47221641, 52136869, 57563718, 63555443, 70170840,
|
||||
77474828, 85539082, 94442737, 104273167 };
|
||||
|
||||
private int index;
|
||||
|
||||
private Skill(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Deprecated use Skill.ordinal() instead
|
||||
* Returns the skill's index.
|
||||
*/
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +124,8 @@ public enum Skill {
|
||||
* Done by Bears
|
||||
*/
|
||||
public static final int getCurrentLevel(int index) {
|
||||
return Loader.getClient().getCurrentStats()[index];
|
||||
//return Loader.getClient().getCurrentStats()[index];
|
||||
return getRealLevel(index); //TODO fix this method, it invokes a method not in the client accessor.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,22 +4,30 @@ import org.rev317.min.Loader;
|
||||
import org.rev317.min.accessors.Client;
|
||||
import org.rev317.min.debug.DActions;
|
||||
|
||||
import org.rev317.min.api.events.ActionEvent;
|
||||
|
||||
import org.rev317.min.script.ScriptEngine;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
* @author mat123337
|
||||
*
|
||||
*/
|
||||
public class MenuAction {
|
||||
|
||||
public static void intercept(int index) {
|
||||
if(DActions.debugActions()) {
|
||||
Client client = Loader.getClient();
|
||||
int action1 = client.getMenuAction1()[index];
|
||||
int action2 = client.getMenuAction2()[index];
|
||||
int action3 = client.getMenuAction3()[index];
|
||||
int actionId = client.getMenuActionId()[index];
|
||||
if(DActions.debugActions()) {
|
||||
System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId));
|
||||
}
|
||||
|
||||
final ActionEvent actionEvent = new ActionEvent(actionId,action1,action2,action3,index);
|
||||
ScriptEngine.getInstance().dispatch(actionEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,13 @@ import org.parabot.environment.api.interfaces.Paintable;
|
||||
import org.parabot.environment.scripts.Script;
|
||||
import org.rev317.min.api.events.MessageEvent;
|
||||
import org.rev317.min.api.events.listeners.MessageListener;
|
||||
import org.rev317.min.api.events.ActionEvent;
|
||||
import org.rev317.min.api.events.listeners.ActionListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
* @author matt123337
|
||||
*
|
||||
*/
|
||||
public class ScriptEngine {
|
||||
@@ -23,6 +26,7 @@ public class ScriptEngine {
|
||||
private ArrayList<MouseListener> mouseListeners;
|
||||
private ArrayList<MouseMotionListener> mouseMotionListeners;
|
||||
private ArrayList<MessageListener> messageListeners;
|
||||
private ArrayList<ActionListener> actionListeners;
|
||||
|
||||
private Script script = null;
|
||||
|
||||
@@ -30,6 +34,7 @@ public class ScriptEngine {
|
||||
this.mouseListeners = new ArrayList<MouseListener>();
|
||||
this.mouseMotionListeners = new ArrayList<MouseMotionListener>();
|
||||
this.messageListeners = new ArrayList<MessageListener>();
|
||||
this.actionListeners = new ArrayList<ActionListener>();
|
||||
instances.put(Context.getInstance(), this);
|
||||
}
|
||||
|
||||
@@ -41,6 +46,18 @@ public class ScriptEngine {
|
||||
return new ScriptEngine();
|
||||
}
|
||||
|
||||
public void addActionListener(ActionListener a){
|
||||
actionListeners.add(a);
|
||||
}
|
||||
|
||||
public void removeActionListener(ActionListener a){
|
||||
actionListeners.remove(a);
|
||||
}
|
||||
|
||||
public void clearActionListeners(){
|
||||
actionListeners.clear();
|
||||
}
|
||||
|
||||
public void addMouseListener(MouseListener mouseListener) {
|
||||
mouseListeners.add(mouseListener);
|
||||
}
|
||||
@@ -152,6 +169,12 @@ public class ScriptEngine {
|
||||
messageListener.messageReceived(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatch(ActionEvent event) {
|
||||
for(final ActionListener a : actionListeners) {
|
||||
a.onGameAction(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user