Re-arranged code

This commit is contained in:
JKetelaar
2014-08-19 03:08:07 +02:00
parent d19933b14f
commit 88050384f8
54 changed files with 2867 additions and 2843 deletions
+6 -8
View File
@@ -22,15 +22,17 @@ import java.io.File;
import java.net.URL; import java.net.URL;
/** /**
*
* @author Everel * @author Everel
*
*/ */
@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().getExtendenHookFile(), HookFile.TYPE_XML); private HookFile hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getExtendenHookFile(), HookFile.TYPE_XML);
public static Client getClient() {
return (Client) Context.getInstance().getClient();
}
@Override @Override
public Applet fetchApplet() { public Applet fetchApplet() {
try { try {
@@ -51,17 +53,13 @@ public class Loader extends ServerProvider {
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(), serverProvider.getClientCRC32() + ".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);
} }
public static Client getClient() {
return (Client) Context.getInstance().getClient();
}
@Override @Override
public void addMenuItems(JMenuBar bar) { public void addMenuItems(JMenuBar bar) {
new BotMenu(bar); new BotMenu(bar);
@@ -72,7 +70,7 @@ public class Loader extends ServerProvider {
AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/"); AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/");
try { try {
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); this.hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML);
super.injectHooks(); super.injectHooks();
@@ -1,9 +1,7 @@
package org.rev317.min.api.events; package org.rev317.min.api.events;
/** /**
*
* @author Matt, Everel * @author Matt, Everel
*
*/ */
public final class GameActionEvent { public final class GameActionEvent {
private int index, cmd1, cmd2, cmd3, cmd4, action; private int index, cmd1, cmd2, cmd3, cmd4, action;
@@ -1,19 +1,16 @@
package org.rev317.min.api.events; package org.rev317.min.api.events;
/** /**
*
* @author Everel, Matt * @author Everel, Matt
*
*/ */
public final class MessageEvent { public final class MessageEvent {
private int type;
private String name;
private String message;
public static final int TYPE_GENERIC = 0; public static final int TYPE_GENERIC = 0;
public static final int TYPE_PLAYER = 2; public static final int TYPE_PLAYER = 2;
public static final int TYPE_TRADE = 4; public static final int TYPE_TRADE = 4;
public static final int TYPE_DUEL = 8; public static final int TYPE_DUEL = 8;
private int type;
private String name;
private String message;
public MessageEvent(final int type, String name, String msg) { public MessageEvent(final int type, String name, String msg) {
this.type = type; this.type = type;
@@ -3,9 +3,7 @@ package org.rev317.min.api.events.listeners;
import org.rev317.min.api.events.GameActionEvent; import org.rev317.min.api.events.GameActionEvent;
/** /**
*
* @author Matt * @author Matt
*
*/ */
public interface GameActionListener { public interface GameActionListener {
@@ -3,20 +3,20 @@ package org.rev317.min.api.interfaces;
import org.rev317.min.api.wrappers.Tile; import org.rev317.min.api.wrappers.Tile;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public interface Locatable { public interface Locatable {
/** /**
* Gets location of this locatable instance * Gets location of this locatable instance
*
* @return location * @return location
*/ */
public Tile getLocation(); public Tile getLocation();
/** /**
* Gets distance to this locatable instance * Gets distance to this locatable instance
*
* @return distance from player to locatable * @return distance from player to locatable
*/ */
public int distanceTo(); public int distanceTo();
+20 -24
View File
@@ -1,8 +1,5 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.ArrayList;
import java.util.HashMap;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.environment.api.utils.Time; import org.parabot.environment.api.utils.Time;
import org.parabot.environment.input.Keyboard; import org.parabot.environment.input.Keyboard;
@@ -11,42 +8,41 @@ import org.rev317.min.api.wrappers.Item;
import org.rev317.min.api.wrappers.Npc; import org.rev317.min.api.wrappers.Npc;
import org.rev317.min.api.wrappers.SceneObject; import org.rev317.min.api.wrappers.SceneObject;
import java.util.ArrayList;
import java.util.HashMap;
/** /**
*
* @author Everel * @author Everel
* @author Matt123337 * @author Matt123337
*
*/ */
public class Bank { public class Bank {
public static final int[] BANKERS = new int[]{44, 45, 494, 495, 498, 499,
909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457,
4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948,
9710, 14367};
public static final int[] BANKS = new int[]{782, 2213, 2995, 5276, 6084,
10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808,
26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693,
4483, 12308, 20607, 21301, 27663, 42192};
public static int BANK_INTERFACE = 5292; public static int BANK_INTERFACE = 5292;
public static int ITEM_INTERFACE = 5382; public static int ITEM_INTERFACE = 5382;
public static int BUTTON_DEPOSIT_ALL = 5386; public static int BUTTON_DEPOSIT_ALL = 5386;
public static int INV_PARENT_ID = 5064; public static int INV_PARENT_ID = 5064;
public static int BANK_OPEN_INDEX = 1; public static int BANK_OPEN_INDEX = 1;
static { static {
HashMap<String, String> p = Context.getInstance().getServerProviderInfo().getProperties(); HashMap<String, String> p = Context.getInstance().getServerProviderInfo().getProperties();
if(p.containsKey("bankInterface")) if (p.containsKey("bankInterface"))
BANK_INTERFACE = Integer.parseInt(p.get("bankInterface")); BANK_INTERFACE = Integer.parseInt(p.get("bankInterface"));
if(p.containsKey("bankItemInterface")) if (p.containsKey("bankItemInterface"))
ITEM_INTERFACE = Integer.parseInt(p.get("bankItemInterface")); ITEM_INTERFACE = Integer.parseInt(p.get("bankItemInterface"));
if(p.containsKey("bankDepositAll")) if (p.containsKey("bankDepositAll"))
BUTTON_DEPOSIT_ALL = Integer.parseInt(p.get("bankDepositAll")); BUTTON_DEPOSIT_ALL = Integer.parseInt(p.get("bankDepositAll"));
if(p.containsKey("bankInvParent")) if (p.containsKey("bankInvParent"))
INV_PARENT_ID = Integer.parseInt(p.get("bankInvParent")); INV_PARENT_ID = Integer.parseInt(p.get("bankInvParent"));
if(p.containsKey("bankOpenIndex")) if (p.containsKey("bankOpenIndex"))
BANK_OPEN_INDEX = Integer.parseInt(p.get("bankOpenIndex")); BANK_OPEN_INDEX = Integer.parseInt(p.get("bankOpenIndex"));
} }
public static final int[] BANKERS = new int[] { 44, 45, 494, 495, 498, 499,
909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457,
4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948,
9710, 14367 };
public static final int[] BANKS = new int[] { 782, 2213, 2995, 5276, 6084,
10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808,
26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693,
4483, 12308, 20607, 21301, 27663, 42192 };
/** /**
* Gets nearest banker * Gets nearest banker
* *
@@ -146,6 +142,7 @@ public class Bank {
* Gets bank item with given id * Gets bank item with given id
* *
* @param id * @param id
*
* @return bank item * @return bank item
*/ */
public static Item getItem(int id) { public static Item getItem(int id) {
@@ -166,6 +163,7 @@ public class Bank {
* Counts the amount of items with given id in bank * Counts the amount of items with given id in bank
* *
* @param id * @param id
*
* @return count * @return count
*/ */
public static int getCount(int id) { public static int getCount(int id) {
@@ -178,8 +176,7 @@ public class Bank {
/** /**
* Opens the bank * Opens the bank
* *
* @param bank * @param bank booth
* booth
*/ */
public static void open(SceneObject bank) { public static void open(SceneObject bank) {
@@ -209,8 +206,7 @@ public class Bank {
/** /**
* Deposits all items except the given ids * Deposits all items except the given ids
* *
* @param exceptions * @param exceptions the item indexes that will be ignored.
* the item indexes that will be ignored.
*/ */
public static void depositAllExcept(int... exceptions) { public static void depositAllExcept(int... exceptions) {
if (Bank.isOpen()) { if (Bank.isOpen()) {
@@ -3,9 +3,7 @@ package org.rev317.min.api.methods;
import org.rev317.min.api.wrappers.Tile; import org.rev317.min.api.wrappers.Tile;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Calculations { public class Calculations {
@@ -13,6 +11,7 @@ public class Calculations {
* Calculates distance between local player and given tile * Calculates distance between local player and given tile
* *
* @param tile * @param tile
*
* @return distance between local player and given tile * @return distance between local player and given tile
*/ */
public static final double distanceTo(Tile tile) { public static final double distanceTo(Tile tile) {
@@ -21,8 +20,10 @@ public class Calculations {
/** /**
* Calculates distance between two given tiles * Calculates distance between two given tiles
*
* @param a * @param a
* @param b * @param b
*
* @return distance between a and b * @return distance between a and b
*/ */
public static final double distanceBetween(Tile a, Tile b) { public static final double distanceBetween(Tile a, Tile b) {
@@ -38,7 +39,9 @@ public class Calculations {
* @param destX the destX (0 < destX < 104) * @param destX the destX (0 < destX < 104)
* @param destY the destY (0 < destY < 104) * @param destY the destY (0 < destY < 104)
* @param findAdjacent if it's an object, it will find path which touches it. * @param findAdjacent if it's an object, it will find path which touches it.
* @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was found. *
* @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was
* found.
*/ */
public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) { public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) {
try { try {
+9 -3
View File
@@ -3,14 +3,13 @@ package org.rev317.min.api.methods;
import org.rev317.min.Loader; import org.rev317.min.Loader;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Game { public class Game {
/** /**
* Gets BaseX * Gets BaseX
*
* @return baseX * @return baseX
*/ */
public static int getBaseX() { public static int getBaseX() {
@@ -19,6 +18,7 @@ public class Game {
/** /**
* Gets BaseY * Gets BaseY
*
* @return baseY * @return baseY
*/ */
public static int getBaseY() { public static int getBaseY() {
@@ -27,6 +27,7 @@ public class Game {
/** /**
* Gets open interface id * Gets open interface id
*
* @return interface id * @return interface id
*/ */
public static int getOpenInterfaceId() { public static int getOpenInterfaceId() {
@@ -35,6 +36,7 @@ public class Game {
/** /**
* Get open back dialog id * Get open back dialog id
*
* @return back dialog id * @return back dialog id
*/ */
public static int getOpenBackDialogId() { public static int getOpenBackDialogId() {
@@ -43,6 +45,7 @@ public class Game {
/** /**
* Gets loop cycle * Gets loop cycle
*
* @return loop cycle * @return loop cycle
*/ */
public static int getLoopCycle() { public static int getLoopCycle() {
@@ -51,6 +54,7 @@ public class Game {
/** /**
* Get collision flags * Get collision flags
*
* @return collision flags * @return collision flags
*/ */
public static int[][] getCollisionFlags() { public static int[][] getCollisionFlags() {
@@ -59,6 +63,7 @@ public class Game {
/** /**
* Gets current plane * Gets current plane
*
* @return current plane * @return current plane
*/ */
public static int getPlane() { public static int getPlane() {
@@ -67,13 +72,14 @@ public class Game {
/** /**
* Determines whether this client has action 4 hooked * Determines whether this client has action 4 hooked
*
* @return <code>true</code> if action 4 is hooked * @return <code>true</code> if action 4 is hooked
*/ */
public static boolean hasAction4() { public static boolean hasAction4() {
try { try {
Loader.getClient().getMenuAction4(); Loader.getClient().getMenuAction4();
return true; return true;
} catch(AbstractMethodError e) { } catch (AbstractMethodError e) {
return false; return false;
} }
} }
+10 -13
View File
@@ -1,9 +1,5 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import org.parabot.environment.api.utils.Filter; import org.parabot.environment.api.utils.Filter;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Client; import org.rev317.min.accessors.Client;
@@ -11,14 +7,14 @@ import org.rev317.min.accessors.Deque;
import org.rev317.min.accessors.Node; import org.rev317.min.accessors.Node;
import org.rev317.min.api.wrappers.GroundItem; import org.rev317.min.api.wrappers.GroundItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class GroundItems { public class GroundItems {
private static Client client;
private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() { private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() {
@Override @Override
@@ -27,7 +23,6 @@ public class GroundItems {
} }
}; };
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() { private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
@Override @Override
@@ -36,6 +31,7 @@ public class GroundItems {
} }
}; };
private static Client client;
/** /**
* Gets all loaded ground items * Gets all loaded ground items
@@ -66,10 +62,9 @@ public class GroundItems {
/** /**
* Gets a ground item * Gets a ground item
* *
* @param x * @param x - local region x
* - local region x * @param y - local region y
* @param y *
* - local region y
* @return ground item array * @return ground item array
*/ */
public static final GroundItem[] getGroundItemsAt(final int x, final int y) { public static final GroundItem[] getGroundItemsAt(final int x, final int y) {
@@ -113,6 +108,7 @@ public class GroundItems {
* Returns array of GroundItems with the first index to be the nearest * Returns array of GroundItems with the first index to be the nearest
* *
* @param filter * @param filter
*
* @return GroundItems * @return GroundItems
*/ */
public static final GroundItem[] getNearest(Filter<GroundItem> filter) { public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
@@ -134,6 +130,7 @@ public class GroundItems {
* Returns nearest ground items with given id * Returns nearest ground items with given id
* *
* @param ids * @param ids
*
* @return GroundItems * @return GroundItems
*/ */
public static final GroundItem[] getNearest(final int... ids) { public static final GroundItem[] getNearest(final int... ids) {
+32 -19
View File
@@ -1,18 +1,16 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.ArrayList;
import org.parabot.environment.api.utils.Filter; import org.parabot.environment.api.utils.Filter;
import org.parabot.environment.api.utils.Time; import org.parabot.environment.api.utils.Time;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Interface; import org.rev317.min.accessors.Interface;
import org.rev317.min.api.wrappers.Item; import org.rev317.min.api.wrappers.Item;
import java.util.ArrayList;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Inventory { public class Inventory {
public static final int INVENTORY_INDEX = 3214; public static final int INVENTORY_INDEX = 3214;
@@ -30,7 +28,7 @@ public class Inventory {
* Clears the inventory * Clears the inventory
*/ */
public static void clear() { public static void clear() {
for(Item item : Inventory.getItems()) { for (Item item : Inventory.getItems()) {
item.drop(); item.drop();
Time.sleep(60, 80); Time.sleep(60, 80);
} }
@@ -38,6 +36,7 @@ public class Inventory {
/** /**
* Gets inventory interface * Gets inventory interface
*
* @return interface of inventory * @return interface of inventory
*/ */
public static Interface getInterface() { public static Interface getInterface() {
@@ -46,6 +45,7 @@ public class Inventory {
/** /**
* Gets the amount of items in inventory, excludes the stack sizes * Gets the amount of items in inventory, excludes the stack sizes
*
* @return amount of items * @return amount of items
*/ */
public static final int getCount() { public static final int getCount() {
@@ -54,7 +54,9 @@ public class Inventory {
/** /**
* Gets the amount of items with given ids in inventory, excludes the stack sizes * Gets the amount of items with given ids in inventory, excludes the stack sizes
*
* @param ids * @param ids
*
* @return amount of items * @return amount of items
*/ */
public static final int getCount(int... ids) { public static final int getCount(int... ids) {
@@ -63,19 +65,21 @@ public class Inventory {
/** /**
* Gets the amount of items in inventory * Gets the amount of items in inventory
*
* @param includeStack - true for including stack sizes to the counting * @param includeStack - true for including stack sizes to the counting
*
* @return amount of items * @return amount of items
*/ */
public static final int getCount(final boolean includeStack) { public static final int getCount(final boolean includeStack) {
final Interface inventory = getInterface(); final Interface inventory = getInterface();
if(inventory == null) { if (inventory == null) {
return -1; return -1;
} }
int count = 0; int count = 0;
final int[] items = inventory.getItems(); final int[] items = inventory.getItems();
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null; final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
for(int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
if(items[i] > 0) { if (items[i] > 0) {
count += includeStack ? stackSizes[i] : 1; count += includeStack ? stackSizes[i] : 1;
} }
} }
@@ -84,23 +88,25 @@ public class Inventory {
/** /**
* Gets the amount of items with given ids in inventory * Gets the amount of items with given ids in inventory
*
* @param includeStack - true for including stack sizes to the counting * @param includeStack - true for including stack sizes to the counting
* @param ids * @param ids
*
* @return amount of items * @return amount of items
*/ */
public static final int getCount(final boolean includeStack, int... ids) { public static final int getCount(final boolean includeStack, int... ids) {
final Interface inventory = getInterface(); final Interface inventory = getInterface();
if(inventory == null) { if (inventory == null) {
return -1; return -1;
} }
int count = 0; int count = 0;
final int[] items = inventory.getItems(); final int[] items = inventory.getItems();
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null; final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
for(int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
final int itemId = items[i]; final int itemId = items[i];
if(itemId > 0) { if (itemId > 0) {
for(final int id : ids) { for (final int id : ids) {
if(id == itemId) { if (id == itemId) {
count += includeStack ? stackSizes[i] : 1; count += includeStack ? stackSizes[i] : 1;
break; break;
} }
@@ -112,6 +118,7 @@ public class Inventory {
/** /**
* Gets every item in inventory * Gets every item in inventory
*
* @return items * @return items
*/ */
public static final Item[] getItems() { public static final Item[] getItems() {
@@ -120,7 +127,9 @@ public class Inventory {
/** /**
* Gets all items with given ids * Gets all items with given ids
*
* @param ids * @param ids
*
* @return items * @return items
*/ */
public static final Item[] getItems(final int... ids) { public static final Item[] getItems(final int... ids) {
@@ -128,8 +137,8 @@ public class Inventory {
@Override @Override
public boolean accept(Item e) { public boolean accept(Item e) {
for(int id : ids) { for (int id : ids) {
if(e.getId() == id) { if (e.getId() == id) {
return true; return true;
} }
} }
@@ -141,25 +150,27 @@ public class Inventory {
/** /**
* Gets all items accepted by filter * Gets all items accepted by filter
*
* @param filter * @param filter
*
* @return items * @return items
*/ */
public static final Item[] getItems(final Filter<Item> filter) { public static final Item[] getItems(final Filter<Item> filter) {
final Interface inventory = getInterface(); final Interface inventory = getInterface();
if(inventory == null) { if (inventory == null) {
return null; return null;
} }
final int[] items = inventory.getItems(); final int[] items = inventory.getItems();
final int[] stackSizes = inventory.getStackSizes(); final int[] stackSizes = inventory.getStackSizes();
final ArrayList<Item> invItems = new ArrayList<Item>(28); final ArrayList<Item> invItems = new ArrayList<Item>(28);
for(int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
final int itemId = items[i]; final int itemId = items[i];
if(itemId < 1) { if (itemId < 1) {
continue; continue;
} }
final int stackSize = stackSizes[i]; final int stackSize = stackSizes[i];
final Item item = new Item(itemId, stackSize, i); final Item item = new Item(itemId, stackSize, i);
if(filter.accept(item)) { if (filter.accept(item)) {
invItems.add(item); invItems.add(item);
} }
} }
@@ -168,6 +179,7 @@ public class Inventory {
/** /**
* Determines if inventory is full * Determines if inventory is full
*
* @return <b>true</b> if inventory is full, otherwise <b>false</b> * @return <b>true</b> if inventory is full, otherwise <b>false</b>
*/ */
public static final boolean isFull() { public static final boolean isFull() {
@@ -176,6 +188,7 @@ public class Inventory {
/** /**
* Determines if inventory is empty * Determines if inventory is empty
*
* @return <b>true</b> if inventory is empty, otherwise <b>false</b> * @return <b>true</b> if inventory is empty, otherwise <b>false</b>
*/ */
public static final boolean isEmpty() { public static final boolean isEmpty() {
+15 -11
View File
@@ -1,7 +1,5 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.HashMap;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Client; import org.rev317.min.accessors.Client;
@@ -10,10 +8,10 @@ import org.rev317.min.api.wrappers.GroundItem;
import org.rev317.min.api.wrappers.Item; import org.rev317.min.api.wrappers.Item;
import org.rev317.min.api.wrappers.SceneObject; import org.rev317.min.api.wrappers.SceneObject;
import java.util.HashMap;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Menu { public class Menu {
public static final int ACTION_CLICK_BUTTON = 646; public static final int ACTION_CLICK_BUTTON = 646;
@@ -24,6 +22,7 @@ public class Menu {
/** /**
* Interacts with a sceneobject * Interacts with a sceneobject
*
* @param object * @param object
* @param actionIndex * @param actionIndex
*/ */
@@ -46,7 +45,7 @@ public class Menu {
actionId = 1062; actionId = 1062;
break; break;
} }
if(Game.hasAction4()) { if (Game.hasAction4()) {
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0); sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0);
} else { } else {
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY()); sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY());
@@ -55,6 +54,7 @@ public class Menu {
/** /**
* Interacts with a character * Interacts with a character
*
* @param character * @param character
* @param actionIndex * @param actionIndex
*/ */
@@ -81,11 +81,8 @@ public class Menu {
} }
/** /**
* Interacts with an item when it has the following menu * Interacts with an item when it has the following menu Transform-1 Transform-5 Transform-10 etc..
* Transform-1 *
* Transform-5
* Transform-10
* etc..
* @param item * @param item
* @param actionIndex * @param actionIndex
* @param interfaceParentId * @param interfaceParentId
@@ -116,6 +113,7 @@ public class Menu {
/** /**
* Takes grounditem from the ground * Takes grounditem from the ground
*
* @param item * @param item
*/ */
public static void take(GroundItem item) { public static void take(GroundItem item) {
@@ -124,6 +122,7 @@ public class Menu {
/** /**
* Interacts with a ground item * Interacts with a ground item
*
* @param item * @param item
* @param action * @param action
*/ */
@@ -151,6 +150,7 @@ public class Menu {
/** /**
* Drops an item * Drops an item
*
* @param item * @param item
*/ */
public static void drop(Item item) { public static void drop(Item item) {
@@ -160,6 +160,7 @@ public class Menu {
/** /**
* Clicks a button * Clicks a button
*
* @param id * @param id
*/ */
public static void clickButton(int id) { public static void clickButton(int id) {
@@ -168,6 +169,7 @@ public class Menu {
/** /**
* Sends an action to the client * Sends an action to the client
*
* @param action * @param action
* @param cmd1 * @param cmd1
* @param cmd2 * @param cmd2
@@ -179,6 +181,7 @@ public class Menu {
/** /**
* Sends an action to the client * Sends an action to the client
*
* @param action * @param action
* @param cmd1 * @param cmd1
* @param cmd2 * @param cmd2
@@ -191,6 +194,7 @@ public class Menu {
/** /**
* Sends an action to the client * Sends an action to the client
*
* @param action * @param action
* @param cmd1 * @param cmd1
* @param cmd2 * @param cmd2
@@ -208,7 +212,7 @@ public class Menu {
client.getMenuAction1()[index] = cmd1; client.getMenuAction1()[index] = cmd1;
client.getMenuAction2()[index] = cmd2; client.getMenuAction2()[index] = cmd2;
client.getMenuAction3()[index] = cmd3; client.getMenuAction3()[index] = cmd3;
if(Game.hasAction4()) { if (Game.hasAction4()) {
client.getMenuAction4()[index] = cmd4; client.getMenuAction4()[index] = cmd4;
} }
client.getMenuActionId()[index] = action; client.getMenuActionId()[index] = action;
+14 -9
View File
@@ -1,18 +1,16 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import org.parabot.environment.api.utils.Filter; import org.parabot.environment.api.utils.Filter;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Client; import org.rev317.min.accessors.Client;
import org.rev317.min.api.wrappers.Npc; import org.rev317.min.api.wrappers.Npc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Npcs { public class Npcs {
@@ -38,6 +36,7 @@ public class Npcs {
* Gets all Npcs except local Npc * Gets all Npcs except local Npc
* *
* @param filter * @param filter
*
* @return all Npcs * @return all Npcs
*/ */
public static final Npc[] getNpcs(final Filter<Npc> filter) { public static final Npc[] getNpcs(final Filter<Npc> filter) {
@@ -45,7 +44,7 @@ public class Npcs {
ArrayList<Npc> npcList = new ArrayList<Npc>(); ArrayList<Npc> npcList = new ArrayList<Npc>();
final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs(); final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs();
for (int i = 0; i < accNpcs.length; i++) { for (int i = 0; i < accNpcs.length; i++) {
if(accNpcs[i] == null) { if (accNpcs[i] == null) {
continue; continue;
} }
final Npc npc = new Npc(accNpcs[i], i); final Npc npc = new Npc(accNpcs[i], i);
@@ -67,12 +66,14 @@ public class Npcs {
/** /**
* Gets the closest npc which matches the given filter * Gets the closest npc which matches the given filter
*
* @param filter * @param filter
*
* @return closest npc * @return closest npc
*/ */
public static final Npc getClosest(final Filter<Npc> filter) { public static final Npc getClosest(final Filter<Npc> filter) {
Npc[] npcs = getNearest(filter); Npc[] npcs = getNearest(filter);
if(npcs == null || npcs.length == 0) { if (npcs == null || npcs.length == 0) {
return null; return null;
} }
return npcs[0]; return npcs[0];
@@ -80,12 +81,14 @@ public class Npcs {
/** /**
* Gets the closest npc which matches the given ids * Gets the closest npc which matches the given ids
*
* @param ids * @param ids
*
* @return closest npc * @return closest npc
*/ */
public static final Npc getClosest(int... ids) { public static final Npc getClosest(int... ids) {
Npc[] npcs = getNearest(ids); Npc[] npcs = getNearest(ids);
if(npcs == null || npcs.length == 0) { if (npcs == null || npcs.length == 0) {
return null; return null;
} }
return npcs[0]; return npcs[0];
@@ -95,6 +98,7 @@ public class Npcs {
* Returns array with the first index to be the nearest Npc * Returns array with the first index to be the nearest Npc
* *
* @param filter * @param filter
*
* @return nearest Npcs * @return nearest Npcs
*/ */
public static final Npc[] getNearest(final Filter<Npc> filter) { public static final Npc[] getNearest(final Filter<Npc> filter) {
@@ -107,6 +111,7 @@ public class Npcs {
* Gets nearest npcs which hold given id(s) * Gets nearest npcs which hold given id(s)
* *
* @param ids * @param ids
*
* @return array of npcs with the first index to be the nearest * @return array of npcs with the first index to be the nearest
*/ */
public static final Npc[] getNearest(final int... ids) { public static final Npc[] getNearest(final int... ids) {
+14 -9
View File
@@ -1,18 +1,16 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import org.parabot.environment.api.utils.Filter; import org.parabot.environment.api.utils.Filter;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Client; import org.rev317.min.accessors.Client;
import org.rev317.min.api.wrappers.Player; import org.rev317.min.api.wrappers.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Players { public class Players {
@@ -36,19 +34,21 @@ public class Players {
/** /**
* Gets all players except local player * Gets all players except local player
*
* @param filter * @param filter
*
* @return all players * @return all players
*/ */
public static final Player[] getPlayers(final Filter<Player> filter) { public static final Player[] getPlayers(final Filter<Player> filter) {
final Client client = Loader.getClient(); final Client client = Loader.getClient();
ArrayList<Player> playerList = new ArrayList<Player>(); ArrayList<Player> playerList = new ArrayList<Player>();
final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers(); final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers();
for(int i = 0; i < accPlayers.length; i++) { for (int i = 0; i < accPlayers.length; i++) {
if(accPlayers[i] == null) { if (accPlayers[i] == null) {
continue; continue;
} }
final Player player = new Player(accPlayers[i], i); final Player player = new Player(accPlayers[i], i);
if(filter.accept(player)) { if (filter.accept(player)) {
playerList.add(player); playerList.add(player);
} }
} }
@@ -57,6 +57,7 @@ public class Players {
/** /**
* Gets all players except local player * Gets all players except local player
*
* @return all players * @return all players
*/ */
public static final Player[] getPlayers() { public static final Player[] getPlayers() {
@@ -65,7 +66,9 @@ public class Players {
/** /**
* Returns array with the first index to be the nearest player * Returns array with the first index to be the nearest player
*
* @param filter * @param filter
*
* @return nearest players * @return nearest players
*/ */
public static final Player[] getNearest(final Filter<Player> filter) { public static final Player[] getNearest(final Filter<Player> filter) {
@@ -76,6 +79,7 @@ public class Players {
/** /**
* Returns array with the first index to be the nearest player * Returns array with the first index to be the nearest player
*
* @return nearest players * @return nearest players
*/ */
public static final Player[] getNearest() { public static final Player[] getNearest() {
@@ -84,6 +88,7 @@ public class Players {
/** /**
* Gets local player * Gets local player
*
* @return local player * @return local player
*/ */
public static Player getMyPlayer() { public static Player getMyPlayer() {
@@ -1,27 +1,25 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import org.parabot.environment.api.utils.Filter; import org.parabot.environment.api.utils.Filter;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Ground; import org.rev317.min.accessors.Ground;
import org.rev317.min.accessors.SceneObjectTile; import org.rev317.min.accessors.SceneObjectTile;
import org.rev317.min.api.wrappers.SceneObject; import org.rev317.min.api.wrappers.SceneObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class SceneObjects { public class SceneObjects {
private static final Comparator<SceneObject> NEAREST_SORTER = new Comparator<SceneObject>() { private static final Comparator<SceneObject> NEAREST_SORTER = new Comparator<SceneObject>() {
@Override @Override
public int compare(SceneObject n1,SceneObject n2) { public int compare(SceneObject n1, SceneObject n2) {
return n1.distanceTo() - n2.distanceTo(); return n1.distanceTo() - n2.distanceTo();
} }
@@ -37,15 +35,17 @@ public class SceneObjects {
}; };
/** /**
* Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall decorations, ground decorations' * Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall
* decorations, ground decorations'
*
* @return scene objects * @return scene objects
*/ */
public static final SceneObject[] getSceneObjects(Filter<SceneObject> filter) { public static final SceneObject[] getSceneObjects(Filter<SceneObject> filter) {
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>(); ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
for(int x = 0; x < 104; x++) { for (int x = 0; x < 104; x++) {
for(int y = 0; y < 104; y++) { for (int y = 0; y < 104; y++) {
final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true); final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true);
if(sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) { if (sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) {
sceneObjects.add(sceneObjectAtTile); sceneObjects.add(sceneObjectAtTile);
} }
@@ -56,6 +56,7 @@ public class SceneObjects {
/** /**
* Gets the most important scene objects in game which can be interacted with * Gets the most important scene objects in game which can be interacted with
*
* @return scene objects * @return scene objects
*/ */
public static final SceneObject[] getSceneObjects() { public static final SceneObject[] getSceneObjects() {
@@ -64,7 +65,9 @@ public class SceneObjects {
/** /**
* Returns array of sceneobjects with the first index to be the nearest * Returns array of sceneobjects with the first index to be the nearest
*
* @param filter * @param filter
*
* @return sceneobjects * @return sceneobjects
*/ */
public static final SceneObject[] getNearest(Filter<SceneObject> filter) { public static final SceneObject[] getNearest(Filter<SceneObject> filter) {
@@ -75,6 +78,7 @@ public class SceneObjects {
/** /**
* Returns array of sceneobjects with the first index to be the nearest * Returns array of sceneobjects with the first index to be the nearest
*
* @return sceneobjects * @return sceneobjects
*/ */
public static final SceneObject[] getNearest() { public static final SceneObject[] getNearest() {
@@ -83,7 +87,9 @@ public class SceneObjects {
/** /**
* Returns nearest objects with given id * Returns nearest objects with given id
*
* @param ids * @param ids
*
* @return sceneobjects * @return sceneobjects
*/ */
public static final SceneObject[] getNearest(final int... ids) { public static final SceneObject[] getNearest(final int... ids) {
@@ -91,8 +97,8 @@ public class SceneObjects {
@Override @Override
public boolean accept(SceneObject object) { public boolean accept(SceneObject object) {
for(final int id : ids) { for (final int id : ids) {
if(id == object.getId()) { if (id == object.getId()) {
return true; return true;
} }
} }
@@ -107,8 +113,8 @@ public class SceneObjects {
@Override @Override
public boolean accept(SceneObject object) { public boolean accept(SceneObject object) {
for(final int id : ids) { for (final int id : ids) {
if(id == object.getId()) { if (id == object.getId()) {
return true; return true;
} }
} }
@@ -116,7 +122,7 @@ public class SceneObjects {
} }
}); });
if(nearestObjects == null || nearestObjects.length == 0) { if (nearestObjects == null || nearestObjects.length == 0) {
return null; return null;
} }
return nearestObjects[0]; return nearestObjects[0];
@@ -124,20 +130,20 @@ public class SceneObjects {
private static SceneObject getSceneObjectAtTile(int x, int y, boolean useCached) { private static SceneObject getSceneObjectAtTile(int x, int y, boolean useCached) {
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y]; Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
if(sceneTile == null) { if (sceneTile == null) {
return null; return null;
} }
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects(); final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
if(interactiveObjects != null) { if (interactiveObjects != null) {
for(final SceneObjectTile interactiveObject : interactiveObjects) { for (final SceneObjectTile interactiveObject : interactiveObjects) {
// get top // get top
if(interactiveObject != null) { if (interactiveObject != null) {
return new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE); return new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE);
} }
} }
} }
SceneObjectTile sceneObjectTile = sceneTile.getWallObject(); SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
if(sceneObjectTile != null) { if (sceneObjectTile != null) {
return new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL); return new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL);
} }
return null; return null;
@@ -145,14 +151,15 @@ public class SceneObjects {
/** /**
* Gets every loaded scene object in game * Gets every loaded scene object in game
*
* @return every loaded scene object in game * @return every loaded scene object in game
*/ */
public static final SceneObject[] getAllSceneObjects() { public static final SceneObject[] getAllSceneObjects() {
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>(); ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
for(int x = 0; x < 104; x++) { for (int x = 0; x < 104; x++) {
for(int y = 0; y < 104; y++) { for (int y = 0; y < 104; y++) {
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true); final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true);
if(sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) { if (sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
sceneObjects.addAll(sceneObjectsAtTile); sceneObjects.addAll(sceneObjectsAtTile);
} }
} }
@@ -162,19 +169,21 @@ public class SceneObjects {
/** /**
* Gets all sceneobjects at a tile * Gets all sceneobjects at a tile
*
* @param x * @param x
* @param y * @param y
* @param useCached * @param useCached
*
* @return array of sceneobjects, or null if there aren't any * @return array of sceneobjects, or null if there aren't any
*/ */
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) { public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) {
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y]; Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
ArrayList<SceneObject> sceneObjects = null; ArrayList<SceneObject> sceneObjects = null;
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects(); final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
if(interactiveObjects != null) { if (interactiveObjects != null) {
for(final SceneObjectTile interactiveObject : interactiveObjects) { for (final SceneObjectTile interactiveObject : interactiveObjects) {
if(interactiveObject != null) { if (interactiveObject != null) {
if(sceneObjects == null) { if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>(); sceneObjects = new ArrayList<SceneObject>();
} }
sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE)); sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE));
@@ -182,32 +191,32 @@ public class SceneObjects {
} }
} }
SceneObjectTile sceneObjectTile = sceneTile.getWallObject(); SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
if(sceneObjectTile != null) { if (sceneObjectTile != null) {
if(sceneObjects == null) { if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>(); sceneObjects = new ArrayList<SceneObject>();
} }
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL)); sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL));
} }
sceneObjectTile = sceneTile.getWallDecoration(); sceneObjectTile = sceneTile.getWallDecoration();
if(sceneObjectTile != null) { if (sceneObjectTile != null) {
if(sceneObjects == null) { if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>(); sceneObjects = new ArrayList<SceneObject>();
} }
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION)); sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION));
} }
sceneObjectTile = sceneTile.getGroundDecoration(); sceneObjectTile = sceneTile.getGroundDecoration();
if(sceneObjectTile != null) { if (sceneObjectTile != null) {
if(sceneObjects == null) { if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>(); sceneObjects = new ArrayList<SceneObject>();
} }
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION)); sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION));
} }
sceneObjectTile = sceneTile.getGroundItem(); sceneObjectTile = sceneTile.getGroundItem();
if(sceneObjectTile != null) { if (sceneObjectTile != null) {
if(sceneObjects == null) { if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>(); sceneObjects = new ArrayList<SceneObject>();
} }
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDITEM)); sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDITEM));
+102 -110
View File
@@ -3,19 +3,13 @@ package org.rev317.min.api.methods;
import org.rev317.min.Loader; import org.rev317.min.Loader;
/** /**
*
* @author Dane * @author Dane
*
*/ */
public enum Skill { public enum Skill {
ATTACK, DEFENSE, STRENGTH, HITPOINTS, CONSTITUTION, RANGE, PRAYER 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;
, 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, private static final int[] EXPERIENCE = {0, 0, 83, 174, 276, 388, 512,
650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,
3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,
12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
@@ -30,11 +24,106 @@ public enum Skill {
13034431, 14391160, 15889109, 17542976, 19368992, 21385073, 13034431, 14391160, 15889109, 17542976, 19368992, 21385073,
23611006, 26068632, 28782069, 31777943, 35085654, 38737661, 23611006, 26068632, 28782069, 31777943, 35085654, 38737661,
42769801, 47221641, 52136869, 57563718, 63555443, 70170840, 42769801, 47221641, 52136869, 57563718, 63555443, 70170840,
77474828, 85539082, 94442737, 104273167 }; 77474828, 85539082, 94442737, 104273167};
/** /**
* @Deprecated use Skill.ordinal() instead * Returns the experience of the provided skill.
* Returns the skill's index. *
* @param index the skill index.
*
* @return the experience.
*/
public static final int getCurrentExperience(int index) {
return Loader.getClient().getCurrentExp()[index];
}
/**
* Returns the real level of the provided skill.
*
* @param index the skill index.
*
* @return the real skill level.
*/
public static final int getRealLevel(int index) {
return getLevelByExperience(getCurrentExperience(index));
}
/**
* Returns the current level of the provided skill. (Will return de-buffed/buffed levels)
*
* @param index the skill index.
*
* @return the current skill level. Done by Bears
*/
public static final int getCurrentLevel(int index) {
//return Loader.getClient().getCurrentStats()[index];
return getRealLevel(index); //TODO fix this method, it invokes a method not in the client accessor.
}
/**
* Returns the exact experience at the provided level.
*
* @param level the level.
*
* @return the experience at the provided level.
*/
public static final int getExperienceByLevel(int level) {
if (level > 99 || level < 1) {
return 0;
}
return EXPERIENCE[level];
}
/**
* Returns the exact level with the provided experience.
*
* @param experience the experience.
*
* @return the level at the provided experience.
*/
public static final int getLevelByExperience(int experience) {
for (int i = EXPERIENCE.length - 1; i > 0; i--) {
if (experience > EXPERIENCE[i]) {
return i;
}
}
return 1;
}
/**
* Returns the remaining experience for the provided skill to level up.
*
* @param index the skill index.
*
* @return the remaining experience.
*/
public static final int getRemainingExperience(int index) {
int level = getLevelByExperience(getCurrentExperience(index));
if (level >= 99 || level < 1) {
return 0;
}
return EXPERIENCE[(level + 1)] - getCurrentExperience(index);
}
/**
* Returns the percentage to the next level for the provided skill.
*
* @param index the skill index.
*
* @return the remaining percentage.
*/
public static final int getPercentToNextLevel(int index) {
int currentLevel = getLevelByExperience(getCurrentExperience(index));
int nextLevel = currentLevel + 1;
if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1
|| nextLevel < 1) {
return 0;
}
return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel]));
}
/**
* @Deprecated use Skill.ordinal() instead Returns the skill's index.
*/ */
public int getIndex() { public int getIndex() {
return ordinal(); return ordinal();
@@ -63,8 +152,8 @@ public enum Skill {
} }
/** /**
* Returns the current level. (For example, if you've been de-buffed by a spell, or drank a beer that buffs the stat; it will return the buffed level.) * Returns the current level. (For example, if you've been de-buffed by a spell, or drank a beer that buffs the
* Done by Bears * stat; it will return the buffed level.) Done by Bears
*/ */
public final int getLevel() { public final int getLevel() {
return Skill.getCurrentLevel(this.getIndex()); return Skill.getCurrentLevel(this.getIndex());
@@ -92,101 +181,4 @@ public enum Skill {
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / " return "Skill: [" + this.getName() + ": " + this.getLevel() + " / "
+ this.getRealLevel() + "]"; + this.getRealLevel() + "]";
} }
/**
* Returns the experience of the provided skill.
*
* @param index
* the skill index.
* @return the experience.
*/
public static final int getCurrentExperience(int index) {
return Loader.getClient().getCurrentExp()[index];
}
/**
* Returns the real level of the provided skill.
*
* @param index
* the skill index.
* @return the real skill level.
*/
public static final int getRealLevel(int index) {
return getLevelByExperience(getCurrentExperience(index));
}
/**
* Returns the current level of the provided skill. (Will return de-buffed/buffed levels)
*
* @param index
* the skill index.
* @return the current skill level.
* Done by Bears
*/
public static final int getCurrentLevel(int index) {
//return Loader.getClient().getCurrentStats()[index];
return getRealLevel(index); //TODO fix this method, it invokes a method not in the client accessor.
}
/**
* Returns the exact experience at the provided level.
*
* @param level
* the level.
* @return the experience at the provided level.
*/
public static final int getExperienceByLevel(int level) {
if (level > 99 || level < 1) {
return 0;
}
return EXPERIENCE[level];
}
/**
* Returns the exact level with the provided experience.
*
* @param experience
* the experience.
* @return the level at the provided experience.
*/
public static final int getLevelByExperience(int experience) {
for (int i = EXPERIENCE.length - 1; i > 0; i--) {
if (experience > EXPERIENCE[i]) {
return i;
}
}
return 1;
}
/**
* Returns the remaining experience for the provided skill to level up.
*
* @param index
* the skill index.
* @return the remaining experience.
*/
public static final int getRemainingExperience(int index) {
int level = getLevelByExperience(getCurrentExperience(index));
if (level >= 99 || level < 1) {
return 0;
}
return EXPERIENCE[(level + 1)] - getCurrentExperience(index);
}
/**
* Returns the percentage to the next level for the provided skill.
*
* @param index
* the skill index.
* @return the remaining percentage.
*/
public static final int getPercentToNextLevel(int index) {
int currentLevel = getLevelByExperience(getCurrentExperience(index));
int nextLevel = currentLevel + 1;
if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1
|| nextLevel < 1) {
return 0;
}
return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel]));
}
} }
+5 -4
View File
@@ -5,14 +5,13 @@ import org.rev317.min.api.wrappers.Tile;
import org.rev317.min.api.wrappers.TilePath; import org.rev317.min.api.wrappers.TilePath;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Walking { public class Walking {
/** /**
* Walks from tile to tile * Walks from tile to tile
*
* @param from * @param from
* @param to * @param to
*/ */
@@ -21,12 +20,12 @@ public class Walking {
} }
/** /**
*
* @param tilePath * @param tilePath
*
* @return <b>true</b> if destination reached, otherwise <b>false</b> * @return <b>true</b> if destination reached, otherwise <b>false</b>
*/ */
public static boolean walkDown(TilePath tilePath) { public static boolean walkDown(TilePath tilePath) {
if(tilePath.hasReached()) { if (tilePath.hasReached()) {
return true; return true;
} }
tilePath.traverse(); tilePath.traverse();
@@ -35,7 +34,9 @@ public class Walking {
/** /**
* Gets nearest reachable tile on minimap to given tile * Gets nearest reachable tile on minimap to given tile
*
* @param tile * @param tile
*
* @return nearest reachable tile on minimap * @return nearest reachable tile on minimap
*/ */
public static Tile getNearestTileTo(Tile tile) { public static Tile getNearestTileTo(Tile tile) {
@@ -9,9 +9,7 @@ import org.rev317.min.api.methods.Menu;
import org.rev317.min.api.methods.Players; import org.rev317.min.api.methods.Players;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Character implements Locatable { public class Character implements Locatable {
@@ -151,12 +149,13 @@ public class Character implements Locatable {
* *
* @return <b>true</b> if entity is logged in * @return <b>true</b> if entity is logged in
*/ */
public boolean isLoggedIn(){ public boolean isLoggedIn() {
return accessor.isLoggedIn(); return accessor.isLoggedIn();
} }
/** /**
* Gets the accessor class * Gets the accessor class
*
* @return RefClass of accessor * @return RefClass of accessor
*/ */
public RefClass getRefClass() { public RefClass getRefClass() {
@@ -7,9 +7,7 @@ import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Menu; import org.rev317.min.api.methods.Menu;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class GroundItem implements Locatable { public class GroundItem implements Locatable {
private org.rev317.min.accessors.Item accessor; private org.rev317.min.accessors.Item accessor;
@@ -24,6 +22,7 @@ public class GroundItem implements Locatable {
/** /**
* Gets location of this ground item * Gets location of this ground item
*
* @return location * @return location
*/ */
public Tile getLocation() { public Tile getLocation() {
@@ -32,6 +31,7 @@ public class GroundItem implements Locatable {
/** /**
* Gets region X * Gets region X
*
* @return x * @return x
*/ */
public int getX() { public int getX() {
@@ -40,6 +40,7 @@ public class GroundItem implements Locatable {
/** /**
* Gets region Y * Gets region Y
*
* @return y * @return y
*/ */
public int getY() { public int getY() {
@@ -48,6 +49,7 @@ public class GroundItem implements Locatable {
/** /**
* Interacts with this ground item * Interacts with this ground item
*
* @param actionIndex * @param actionIndex
*/ */
public void interact(int actionIndex) { public void interact(int actionIndex) {
@@ -63,6 +65,7 @@ public class GroundItem implements Locatable {
/** /**
* Gets distance between you and this ground item * Gets distance between you and this ground item
*
* @return distance * @return distance
*/ */
public int distanceTo() { public int distanceTo() {
@@ -71,6 +74,7 @@ public class GroundItem implements Locatable {
/** /**
* Get's ID of this item * Get's ID of this item
*
* @return ID * @return ID
*/ */
public int getId() { public int getId() {
@@ -79,6 +83,7 @@ public class GroundItem implements Locatable {
/** /**
* Gets the accessor class * Gets the accessor class
*
* @return RefClass of accessor * @return RefClass of accessor
*/ */
public RefClass getRefClass() { public RefClass getRefClass() {
+4 -2
View File
@@ -3,9 +3,7 @@ package org.rev317.min.api.wrappers;
import org.rev317.min.api.methods.Menu; import org.rev317.min.api.methods.Menu;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Item { public class Item {
private int id, stackSize; private int id, stackSize;
@@ -19,6 +17,7 @@ public class Item {
/** /**
* Get id of this item * Get id of this item
*
* @return id * @return id
*/ */
public int getId() { public int getId() {
@@ -27,6 +26,7 @@ public class Item {
/** /**
* Gets quantity of this item * Gets quantity of this item
*
* @return stack size * @return stack size
*/ */
public int getStackSize() { public int getStackSize() {
@@ -35,6 +35,7 @@ public class Item {
/** /**
* Item slot * Item slot
*
* @return slot * @return slot
*/ */
public int getSlot() { public int getSlot() {
@@ -50,6 +51,7 @@ public class Item {
/** /**
* Interacts with this item * Interacts with this item
*
* @param i * @param i
*/ */
public void interact(int i) { public void interact(int i) {
+2 -2
View File
@@ -3,9 +3,7 @@ package org.rev317.min.api.wrappers;
import org.parabot.core.reflect.RefClass; import org.parabot.core.reflect.RefClass;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public final class Npc extends Character { public final class Npc extends Character {
private org.rev317.min.accessors.Npc accessor; private org.rev317.min.accessors.Npc accessor;
@@ -18,6 +16,7 @@ public final class Npc extends Character {
/** /**
* Gets the definition of this npc * Gets the definition of this npc
*
* @return npc definitions * @return npc definitions
*/ */
public final NpcDef getDef() { public final NpcDef getDef() {
@@ -26,6 +25,7 @@ public final class Npc extends Character {
/** /**
* Gets the accessor class * Gets the accessor class
*
* @return RefClass of accessor * @return RefClass of accessor
*/ */
public RefClass getRefClass() { public RefClass getRefClass() {
+2 -2
View File
@@ -3,9 +3,7 @@ package org.rev317.min.api.wrappers;
import org.parabot.core.reflect.RefClass; import org.parabot.core.reflect.RefClass;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class NpcDef { public class NpcDef {
private org.rev317.min.accessors.NpcDef accessor; private org.rev317.min.accessors.NpcDef accessor;
@@ -16,6 +14,7 @@ public class NpcDef {
/** /**
* Gets id of this item * Gets id of this item
*
* @return id of this item * @return id of this item
*/ */
public int getId() { public int getId() {
@@ -24,6 +23,7 @@ public class NpcDef {
/** /**
* Gets the accessor class * Gets the accessor class
*
* @return RefClass of accessor * @return RefClass of accessor
*/ */
public RefClass getRefClass() { public RefClass getRefClass() {
@@ -1,9 +1,7 @@
package org.rev317.min.api.wrappers; package org.rev317.min.api.wrappers;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class Player extends Character { public class Player extends Character {
@@ -8,9 +8,7 @@ import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Menu; import org.rev317.min.api.methods.Menu;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class SceneObject implements Locatable { public class SceneObject implements Locatable {
public static final int TYPE_WALL = 0; // object1 public static final int TYPE_WALL = 0; // object1
@@ -38,6 +36,7 @@ public class SceneObject implements Locatable {
/** /**
* Gets location of this tile * Gets location of this tile
*
* @return location * @return location
*/ */
public final Tile getLocation() { public final Tile getLocation() {
@@ -46,6 +45,7 @@ public class SceneObject implements Locatable {
/** /**
* Gets region X * Gets region X
*
* @return region X * @return region X
*/ */
public final int getLocalRegionX() { public final int getLocalRegionX() {
@@ -54,6 +54,7 @@ public class SceneObject implements Locatable {
/** /**
* Gets region Y * Gets region Y
*
* @return region Y * @return region Y
*/ */
public final int getLocalRegionY() { public final int getLocalRegionY() {
@@ -80,6 +81,7 @@ public class SceneObject implements Locatable {
/** /**
* Calculates distance to this object * Calculates distance to this object
*
* @return distance * @return distance
*/ */
public final int distanceTo() { public final int distanceTo() {
@@ -88,6 +90,7 @@ public class SceneObject implements Locatable {
/** /**
* Interacts with this object * Interacts with this object
*
* @param actionIndex * @param actionIndex
*/ */
public void interact(int actionIndex) { public void interact(int actionIndex) {
@@ -96,6 +99,7 @@ public class SceneObject implements Locatable {
/** /**
* Gets the accessor class * Gets the accessor class
*
* @return RefClass of accessor * @return RefClass of accessor
*/ */
public RefClass getRefClass() { public RefClass getRefClass() {
+7 -2
View File
@@ -8,11 +8,9 @@ import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.Walking; import org.rev317.min.api.methods.Walking;
/** /**
*
* Class which holds a world location * Class which holds a world location
* *
* @author Everel * @author Everel
*
*/ */
public final class Tile implements TileFlags, Locatable { public final class Tile implements TileFlags, Locatable {
private int x; private int x;
@@ -50,6 +48,7 @@ public final class Tile implements TileFlags, Locatable {
/** /**
* Gets region x * Gets region x
*
* @return region x * @return region x
*/ */
public final int getRegionX() { public final int getRegionX() {
@@ -58,6 +57,7 @@ public final class Tile implements TileFlags, Locatable {
/** /**
* Gets region y * Gets region y
*
* @return region y * @return region y
*/ */
public final int getRegionY() { public final int getRegionY() {
@@ -128,6 +128,7 @@ public final class Tile implements TileFlags, Locatable {
/** /**
* Determines if this tile is walkable * Determines if this tile is walkable
*
* @return <code>true</code> if this tile is walkable, otherwise <code>false</code> * @return <code>true</code> if this tile is walkable, otherwise <code>false</code>
*/ */
public boolean isWalkable() { public boolean isWalkable() {
@@ -136,7 +137,9 @@ public final class Tile implements TileFlags, Locatable {
/** /**
* Determines if this tile is reachable * Determines if this tile is reachable
*
* @param isObject whether this tile is an object tile * @param isObject whether this tile is an object tile
*
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code> * @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
*/ */
public boolean isReachable(boolean isObject) { public boolean isReachable(boolean isObject) {
@@ -146,6 +149,7 @@ public final class Tile implements TileFlags, Locatable {
/** /**
* Determines if this tile is reachable * Determines if this tile is reachable
*
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code> * @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
*/ */
public boolean isReachable() { public boolean isReachable() {
@@ -154,6 +158,7 @@ public final class Tile implements TileFlags, Locatable {
/** /**
* Determines if this tile is an object tile * Determines if this tile is an object tile
*
* @return <code>true</code> if this tile is an object tile, otherwise <code>false</code> * @return <code>true</code> if this tile is an object tile, otherwise <code>false</code>
*/ */
public boolean isObjectTile() { public boolean isObjectTile() {
@@ -1,9 +1,7 @@
package org.rev317.min.api.wrappers; package org.rev317.min.api.wrappers;
/** /**
*
* @author Everel * @author Everel
*
*/ */
public class TilePath { public class TilePath {
+2 -4
View File
@@ -2,16 +2,14 @@ package org.rev317.min.callback;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.accessors.Client; import org.rev317.min.accessors.Client;
import org.rev317.min.debug.DActions;
import org.rev317.min.api.events.GameActionEvent; import org.rev317.min.api.events.GameActionEvent;
import org.rev317.min.api.methods.Game; import org.rev317.min.api.methods.Game;
import org.rev317.min.debug.DActions;
import org.rev317.min.script.ScriptEngine; import org.rev317.min.script.ScriptEngine;
/** /**
*
* @author Everel * @author Everel
* @author Matt123337 * @author Matt123337
*
*/ */
public class MenuAction { public class MenuAction {
@@ -23,7 +21,7 @@ public class MenuAction {
int action4 = 0; int action4 = 0;
int actionId = client.getMenuActionId()[index]; int actionId = client.getMenuActionId()[index];
if (DActions.debugActions()) { if (DActions.debugActions()) {
if(Game.hasAction4()) { if (Game.hasAction4()) {
action4 = client.getMenuAction4()[index]; action4 = client.getMenuAction4()[index];
System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId)); System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId));
} else { } else {
@@ -1,7 +1,6 @@
package org.rev317.min.callback; package org.rev317.min.callback;
import org.rev317.min.api.events.MessageEvent; import org.rev317.min.api.events.MessageEvent;
import org.rev317.min.script.ScriptEngine; import org.rev317.min.script.ScriptEngine;
+6 -6
View File
@@ -1,12 +1,16 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import java.awt.*;
public class DActions extends AbstractDebugger { public class DActions extends AbstractDebugger {
private static boolean enabled; private static boolean enabled;
public static boolean debugActions() {
return enabled;
}
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
} }
@@ -21,8 +25,4 @@ public class DActions extends AbstractDebugger {
enabled = !enabled; enabled = !enabled;
} }
public static boolean debugActions() {
return enabled;
}
} }
+2 -2
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Players; import org.rev317.min.api.methods.Players;
import java.awt.*;
public class DAnimation extends AbstractDebugger { public class DAnimation extends AbstractDebugger {
private boolean enabled; private boolean enabled;
+2 -2
View File
@@ -1,10 +1,10 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Bank; import org.rev317.min.api.methods.Bank;
import java.awt.*;
public class DBank extends AbstractDebugger { public class DBank extends AbstractDebugger {
@Override @Override
@@ -1,7 +1,5 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger; import org.parabot.core.paint.PaintDebugger;
@@ -9,6 +7,8 @@ import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Players; import org.rev317.min.api.methods.Players;
import org.rev317.min.api.wrappers.Tile; import org.rev317.min.api.wrappers.Tile;
import java.awt.*;
public class DCollisionFlags extends AbstractDebugger { public class DCollisionFlags extends AbstractDebugger {
private boolean enabled; private boolean enabled;
+4 -4
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.GroundItems; import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.wrappers.GroundItem; import org.rev317.min.api.wrappers.GroundItem;
import java.awt.*;
public class DGroundItems extends AbstractDebugger { public class DGroundItems extends AbstractDebugger {
@Override @Override
@@ -21,10 +21,10 @@ public class DGroundItems extends AbstractDebugger {
@Override @Override
public void toggle() { public void toggle() {
GroundItem[] items = GroundItems.getNearest(); GroundItem[] items = GroundItems.getNearest();
if(items == null || items.length == 0) { if (items == null || items.length == 0) {
return; return;
} }
for(GroundItem item : items) { for (GroundItem item : items) {
System.out.println("ID: " + item.getId() + " Location: " + item.getLocation()); System.out.println("ID: " + item.getId() + " Location: " + item.getLocation());
} }
} }
+2 -2
View File
@@ -1,12 +1,12 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger; import org.parabot.core.paint.PaintDebugger;
import org.rev317.min.api.methods.Game; import org.rev317.min.api.methods.Game;
import java.awt.*;
public class DInterfaces extends AbstractDebugger { public class DInterfaces extends AbstractDebugger {
private boolean enabled; private boolean enabled;
+3 -3
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Inventory; import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.wrappers.Item; import org.rev317.min.api.wrappers.Item;
import java.awt.*;
public class DInventory extends AbstractDebugger { public class DInventory extends AbstractDebugger {
@Override @Override
@@ -20,7 +20,7 @@ public class DInventory extends AbstractDebugger {
@Override @Override
public void toggle() { public void toggle() {
for(Item i : Inventory.getItems()) { for (Item i : Inventory.getItems()) {
System.out.println("ID: " + i.getId() + " Stack: " + i.getStackSize() + " Slot: " + i.getSlot()); System.out.println("ID: " + i.getId() + " Stack: " + i.getStackSize() + " Slot: " + i.getSlot());
} }
} }
+2 -2
View File
@@ -1,13 +1,13 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger; import org.parabot.core.paint.PaintDebugger;
import org.rev317.min.api.methods.Game; import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Players; import org.rev317.min.api.methods.Players;
import java.awt.*;
public class DMap extends AbstractDebugger { public class DMap extends AbstractDebugger {
private boolean enabled; private boolean enabled;
+2 -2
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.parabot.environment.input.Mouse; import org.parabot.environment.input.Mouse;
import java.awt.*;
public class DMouse extends AbstractDebugger { public class DMouse extends AbstractDebugger {
private boolean enabled; private boolean enabled;
+3 -3
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Npcs; import org.rev317.min.api.methods.Npcs;
import org.rev317.min.api.wrappers.Npc; import org.rev317.min.api.wrappers.Npc;
import java.awt.*;
public class DNpcs extends AbstractDebugger { public class DNpcs extends AbstractDebugger {
@Override @Override
@@ -20,7 +20,7 @@ public class DNpcs extends AbstractDebugger {
@Override @Override
public void toggle() { public void toggle() {
for(Npc n : Npcs.getNearest()) { for (Npc n : Npcs.getNearest()) {
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString()); System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
} }
+5 -5
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug; package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.SceneObjects; import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject; import org.rev317.min.api.wrappers.SceneObject;
import java.awt.*;
public class DSceneObjects extends AbstractDebugger { public class DSceneObjects extends AbstractDebugger {
@Override @Override
@@ -20,15 +20,15 @@ public class DSceneObjects extends AbstractDebugger {
@Override @Override
public void toggle() { public void toggle() {
SceneObject[] objects = SceneObjects.getNearest(); SceneObject[] objects = SceneObjects.getNearest();
if(objects == null || objects.length == 0) if (objects == null || objects.length == 0)
return; return;
for (int i = objects.length - 1; i >= 0; i--) { for (int i = objects.length - 1; i >= 0; i--) {
System.out.println( System.out.println(
" ID: " + objects[i].getId() + " ID: " + objects[i].getId() +
" UID: " + objects[i].getHash() + " UID: " + objects[i].getHash() +
" Location: "+ objects[i].getLocation() + " Location: " + objects[i].getLocation() +
" Distance: "+ objects[i].distanceTo()); " Distance: " + objects[i].distanceTo());
} }
} }
+33 -35
View File
@@ -1,25 +1,23 @@
package org.rev317.min.script; package org.rev317.min.script;
import java.awt.AWTEvent; import org.parabot.core.Context;
import org.parabot.environment.api.interfaces.Paintable;
import org.parabot.environment.scripts.Script;
import org.rev317.min.api.events.GameActionEvent;
import org.rev317.min.api.events.MessageEvent;
import org.rev317.min.api.events.listeners.GameActionListener;
import org.rev317.min.api.events.listeners.MessageListener;
import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.parabot.core.Context;
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.GameActionEvent;
import org.rev317.min.api.events.listeners.GameActionListener;
/** /**
*
* @author Everel * @author Everel
* @author matt123337 * @author matt123337
*
*/ */
public class ScriptEngine { public class ScriptEngine {
private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>(); private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>();
@@ -40,21 +38,21 @@ public class ScriptEngine {
public static ScriptEngine getInstance() { public static ScriptEngine getInstance() {
final ScriptEngine engine = instances.get(Context.getInstance()); final ScriptEngine engine = instances.get(Context.getInstance());
if(engine != null) { if (engine != null) {
return engine; return engine;
} }
return new ScriptEngine(); return new ScriptEngine();
} }
public void addActionListener(GameActionListener a){ public void addActionListener(GameActionListener a) {
actionListeners.add(a); actionListeners.add(a);
} }
public void removeActionListener(GameActionListener a){ public void removeActionListener(GameActionListener a) {
actionListeners.remove(a); actionListeners.remove(a);
} }
public void clearActionListeners(){ public void clearActionListeners() {
actionListeners.clear(); actionListeners.clear();
} }
@@ -102,43 +100,43 @@ public class ScriptEngine {
clearMouseListeners(); clearMouseListeners();
clearMouseMotionListeners(); clearMouseMotionListeners();
clearMessageListeners(); clearMessageListeners();
if(script instanceof Paintable) { if (script instanceof Paintable) {
Context.getInstance().removePaintable((Paintable)script); Context.getInstance().removePaintable((Paintable) script);
} }
this.script = null; this.script = null;
} }
public void init() { public void init() {
if(script == null) { if (script == null) {
throw new RuntimeException("Script is null"); throw new RuntimeException("Script is null");
} }
if(script instanceof MouseListener) { if (script instanceof MouseListener) {
addMouseListener((MouseListener)script); addMouseListener((MouseListener) script);
} }
if(script instanceof MouseMotionListener) { if (script instanceof MouseMotionListener) {
addMouseMotionListener((MouseMotionListener)script); addMouseMotionListener((MouseMotionListener) script);
} }
if(script instanceof MessageListener) { if (script instanceof MessageListener) {
addMessageListener((MessageListener)script); addMessageListener((MessageListener) script);
} }
if(script instanceof Paintable) { if (script instanceof Paintable) {
Context.getInstance().addPaintable((Paintable)script); Context.getInstance().addPaintable((Paintable) script);
} }
if(script instanceof GameActionListener){ if (script instanceof GameActionListener) {
addActionListener((GameActionListener) script); addActionListener((GameActionListener) script);
} }
} }
public void dispatch(AWTEvent event) { public void dispatch(AWTEvent event) {
if(this.script == null) { if (this.script == null) {
return; return;
} }
if(!(event instanceof MouseEvent)) { if (!(event instanceof MouseEvent)) {
return; return;
} }
final MouseEvent e = (MouseEvent) event; final MouseEvent e = (MouseEvent) event;
for(final MouseListener m : mouseListeners) { for (final MouseListener m : mouseListeners) {
switch(e.getID()) { switch (e.getID()) {
case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_CLICKED:
m.mouseClicked(e); m.mouseClicked(e);
break; break;
@@ -155,8 +153,8 @@ public class ScriptEngine {
m.mouseReleased(e); m.mouseReleased(e);
} }
} }
for(final MouseMotionListener m : mouseMotionListeners) { for (final MouseMotionListener m : mouseMotionListeners) {
switch(e.getID()) { switch (e.getID()) {
case MouseEvent.MOUSE_MOVED: case MouseEvent.MOUSE_MOVED:
m.mouseMoved(e); m.mouseMoved(e);
break; break;
@@ -168,13 +166,13 @@ public class ScriptEngine {
} }
public void dispatch(MessageEvent event) { public void dispatch(MessageEvent event) {
for(final MessageListener messageListener : messageListeners) { for (final MessageListener messageListener : messageListeners) {
messageListener.messageReceived(event); messageListener.messageReceived(event);
} }
} }
public void dispatch(GameActionEvent event) { public void dispatch(GameActionEvent event) {
for(final GameActionListener a : actionListeners) { for (final GameActionListener a : actionListeners) {
a.onGameAction(event); a.onGameAction(event);
} }
} }
+5 -9
View File
@@ -1,16 +1,12 @@
package org.rev317.min.ui; package org.rev317.min.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import org.rev317.min.debug.*;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.core.paint.PaintDebugger; import org.parabot.core.paint.PaintDebugger;
import org.rev317.min.debug.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class BotMenu implements ActionListener { public class BotMenu implements ActionListener {