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;
/**
*
* @author Everel
*
*/
@ServerManifest(author = "Everel & Paradox", name = "Server name here", type = Type.INJECTION, version = 2.1)
public class Loader extends ServerProvider {
private Applet applet;
private HookFile hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getExtendenHookFile(), HookFile.TYPE_XML);
public static Client getClient() {
return (Client) Context.getInstance().getClient();
}
@Override
public Applet fetchApplet() {
try {
@@ -51,17 +53,13 @@ public class Loader extends ServerProvider {
ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo();
File target = new File(Directories.getCachePath(), serverProvider.getClientCRC32() + ".jar");
if(!target.exists()) {
if (!target.exists()) {
WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get());
}
return WebUtil.toURL(target);
}
public static Client getClient() {
return (Client) Context.getInstance().getClient();
}
@Override
public void addMenuItems(JMenuBar bar) {
new BotMenu(bar);
@@ -72,7 +70,7 @@ public class Loader extends ServerProvider {
AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/");
try {
super.injectHooks();
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
this.hookFile = new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML);
super.injectHooks();
@@ -1,9 +1,7 @@
package org.rev317.min.api.events;
/**
*
* @author Matt, Everel
*
*/
public final class GameActionEvent {
private int index, cmd1, cmd2, cmd3, cmd4, action;
@@ -1,19 +1,16 @@
package org.rev317.min.api.events;
/**
*
* @author Everel, Matt
*
*/
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_PLAYER = 2;
public static final int TYPE_TRADE = 4;
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) {
this.type = type;
@@ -3,9 +3,7 @@ package org.rev317.min.api.events.listeners;
import org.rev317.min.api.events.GameActionEvent;
/**
*
* @author Matt
*
*/
public interface GameActionListener {
@@ -3,20 +3,20 @@ package org.rev317.min.api.interfaces;
import org.rev317.min.api.wrappers.Tile;
/**
*
* @author Everel
*
*/
public interface Locatable {
/**
* Gets location of this locatable instance
*
* @return location
*/
public Tile getLocation();
/**
* Gets distance to this locatable instance
*
* @return distance from player to locatable
*/
public int distanceTo();
+20 -24
View File
@@ -1,8 +1,5 @@
package org.rev317.min.api.methods;
import java.util.ArrayList;
import java.util.HashMap;
import org.parabot.core.Context;
import org.parabot.environment.api.utils.Time;
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.SceneObject;
import java.util.ArrayList;
import java.util.HashMap;
/**
*
* @author Everel
* @author Matt123337
*
*/
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 ITEM_INTERFACE = 5382;
public static int BUTTON_DEPOSIT_ALL = 5386;
public static int INV_PARENT_ID = 5064;
public static int BANK_OPEN_INDEX = 1;
static {
HashMap<String, String> p = Context.getInstance().getServerProviderInfo().getProperties();
if(p.containsKey("bankInterface"))
if (p.containsKey("bankInterface"))
BANK_INTERFACE = Integer.parseInt(p.get("bankInterface"));
if(p.containsKey("bankItemInterface"))
if (p.containsKey("bankItemInterface"))
ITEM_INTERFACE = Integer.parseInt(p.get("bankItemInterface"));
if(p.containsKey("bankDepositAll"))
if (p.containsKey("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"));
if(p.containsKey("bankOpenIndex"))
if (p.containsKey("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
*
@@ -146,6 +142,7 @@ public class Bank {
* Gets bank item with given id
*
* @param id
*
* @return bank item
*/
public static Item getItem(int id) {
@@ -166,6 +163,7 @@ public class Bank {
* Counts the amount of items with given id in bank
*
* @param id
*
* @return count
*/
public static int getCount(int id) {
@@ -178,8 +176,7 @@ public class Bank {
/**
* Opens the bank
*
* @param bank
* booth
* @param bank booth
*/
public static void open(SceneObject bank) {
@@ -209,8 +206,7 @@ public class Bank {
/**
* Deposits all items except the given ids
*
* @param exceptions
* the item indexes that will be ignored.
* @param exceptions the item indexes that will be ignored.
*/
public static void depositAllExcept(int... exceptions) {
if (Bank.isOpen()) {
@@ -3,9 +3,7 @@ package org.rev317.min.api.methods;
import org.rev317.min.api.wrappers.Tile;
/**
*
* @author Everel
*
*/
public class Calculations {
@@ -13,6 +11,7 @@ public class Calculations {
* Calculates distance between local player and given tile
*
* @param tile
*
* @return distance between local player and given tile
*/
public static final double distanceTo(Tile tile) {
@@ -21,8 +20,10 @@ public class Calculations {
/**
* Calculates distance between two given tiles
*
* @param a
* @param b
*
* @return distance between a and 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 destY the destY (0 < destY < 104)
* @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) {
try {
+9 -3
View File
@@ -3,14 +3,13 @@ package org.rev317.min.api.methods;
import org.rev317.min.Loader;
/**
*
* @author Everel
*
*/
public class Game {
/**
* Gets BaseX
*
* @return baseX
*/
public static int getBaseX() {
@@ -19,6 +18,7 @@ public class Game {
/**
* Gets BaseY
*
* @return baseY
*/
public static int getBaseY() {
@@ -27,6 +27,7 @@ public class Game {
/**
* Gets open interface id
*
* @return interface id
*/
public static int getOpenInterfaceId() {
@@ -35,6 +36,7 @@ public class Game {
/**
* Get open back dialog id
*
* @return back dialog id
*/
public static int getOpenBackDialogId() {
@@ -43,6 +45,7 @@ public class Game {
/**
* Gets loop cycle
*
* @return loop cycle
*/
public static int getLoopCycle() {
@@ -51,6 +54,7 @@ public class Game {
/**
* Get collision flags
*
* @return collision flags
*/
public static int[][] getCollisionFlags() {
@@ -59,6 +63,7 @@ public class Game {
/**
* Gets current plane
*
* @return current plane
*/
public static int getPlane() {
@@ -67,13 +72,14 @@ public class Game {
/**
* Determines whether this client has action 4 hooked
*
* @return <code>true</code> if action 4 is hooked
*/
public static boolean hasAction4() {
try {
Loader.getClient().getMenuAction4();
return true;
} catch(AbstractMethodError e) {
} catch (AbstractMethodError e) {
return false;
}
}
+10 -13
View File
@@ -1,9 +1,5 @@
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.rev317.min.Loader;
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.api.wrappers.GroundItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
/**
*
* @author Everel
*
*/
public class GroundItems {
private static Client client;
private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() {
@Override
@@ -27,7 +23,6 @@ public class GroundItems {
}
};
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
@Override
@@ -36,6 +31,7 @@ public class GroundItems {
}
};
private static Client client;
/**
* Gets all loaded ground items
@@ -66,10 +62,9 @@ public class GroundItems {
/**
* Gets a ground item
*
* @param x
* - local region x
* @param y
* - local region y
* @param x - local region x
* @param y - local region y
*
* @return ground item array
*/
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
*
* @param filter
*
* @return GroundItems
*/
public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
@@ -134,6 +130,7 @@ public class GroundItems {
* Returns nearest ground items with given id
*
* @param ids
*
* @return GroundItems
*/
public static final GroundItem[] getNearest(final int... ids) {
+32 -19
View File
@@ -1,18 +1,16 @@
package org.rev317.min.api.methods;
import java.util.ArrayList;
import org.parabot.environment.api.utils.Filter;
import org.parabot.environment.api.utils.Time;
import org.rev317.min.Loader;
import org.rev317.min.accessors.Interface;
import org.rev317.min.api.wrappers.Item;
import java.util.ArrayList;
/**
*
* @author Everel
*
*/
public class Inventory {
public static final int INVENTORY_INDEX = 3214;
@@ -30,7 +28,7 @@ public class Inventory {
* Clears the inventory
*/
public static void clear() {
for(Item item : Inventory.getItems()) {
for (Item item : Inventory.getItems()) {
item.drop();
Time.sleep(60, 80);
}
@@ -38,6 +36,7 @@ public class Inventory {
/**
* Gets inventory interface
*
* @return interface of inventory
*/
public static Interface getInterface() {
@@ -46,6 +45,7 @@ public class Inventory {
/**
* Gets the amount of items in inventory, excludes the stack sizes
*
* @return amount of items
*/
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
*
* @param ids
*
* @return amount of items
*/
public static final int getCount(int... ids) {
@@ -63,19 +65,21 @@ public class Inventory {
/**
* Gets the amount of items in inventory
*
* @param includeStack - true for including stack sizes to the counting
*
* @return amount of items
*/
public static final int getCount(final boolean includeStack) {
final Interface inventory = getInterface();
if(inventory == null) {
if (inventory == null) {
return -1;
}
int count = 0;
final int[] items = inventory.getItems();
final int[] stackSizes = includeStack ? inventory.getStackSizes() : null;
for(int i = 0; i < items.length; i++) {
if(items[i] > 0) {
for (int i = 0; i < items.length; i++) {
if (items[i] > 0) {
count += includeStack ? stackSizes[i] : 1;
}
}
@@ -84,23 +88,25 @@ public class Inventory {
/**
* Gets the amount of items with given ids in inventory
*
* @param includeStack - true for including stack sizes to the counting
* @param ids
*
* @return amount of items
*/
public static final int getCount(final boolean includeStack, int... ids) {
final Interface inventory = getInterface();
if(inventory == null) {
if (inventory == null) {
return -1;
}
int count = 0;
final int[] items = inventory.getItems();
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];
if(itemId > 0) {
for(final int id : ids) {
if(id == itemId) {
if (itemId > 0) {
for (final int id : ids) {
if (id == itemId) {
count += includeStack ? stackSizes[i] : 1;
break;
}
@@ -112,6 +118,7 @@ public class Inventory {
/**
* Gets every item in inventory
*
* @return items
*/
public static final Item[] getItems() {
@@ -120,7 +127,9 @@ public class Inventory {
/**
* Gets all items with given ids
*
* @param ids
*
* @return items
*/
public static final Item[] getItems(final int... ids) {
@@ -128,8 +137,8 @@ public class Inventory {
@Override
public boolean accept(Item e) {
for(int id : ids) {
if(e.getId() == id) {
for (int id : ids) {
if (e.getId() == id) {
return true;
}
}
@@ -141,25 +150,27 @@ public class Inventory {
/**
* Gets all items accepted by filter
*
* @param filter
*
* @return items
*/
public static final Item[] getItems(final Filter<Item> filter) {
final Interface inventory = getInterface();
if(inventory == null) {
if (inventory == null) {
return null;
}
final int[] items = inventory.getItems();
final int[] stackSizes = inventory.getStackSizes();
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];
if(itemId < 1) {
if (itemId < 1) {
continue;
}
final int stackSize = stackSizes[i];
final Item item = new Item(itemId, stackSize, i);
if(filter.accept(item)) {
if (filter.accept(item)) {
invItems.add(item);
}
}
@@ -168,6 +179,7 @@ public class Inventory {
/**
* Determines if inventory is full
*
* @return <b>true</b> if inventory is full, otherwise <b>false</b>
*/
public static final boolean isFull() {
@@ -176,6 +188,7 @@ public class Inventory {
/**
* Determines if inventory is empty
*
* @return <b>true</b> if inventory is empty, otherwise <b>false</b>
*/
public static final boolean isEmpty() {
+15 -11
View File
@@ -1,7 +1,5 @@
package org.rev317.min.api.methods;
import java.util.HashMap;
import org.parabot.core.Context;
import org.rev317.min.Loader;
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.SceneObject;
import java.util.HashMap;
/**
*
* @author Everel
*
*/
public class Menu {
public static final int ACTION_CLICK_BUTTON = 646;
@@ -24,6 +22,7 @@ public class Menu {
/**
* Interacts with a sceneobject
*
* @param object
* @param actionIndex
*/
@@ -46,7 +45,7 @@ public class Menu {
actionId = 1062;
break;
}
if(Game.hasAction4()) {
if (Game.hasAction4()) {
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY(), object.getId(), 0);
} else {
sendAction(actionId, object.getHash(), object.getLocalRegionX(), object.getLocalRegionY());
@@ -55,6 +54,7 @@ public class Menu {
/**
* Interacts with a character
*
* @param character
* @param actionIndex
*/
@@ -81,11 +81,8 @@ public class Menu {
}
/**
* Interacts with an item when it has the following menu
* Transform-1
* Transform-5
* Transform-10
* etc..
* Interacts with an item when it has the following menu Transform-1 Transform-5 Transform-10 etc..
*
* @param item
* @param actionIndex
* @param interfaceParentId
@@ -116,6 +113,7 @@ public class Menu {
/**
* Takes grounditem from the ground
*
* @param item
*/
public static void take(GroundItem item) {
@@ -124,6 +122,7 @@ public class Menu {
/**
* Interacts with a ground item
*
* @param item
* @param action
*/
@@ -151,6 +150,7 @@ public class Menu {
/**
* Drops an item
*
* @param item
*/
public static void drop(Item item) {
@@ -160,6 +160,7 @@ public class Menu {
/**
* Clicks a button
*
* @param id
*/
public static void clickButton(int id) {
@@ -168,6 +169,7 @@ public class Menu {
/**
* Sends an action to the client
*
* @param action
* @param cmd1
* @param cmd2
@@ -179,6 +181,7 @@ public class Menu {
/**
* Sends an action to the client
*
* @param action
* @param cmd1
* @param cmd2
@@ -191,6 +194,7 @@ public class Menu {
/**
* Sends an action to the client
*
* @param action
* @param cmd1
* @param cmd2
@@ -208,7 +212,7 @@ public class Menu {
client.getMenuAction1()[index] = cmd1;
client.getMenuAction2()[index] = cmd2;
client.getMenuAction3()[index] = cmd3;
if(Game.hasAction4()) {
if (Game.hasAction4()) {
client.getMenuAction4()[index] = cmd4;
}
client.getMenuActionId()[index] = action;
+14 -9
View File
@@ -1,18 +1,16 @@
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.rev317.min.Loader;
import org.rev317.min.accessors.Client;
import org.rev317.min.api.wrappers.Npc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
/**
*
* @author Everel
*
*/
public class Npcs {
@@ -38,6 +36,7 @@ public class Npcs {
* Gets all Npcs except local Npc
*
* @param filter
*
* @return all Npcs
*/
public static final Npc[] getNpcs(final Filter<Npc> filter) {
@@ -45,7 +44,7 @@ public class Npcs {
ArrayList<Npc> npcList = new ArrayList<Npc>();
final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs();
for (int i = 0; i < accNpcs.length; i++) {
if(accNpcs[i] == null) {
if (accNpcs[i] == null) {
continue;
}
final Npc npc = new Npc(accNpcs[i], i);
@@ -67,12 +66,14 @@ public class Npcs {
/**
* Gets the closest npc which matches the given filter
*
* @param filter
*
* @return closest npc
*/
public static final Npc getClosest(final Filter<Npc> filter) {
Npc[] npcs = getNearest(filter);
if(npcs == null || npcs.length == 0) {
if (npcs == null || npcs.length == 0) {
return null;
}
return npcs[0];
@@ -80,12 +81,14 @@ public class Npcs {
/**
* Gets the closest npc which matches the given ids
*
* @param ids
*
* @return closest npc
*/
public static final Npc getClosest(int... ids) {
Npc[] npcs = getNearest(ids);
if(npcs == null || npcs.length == 0) {
if (npcs == null || npcs.length == 0) {
return null;
}
return npcs[0];
@@ -95,6 +98,7 @@ public class Npcs {
* Returns array with the first index to be the nearest Npc
*
* @param filter
*
* @return nearest Npcs
*/
public static final Npc[] getNearest(final Filter<Npc> filter) {
@@ -107,6 +111,7 @@ public class Npcs {
* Gets nearest npcs which hold given id(s)
*
* @param ids
*
* @return array of npcs with the first index to be the nearest
*/
public static final Npc[] getNearest(final int... ids) {
+14 -9
View File
@@ -1,18 +1,16 @@
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.rev317.min.Loader;
import org.rev317.min.accessors.Client;
import org.rev317.min.api.wrappers.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
/**
*
* @author Everel
*
*/
public class Players {
@@ -36,19 +34,21 @@ public class Players {
/**
* Gets all players except local player
*
* @param filter
*
* @return all players
*/
public static final Player[] getPlayers(final Filter<Player> filter) {
final Client client = Loader.getClient();
ArrayList<Player> playerList = new ArrayList<Player>();
final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers();
for(int i = 0; i < accPlayers.length; i++) {
if(accPlayers[i] == null) {
for (int i = 0; i < accPlayers.length; i++) {
if (accPlayers[i] == null) {
continue;
}
final Player player = new Player(accPlayers[i], i);
if(filter.accept(player)) {
if (filter.accept(player)) {
playerList.add(player);
}
}
@@ -57,6 +57,7 @@ public class Players {
/**
* Gets all players except local player
*
* @return all players
*/
public static final Player[] getPlayers() {
@@ -65,7 +66,9 @@ public class Players {
/**
* Returns array with the first index to be the nearest player
*
* @param filter
*
* @return nearest players
*/
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
*
* @return nearest players
*/
public static final Player[] getNearest() {
@@ -84,6 +88,7 @@ public class Players {
/**
* Gets local player
*
* @return local player
*/
public static Player getMyPlayer() {
@@ -1,27 +1,25 @@
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.rev317.min.Loader;
import org.rev317.min.accessors.Ground;
import org.rev317.min.accessors.SceneObjectTile;
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
*
*/
public class SceneObjects {
private static final Comparator<SceneObject> NEAREST_SORTER = new Comparator<SceneObject>() {
@Override
public int compare(SceneObject n1,SceneObject n2) {
public int compare(SceneObject n1, SceneObject n2) {
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
*/
public static final SceneObject[] getSceneObjects(Filter<SceneObject> filter) {
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
for(int x = 0; x < 104; x++) {
for(int y = 0; y < 104; y++) {
for (int x = 0; x < 104; x++) {
for (int y = 0; y < 104; y++) {
final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true);
if(sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) {
if (sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) {
sceneObjects.add(sceneObjectAtTile);
}
@@ -56,6 +56,7 @@ public class SceneObjects {
/**
* Gets the most important scene objects in game which can be interacted with
*
* @return scene objects
*/
public static final SceneObject[] getSceneObjects() {
@@ -64,7 +65,9 @@ public class SceneObjects {
/**
* Returns array of sceneobjects with the first index to be the nearest
*
* @param filter
*
* @return sceneobjects
*/
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
*
* @return sceneobjects
*/
public static final SceneObject[] getNearest() {
@@ -83,7 +87,9 @@ public class SceneObjects {
/**
* Returns nearest objects with given id
*
* @param ids
*
* @return sceneobjects
*/
public static final SceneObject[] getNearest(final int... ids) {
@@ -91,8 +97,8 @@ public class SceneObjects {
@Override
public boolean accept(SceneObject object) {
for(final int id : ids) {
if(id == object.getId()) {
for (final int id : ids) {
if (id == object.getId()) {
return true;
}
}
@@ -107,8 +113,8 @@ public class SceneObjects {
@Override
public boolean accept(SceneObject object) {
for(final int id : ids) {
if(id == object.getId()) {
for (final int id : ids) {
if (id == object.getId()) {
return true;
}
}
@@ -116,7 +122,7 @@ public class SceneObjects {
}
});
if(nearestObjects == null || nearestObjects.length == 0) {
if (nearestObjects == null || nearestObjects.length == 0) {
return null;
}
return nearestObjects[0];
@@ -124,20 +130,20 @@ public class SceneObjects {
private static SceneObject getSceneObjectAtTile(int x, int y, boolean useCached) {
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
if(sceneTile == null) {
if (sceneTile == null) {
return null;
}
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
if(interactiveObjects != null) {
for(final SceneObjectTile interactiveObject : interactiveObjects) {
if (interactiveObjects != null) {
for (final SceneObjectTile interactiveObject : interactiveObjects) {
// get top
if(interactiveObject != null) {
if (interactiveObject != null) {
return new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE);
}
}
}
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
if(sceneObjectTile != null) {
if (sceneObjectTile != null) {
return new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL);
}
return null;
@@ -145,14 +151,15 @@ public class SceneObjects {
/**
* Gets every loaded scene object in game
*
* @return every loaded scene object in game
*/
public static final SceneObject[] getAllSceneObjects() {
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
for(int x = 0; x < 104; x++) {
for(int y = 0; y < 104; y++) {
for (int x = 0; x < 104; x++) {
for (int y = 0; y < 104; y++) {
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true);
if(sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
if (sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
sceneObjects.addAll(sceneObjectsAtTile);
}
}
@@ -162,19 +169,21 @@ public class SceneObjects {
/**
* Gets all sceneobjects at a tile
*
* @param x
* @param y
* @param useCached
*
* @return array of sceneobjects, or null if there aren't any
*/
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) {
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
ArrayList<SceneObject> sceneObjects = null;
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
if(interactiveObjects != null) {
for(final SceneObjectTile interactiveObject : interactiveObjects) {
if(interactiveObject != null) {
if(sceneObjects == null) {
if (interactiveObjects != null) {
for (final SceneObjectTile interactiveObject : interactiveObjects) {
if (interactiveObject != null) {
if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>();
}
sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE));
@@ -182,32 +191,32 @@ public class SceneObjects {
}
}
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
if(sceneObjectTile != null) {
if(sceneObjects == null) {
if (sceneObjectTile != null) {
if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>();
}
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL));
}
sceneObjectTile = sceneTile.getWallDecoration();
if(sceneObjectTile != null) {
if(sceneObjects == null) {
if (sceneObjectTile != null) {
if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>();
}
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION));
}
sceneObjectTile = sceneTile.getGroundDecoration();
if(sceneObjectTile != null) {
if(sceneObjects == null) {
if (sceneObjectTile != null) {
if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>();
}
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION));
}
sceneObjectTile = sceneTile.getGroundItem();
if(sceneObjectTile != null) {
if(sceneObjects == null) {
if (sceneObjectTile != null) {
if (sceneObjects == null) {
sceneObjects = new ArrayList<SceneObject>();
}
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;
/**
*
* @author Dane
*
*/
public enum Skill {
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;
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,
private static final int[] EXPERIENCE = {0, 0, 83, 174, 276, 388, 512,
650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,
3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,
12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
@@ -30,11 +24,106 @@ public enum Skill {
13034431, 14391160, 15889109, 17542976, 19368992, 21385073,
23611006, 26068632, 28782069, 31777943, 35085654, 38737661,
42769801, 47221641, 52136869, 57563718, 63555443, 70170840,
77474828, 85539082, 94442737, 104273167 };
77474828, 85539082, 94442737, 104273167};
/**
* @Deprecated use Skill.ordinal() instead
* Returns the skill's index.
* 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]));
}
/**
* @Deprecated use Skill.ordinal() instead Returns the skill's index.
*/
public int getIndex() {
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.)
* Done by Bears
* 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.) Done by Bears
*/
public final int getLevel() {
return Skill.getCurrentLevel(this.getIndex());
@@ -92,101 +181,4 @@ public enum Skill {
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / "
+ 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;
/**
*
* @author Everel
*
*/
public class Walking {
/**
* Walks from tile to tile
*
* @param from
* @param to
*/
@@ -21,12 +20,12 @@ public class Walking {
}
/**
*
* @param tilePath
*
* @return <b>true</b> if destination reached, otherwise <b>false</b>
*/
public static boolean walkDown(TilePath tilePath) {
if(tilePath.hasReached()) {
if (tilePath.hasReached()) {
return true;
}
tilePath.traverse();
@@ -35,7 +34,9 @@ public class Walking {
/**
* Gets nearest reachable tile on minimap to given tile
*
* @param tile
*
* @return nearest reachable tile on minimap
*/
public static Tile getNearestTileTo(Tile tile) {
@@ -9,9 +9,7 @@ import org.rev317.min.api.methods.Menu;
import org.rev317.min.api.methods.Players;
/**
*
* @author Everel
*
*/
public class Character implements Locatable {
@@ -151,12 +149,13 @@ public class Character implements Locatable {
*
* @return <b>true</b> if entity is logged in
*/
public boolean isLoggedIn(){
public boolean isLoggedIn() {
return accessor.isLoggedIn();
}
/**
* Gets the accessor class
*
* @return RefClass of accessor
*/
public RefClass getRefClass() {
@@ -7,9 +7,7 @@ import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Menu;
/**
*
* @author Everel
*
*/
public class GroundItem implements Locatable {
private org.rev317.min.accessors.Item accessor;
@@ -24,6 +22,7 @@ public class GroundItem implements Locatable {
/**
* Gets location of this ground item
*
* @return location
*/
public Tile getLocation() {
@@ -32,6 +31,7 @@ public class GroundItem implements Locatable {
/**
* Gets region X
*
* @return x
*/
public int getX() {
@@ -40,6 +40,7 @@ public class GroundItem implements Locatable {
/**
* Gets region Y
*
* @return y
*/
public int getY() {
@@ -48,6 +49,7 @@ public class GroundItem implements Locatable {
/**
* Interacts with this ground item
*
* @param actionIndex
*/
public void interact(int actionIndex) {
@@ -63,6 +65,7 @@ public class GroundItem implements Locatable {
/**
* Gets distance between you and this ground item
*
* @return distance
*/
public int distanceTo() {
@@ -71,6 +74,7 @@ public class GroundItem implements Locatable {
/**
* Get's ID of this item
*
* @return ID
*/
public int getId() {
@@ -79,6 +83,7 @@ public class GroundItem implements Locatable {
/**
* Gets the accessor class
*
* @return RefClass of accessor
*/
public RefClass getRefClass() {
+4 -2
View File
@@ -3,9 +3,7 @@ package org.rev317.min.api.wrappers;
import org.rev317.min.api.methods.Menu;
/**
*
* @author Everel
*
*/
public class Item {
private int id, stackSize;
@@ -19,6 +17,7 @@ public class Item {
/**
* Get id of this item
*
* @return id
*/
public int getId() {
@@ -27,6 +26,7 @@ public class Item {
/**
* Gets quantity of this item
*
* @return stack size
*/
public int getStackSize() {
@@ -35,6 +35,7 @@ public class Item {
/**
* Item slot
*
* @return slot
*/
public int getSlot() {
@@ -50,6 +51,7 @@ public class Item {
/**
* Interacts with this item
*
* @param 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;
/**
*
* @author Everel
*
*/
public final class Npc extends Character {
private org.rev317.min.accessors.Npc accessor;
@@ -18,6 +16,7 @@ public final class Npc extends Character {
/**
* Gets the definition of this npc
*
* @return npc definitions
*/
public final NpcDef getDef() {
@@ -26,6 +25,7 @@ public final class Npc extends Character {
/**
* Gets the accessor class
*
* @return RefClass of accessor
*/
public RefClass getRefClass() {
+2 -2
View File
@@ -3,9 +3,7 @@ package org.rev317.min.api.wrappers;
import org.parabot.core.reflect.RefClass;
/**
*
* @author Everel
*
*/
public class NpcDef {
private org.rev317.min.accessors.NpcDef accessor;
@@ -16,6 +14,7 @@ public class NpcDef {
/**
* Gets id of this item
*
* @return id of this item
*/
public int getId() {
@@ -24,6 +23,7 @@ public class NpcDef {
/**
* Gets the accessor class
*
* @return RefClass of accessor
*/
public RefClass getRefClass() {
@@ -1,9 +1,7 @@
package org.rev317.min.api.wrappers;
/**
*
* @author Everel
*
*/
public class Player extends Character {
@@ -8,9 +8,7 @@ import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Menu;
/**
*
* @author Everel
*
*/
public class SceneObject implements Locatable {
public static final int TYPE_WALL = 0; // object1
@@ -38,6 +36,7 @@ public class SceneObject implements Locatable {
/**
* Gets location of this tile
*
* @return location
*/
public final Tile getLocation() {
@@ -46,6 +45,7 @@ public class SceneObject implements Locatable {
/**
* Gets region X
*
* @return region X
*/
public final int getLocalRegionX() {
@@ -54,6 +54,7 @@ public class SceneObject implements Locatable {
/**
* Gets region Y
*
* @return region Y
*/
public final int getLocalRegionY() {
@@ -80,6 +81,7 @@ public class SceneObject implements Locatable {
/**
* Calculates distance to this object
*
* @return distance
*/
public final int distanceTo() {
@@ -88,6 +90,7 @@ public class SceneObject implements Locatable {
/**
* Interacts with this object
*
* @param actionIndex
*/
public void interact(int actionIndex) {
@@ -96,6 +99,7 @@ public class SceneObject implements Locatable {
/**
* Gets the accessor class
*
* @return RefClass of accessor
*/
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;
/**
*
* Class which holds a world location
*
* @author Everel
*
*/
public final class Tile implements TileFlags, Locatable {
private int x;
@@ -50,6 +48,7 @@ public final class Tile implements TileFlags, Locatable {
/**
* Gets region x
*
* @return region x
*/
public final int getRegionX() {
@@ -58,6 +57,7 @@ public final class Tile implements TileFlags, Locatable {
/**
* Gets region y
*
* @return region y
*/
public final int getRegionY() {
@@ -128,6 +128,7 @@ public final class Tile implements TileFlags, Locatable {
/**
* Determines if this tile is walkable
*
* @return <code>true</code> if this tile is walkable, otherwise <code>false</code>
*/
public boolean isWalkable() {
@@ -136,7 +137,9 @@ public final class Tile implements TileFlags, Locatable {
/**
* Determines if this tile is reachable
*
* @param isObject whether this tile is an object tile
*
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
*/
public boolean isReachable(boolean isObject) {
@@ -146,6 +149,7 @@ public final class Tile implements TileFlags, Locatable {
/**
* Determines if this tile is reachable
*
* @return <code>true</code> if this tile is reachable, otherwise <code>false</code>
*/
public boolean isReachable() {
@@ -154,6 +158,7 @@ public final class Tile implements TileFlags, Locatable {
/**
* Determines if this tile is an object tile
*
* @return <code>true</code> if this tile is an object tile, otherwise <code>false</code>
*/
public boolean isObjectTile() {
@@ -1,9 +1,7 @@
package org.rev317.min.api.wrappers;
/**
*
* @author Everel
*
*/
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.accessors.Client;
import org.rev317.min.debug.DActions;
import org.rev317.min.api.events.GameActionEvent;
import org.rev317.min.api.methods.Game;
import org.rev317.min.debug.DActions;
import org.rev317.min.script.ScriptEngine;
/**
*
* @author Everel
* @author Matt123337
*
*/
public class MenuAction {
@@ -23,7 +21,7 @@ public class MenuAction {
int action4 = 0;
int actionId = client.getMenuActionId()[index];
if (DActions.debugActions()) {
if(Game.hasAction4()) {
if (Game.hasAction4()) {
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));
} else {
@@ -1,7 +1,6 @@
package org.rev317.min.callback;
import org.rev317.min.api.events.MessageEvent;
import org.rev317.min.script.ScriptEngine;
+6 -6
View File
@@ -1,12 +1,16 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger;
import java.awt.*;
public class DActions extends AbstractDebugger {
private static boolean enabled;
public static boolean debugActions() {
return enabled;
}
@Override
public void paint(Graphics g) {
}
@@ -21,8 +25,4 @@ public class DActions extends AbstractDebugger {
enabled = !enabled;
}
public static boolean debugActions() {
return enabled;
}
}
+2 -2
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Players;
import java.awt.*;
public class DAnimation extends AbstractDebugger {
private boolean enabled;
+2 -2
View File
@@ -1,10 +1,10 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Bank;
import java.awt.*;
public class DBank extends AbstractDebugger {
@Override
@@ -1,7 +1,5 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger;
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.wrappers.Tile;
import java.awt.*;
public class DCollisionFlags extends AbstractDebugger {
private boolean enabled;
+4 -4
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.wrappers.GroundItem;
import java.awt.*;
public class DGroundItems extends AbstractDebugger {
@Override
@@ -21,10 +21,10 @@ public class DGroundItems extends AbstractDebugger {
@Override
public void toggle() {
GroundItem[] items = GroundItems.getNearest();
if(items == null || items.length == 0) {
if (items == null || items.length == 0) {
return;
}
for(GroundItem item : items) {
for (GroundItem item : items) {
System.out.println("ID: " + item.getId() + " Location: " + item.getLocation());
}
}
+2 -2
View File
@@ -1,12 +1,12 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger;
import org.rev317.min.api.methods.Game;
import java.awt.*;
public class DInterfaces extends AbstractDebugger {
private boolean enabled;
+3 -3
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.wrappers.Item;
import java.awt.*;
public class DInventory extends AbstractDebugger {
@Override
@@ -20,7 +20,7 @@ public class DInventory extends AbstractDebugger {
@Override
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());
}
}
+2 -2
View File
@@ -1,13 +1,13 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger;
import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Players;
import java.awt.*;
public class DMap extends AbstractDebugger {
private boolean enabled;
+2 -2
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger;
import org.parabot.environment.input.Mouse;
import java.awt.*;
public class DMouse extends AbstractDebugger {
private boolean enabled;
+3 -3
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.Npcs;
import org.rev317.min.api.wrappers.Npc;
import java.awt.*;
public class DNpcs extends AbstractDebugger {
@Override
@@ -20,7 +20,7 @@ public class DNpcs extends AbstractDebugger {
@Override
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());
}
+5 -5
View File
@@ -1,11 +1,11 @@
package org.rev317.min.debug;
import java.awt.Graphics;
import org.parabot.core.paint.AbstractDebugger;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
import java.awt.*;
public class DSceneObjects extends AbstractDebugger {
@Override
@@ -20,15 +20,15 @@ public class DSceneObjects extends AbstractDebugger {
@Override
public void toggle() {
SceneObject[] objects = SceneObjects.getNearest();
if(objects == null || objects.length == 0)
if (objects == null || objects.length == 0)
return;
for (int i = objects.length - 1; i >= 0; i--) {
System.out.println(
" ID: " + objects[i].getId() +
" UID: " + objects[i].getHash() +
" Location: "+ objects[i].getLocation() +
" Distance: "+ objects[i].distanceTo());
" Location: " + objects[i].getLocation() +
" Distance: " + objects[i].distanceTo());
}
}
+33 -35
View File
@@ -1,25 +1,23 @@
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.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
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 matt123337
*
*/
public class ScriptEngine {
private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>();
@@ -40,21 +38,21 @@ public class ScriptEngine {
public static ScriptEngine getInstance() {
final ScriptEngine engine = instances.get(Context.getInstance());
if(engine != null) {
if (engine != null) {
return engine;
}
return new ScriptEngine();
}
public void addActionListener(GameActionListener a){
public void addActionListener(GameActionListener a) {
actionListeners.add(a);
}
public void removeActionListener(GameActionListener a){
public void removeActionListener(GameActionListener a) {
actionListeners.remove(a);
}
public void clearActionListeners(){
public void clearActionListeners() {
actionListeners.clear();
}
@@ -102,43 +100,43 @@ public class ScriptEngine {
clearMouseListeners();
clearMouseMotionListeners();
clearMessageListeners();
if(script instanceof Paintable) {
Context.getInstance().removePaintable((Paintable)script);
if (script instanceof Paintable) {
Context.getInstance().removePaintable((Paintable) script);
}
this.script = null;
}
public void init() {
if(script == null) {
if (script == null) {
throw new RuntimeException("Script is null");
}
if(script instanceof MouseListener) {
addMouseListener((MouseListener)script);
if (script instanceof MouseListener) {
addMouseListener((MouseListener) script);
}
if(script instanceof MouseMotionListener) {
addMouseMotionListener((MouseMotionListener)script);
if (script instanceof MouseMotionListener) {
addMouseMotionListener((MouseMotionListener) script);
}
if(script instanceof MessageListener) {
addMessageListener((MessageListener)script);
if (script instanceof MessageListener) {
addMessageListener((MessageListener) script);
}
if(script instanceof Paintable) {
Context.getInstance().addPaintable((Paintable)script);
if (script instanceof Paintable) {
Context.getInstance().addPaintable((Paintable) script);
}
if(script instanceof GameActionListener){
if (script instanceof GameActionListener) {
addActionListener((GameActionListener) script);
}
}
public void dispatch(AWTEvent event) {
if(this.script == null) {
if (this.script == null) {
return;
}
if(!(event instanceof MouseEvent)) {
if (!(event instanceof MouseEvent)) {
return;
}
final MouseEvent e = (MouseEvent) event;
for(final MouseListener m : mouseListeners) {
switch(e.getID()) {
for (final MouseListener m : mouseListeners) {
switch (e.getID()) {
case MouseEvent.MOUSE_CLICKED:
m.mouseClicked(e);
break;
@@ -155,8 +153,8 @@ public class ScriptEngine {
m.mouseReleased(e);
}
}
for(final MouseMotionListener m : mouseMotionListeners) {
switch(e.getID()) {
for (final MouseMotionListener m : mouseMotionListeners) {
switch (e.getID()) {
case MouseEvent.MOUSE_MOVED:
m.mouseMoved(e);
break;
@@ -168,13 +166,13 @@ public class ScriptEngine {
}
public void dispatch(MessageEvent event) {
for(final MessageListener messageListener : messageListeners) {
for (final MessageListener messageListener : messageListeners) {
messageListener.messageReceived(event);
}
}
public void dispatch(GameActionEvent event) {
for(final GameActionListener a : actionListeners) {
for (final GameActionListener a : actionListeners) {
a.onGameAction(event);
}
}
+5 -9
View File
@@ -1,16 +1,12 @@
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.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 {