Merge pull request #78 from Parabot/task/settings

[TASK] Moved settings to the api
This commit is contained in:
Jeroen Ketelaar
2017-03-20 09:10:34 +01:00
committed by GitHub
37 changed files with 472 additions and 246 deletions
+3 -3
View File
@@ -36,10 +36,10 @@ public class Loader extends ServerProvider {
@Override @Override
public Applet fetchApplet() { public Applet fetchApplet() {
try { try {
final Context context = Context.getInstance(); final Context context = Context.getInstance();
final ASMClassLoader classLoader = context.getASMClassLoader(); final ASMClassLoader classLoader = context.getASMClassLoader();
final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass()); final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
Object instance = clientClass.newInstance(); Object instance = clientClass.newInstance();
return (Applet) instance; return (Applet) instance;
} catch (Exception e) { } catch (Exception e) {
@@ -1,6 +1,5 @@
package org.rev317.min.accessors; package org.rev317.min.accessors;
public interface CollisionMap { public interface CollisionMap {
int[][] getFlags(); int[][] getFlags();
@@ -5,10 +5,10 @@ package org.rev317.min.api.events;
*/ */
public final class MessageEvent { public final class MessageEvent {
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 int type;
private String name; private String name;
private String message; private String message;
@@ -2,7 +2,6 @@ package org.rev317.min.api.events.listeners;
import org.rev317.min.api.events.MessageEvent; import org.rev317.min.api.events.MessageEvent;
public interface MessageListener { public interface MessageListener {
void messageReceived(MessageEvent event); void messageReceived(MessageEvent event);
@@ -3,15 +3,15 @@ package org.rev317.min.api.interfaces;
public interface TileFlags { public interface TileFlags {
int WALL_NORTHWEST = 0x1; int WALL_NORTHWEST = 0x1;
int WALL_NORTH = 0x2; int WALL_NORTH = 0x2;
int WALL_NORTHEAST = 0x4; int WALL_NORTHEAST = 0x4;
int WALL_EAST = 0x8; int WALL_EAST = 0x8;
int WALL_SOUTHEAST = 0x10; int WALL_SOUTHEAST = 0x10;
int WALL_SOUTH = 0x20; int WALL_SOUTH = 0x20;
int WALL_SOUTHWEST = 0x40; int WALL_SOUTHWEST = 0x40;
int WALL_WEST = 0x80; int WALL_WEST = 0x80;
int OBJECT_TILE = 0x100; int OBJECT_TILE = 0x100;
int UNKNOWN = 0x80000; int UNKNOWN = 0x80000;
int BLOCKED_TILE = 0x200000; int BLOCKED_TILE = 0x200000;
int UNLOADED_TILE = 0x1000000; int UNLOADED_TILE = 0x1000000;
} }
@@ -5,6 +5,7 @@ import org.parabot.environment.api.utils.Time;
import org.parabot.environment.input.Keyboard; import org.parabot.environment.input.Keyboard;
import org.parabot.environment.scripts.framework.SleepCondition; import org.parabot.environment.scripts.framework.SleepCondition;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.api.methods.utils.Settings;
import org.rev317.min.api.wrappers.Item; 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;
@@ -16,15 +17,15 @@ import java.util.HashMap;
* @author Everel, Matt123337, JKetelaar * @author Everel, Matt123337, JKetelaar
*/ */
public class Bank { public class Bank {
public static final int[] BANKERS = new int[]{44, 45, 494, 495, 498, 499, public static final int[] BANKERS = new int[]{ 44, 45, 494, 495, 498, 499,
909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457, 909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457,
4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948, 4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948,
9710, 14367}; 9710, 14367 };
public static final int[] BANKS = new int[]{782, 2213, 2995, 5276, 6084, public static final int[] BANKS = new int[]{ 782, 2213, 2995, 5276, 6084,
10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808, 10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808,
26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693, 26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693,
4483, 12308, 20607, 21301, 27663, 42192}; 4483, 12308, 20607, 21301, 27663, 42192 };
private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings(); private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings();
/** /**
* Gets nearest banker * Gets nearest banker
@@ -67,8 +68,8 @@ public class Bank {
return false; return false;
} }
SceneObject bank = getBank(); SceneObject bank = getBank();
Npc banker = getBanker(); Npc banker = getBanker();
if (bank != null) { if (bank != null) {
bank.interact(SceneObjects.Option.USE); bank.interact(SceneObjects.Option.USE);
@@ -85,7 +86,7 @@ public class Bank {
* Deposits all items * Deposits all items
*/ */
public static void depositAll() { public static void depositAll() {
Menu.clickButton(settings.get("button_deposit_all")); Menu.clickButton(Settings.getActionByName("button_deposit_all"));
} }
/** /**
@@ -105,15 +106,15 @@ public class Bank {
} }
if (amount == 1) { if (amount == 1) {
b.transform(Items.Option.TRANSFORM_ONE, settings.get("item_interface_id")); b.transform(Items.Option.TRANSFORM_ONE, Settings.getActionByName("item_interface_id"));
} else if (amount == 5) { } else if (amount == 5) {
b.transform(Items.Option.TRANSFORM_FIVE, settings.get("item_interface_id")); b.transform(Items.Option.TRANSFORM_FIVE, Settings.getActionByName("item_interface_id"));
} else if (amount == 10) { } else if (amount == 10) {
b.transform(Items.Option.TRANSFORM_TEN, settings.get("item_interface_id")); b.transform(Items.Option.TRANSFORM_TEN, Settings.getActionByName("item_interface_id"));
} else if (amount == 0) { } else if (amount == 0) {
b.transform(Items.Option.TRANSFORM_ALL, settings.get("item_interface_id")); b.transform(Items.Option.TRANSFORM_ALL, Settings.getActionByName("item_interface_id"));
} else { } else {
b.transform(Items.Option.TRANSFORM_X, settings.get("item_interface_id")); b.transform(Items.Option.TRANSFORM_X, Settings.getActionByName("item_interface_id"));
Time.sleep(1500 + sleep); Time.sleep(1500 + sleep);
Keyboard.getInstance().sendKeys("" + amount); Keyboard.getInstance().sendKeys("" + amount);
} }
@@ -123,6 +124,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) {
@@ -146,6 +148,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) {
@@ -180,7 +183,6 @@ public class Bank {
bank.interact(SceneObjects.Option.USE); bank.interact(SceneObjects.Option.USE);
} }
/** /**
* Closes the bank interface * Closes the bank interface
*/ */
@@ -189,7 +191,7 @@ public class Bank {
return; return;
} }
Menu.sendAction(200, -1, -1, settings.get("button_close_bank")); Menu.sendAction(200, -1, -1, Settings.getActionByName("button_close_bank"));
} }
/** /**
@@ -207,7 +209,7 @@ public class Bank {
for (Item i : Inventory.getItems()) { for (Item i : Inventory.getItems()) {
if (!ignored.contains(i.getId())) { if (!ignored.contains(i.getId())) {
while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) { while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) {
i.transform(Items.Option.TRANSFORM_ALL, settings.get("inventory_parent_id")); i.transform(Items.Option.TRANSFORM_ALL, Settings.getActionByName("inventory_parent_id"));
ignored.add(i.getId()); ignored.add(i.getId());
final int previous = Inventory.getCount(true); final int previous = Inventory.getCount(true);
Time.sleep(new SleepCondition() { Time.sleep(new SleepCondition() {
@@ -232,7 +234,7 @@ public class Bank {
return null; return null;
} }
return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getItems(); return Loader.getClient().getInterfaceCache()[Settings.getActionByName("item_interface_id")].getItems();
} }
/** /**
@@ -245,7 +247,7 @@ public class Bank {
return null; return null;
} }
return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getStackSizes(); return Loader.getClient().getInterfaceCache()[Settings.getActionByName("item_interface_id")].getStackSizes();
} }
/** /**
@@ -258,9 +260,9 @@ public class Bank {
return null; return null;
} }
ArrayList<Item> items = new ArrayList<Item>(); ArrayList<Item> items = new ArrayList<>();
int[] ids = getBankItemIDs(); int[] ids = getBankItemIDs();
int[] stacks = getBankStacks(); int[] stacks = getBankStacks();
if (ids != null && stacks != null) { if (ids != null && stacks != null) {
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {
if (ids[i] > 0) { if (ids[i] > 0) {
@@ -292,6 +294,6 @@ public class Bank {
* @return <b>true</b> if bank is open * @return <b>true</b> if bank is open
*/ */
public static boolean isOpen() { public static boolean isOpen() {
return Loader.getClient().getOpenInterfaceId() == settings.get("bank_interface_id"); return Loader.getClient().getOpenInterfaceId() == Settings.getActionByName("bank_interface_id");
} }
} }
@@ -12,6 +12,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) {
@@ -23,6 +24,7 @@ public class Calculations {
* *
* @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) {
@@ -32,22 +34,22 @@ public class Calculations {
return Math.sqrt((x * x) + (y * y)); return Math.sqrt((x * x) + (y * y));
} }
/** /**
* @param startX the startX (0 < startX < 104) * @param startX the startX (0 < startX < 104)
* @param startY the startY (0 < startY < 104) * @param startY the startY (0 < startY < 104)
* @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 * @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was
* found. * 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 {
final int[][] prev = new int[104][104]; final int[][] prev = new int[104][104];
final int[][] dist = new int[104][104]; final int[][] dist = new int[104][104];
final int[] path_x = new int[4000]; final int[] path_x = new int[4000];
final int[] path_y = new int[4000]; final int[] path_y = new int[4000];
for (int xx = 0; xx < 104; xx++) { for (int xx = 0; xx < 104; xx++) {
for (int yy = 0; yy < 104; yy++) { for (int yy = 0; yy < 104; yy++) {
prev[xx][yy] = 0; prev[xx][yy] = 0;
@@ -64,7 +66,7 @@ public class Calculations {
path_y[path_ptr++] = startY; path_y[path_ptr++] = startY;
final int blocks[][] = Game.getCollisionFlags(); final int blocks[][] = Game.getCollisionFlags();
final int pathLength = path_x.length; final int pathLength = path_x.length;
boolean foundPath = false; boolean foundPath = false;
while (step_ptr != path_ptr) { while (step_ptr != path_ptr) {
curr_x = path_x[step_ptr]; curr_x = path_x[step_ptr];
curr_y = path_y[step_ptr]; curr_y = path_y[step_ptr];
@@ -158,6 +160,7 @@ public class Calculations {
* *
* @param from Start Tile. * @param from Start Tile.
* @param to Destination Tile. * @param to Destination Tile.
*
* @return True if Path is found. * @return True if Path is found.
*/ */
public static boolean foundPath(Tile from, Tile to) { public static boolean foundPath(Tile from, Tile to) {
@@ -170,6 +173,7 @@ public class Calculations {
* @param from Start Tile. * @param from Start Tile.
* @param to Destination Tile. * @param to Destination Tile.
* @param isObject Is destination an Object. * @param isObject Is destination an Object.
*
* @return True if Path is found. * @return True if Path is found.
*/ */
public static boolean foundPath(Tile from, Tile to, boolean isObject) { public static boolean foundPath(Tile from, Tile to, boolean isObject) {
@@ -181,6 +185,7 @@ public class Calculations {
* *
* @param from Start Tile. * @param from Start Tile.
* @param to Destination Tile. * @param to Destination Tile.
*
* @return Shortest Path distance between two tiles using Dijkstra algorithm, returns -1 if path isn't found. * @return Shortest Path distance between two tiles using Dijkstra algorithm, returns -1 if path isn't found.
*/ */
public static int pathDistanceBetween(Tile from, Tile to) { public static int pathDistanceBetween(Tile from, Tile to) {
@@ -197,6 +202,7 @@ public class Calculations {
* @param from Start Tile. * @param from Start Tile.
* @param to Destination Tile. * @param to Destination Tile.
* @param isObject Is destination an Object. * @param isObject Is destination an Object.
*
* @return Shortest Path distance between two tiles using Dijkstra algorithm, returns -1 if path isn't found. * @return Shortest Path distance between two tiles using Dijkstra algorithm, returns -1 if path isn't found.
*/ */
public static int pathDistanceBetween(Tile from, Tile to, boolean isObject) { public static int pathDistanceBetween(Tile from, Tile to, boolean isObject) {
@@ -211,6 +217,7 @@ public class Calculations {
* Gets the shortest distance to a tile. * Gets the shortest distance to a tile.
* *
* @param tile Destination Tile. * @param tile Destination Tile.
*
* @return Shortest distance to tile. * @return Shortest distance to tile.
*/ */
public static int pathDistanceTo(Tile tile) { public static int pathDistanceTo(Tile tile) {
@@ -222,6 +229,7 @@ public class Calculations {
* *
* @param tile Destination Tile. * @param tile Destination Tile.
* @param isObject Is destination an Object. * @param isObject Is destination an Object.
*
* @return Shortest distance to tile. * @return Shortest distance to tile.
*/ */
public static int pathDistanceTo(Tile tile, boolean isObject) { public static int pathDistanceTo(Tile tile, boolean isObject) {
@@ -233,6 +241,7 @@ public class Calculations {
* *
* @param first First tile. * @param first First tile.
* @param second Second tile. * @param second Second tile.
*
* @return True if Coordinate data from first and second tiles match. * @return True if Coordinate data from first and second tiles match.
*/ */
public static boolean isSameTile(Tile first, Tile second) { public static boolean isSameTile(Tile first, Tile second) {
@@ -243,6 +252,7 @@ public class Calculations {
* Checks if player is at the destination tile. * Checks if player is at the destination tile.
* *
* @param destination destination tile. * @param destination destination tile.
*
* @return true if players location equals destination tile. * @return true if players location equals destination tile.
*/ */
public static boolean atTile(Tile destination) { public static boolean atTile(Tile destination) {
@@ -254,6 +264,7 @@ public class Calculations {
* *
* @param start Starting value. * @param start Starting value.
* @param current Current value. * @param current Current value.
*
* @return difference between start and current. * @return difference between start and current.
*/ */
public static int gained(int start, int current) { public static int gained(int start, int current) {
@@ -266,6 +277,7 @@ public class Calculations {
* @param runtime Timer used for calculating hourly difference. * @param runtime Timer used for calculating hourly difference.
* @param start Starting value. * @param start Starting value.
* @param current Current value. * @param current Current value.
*
* @return Hourly difference between start and current. * @return Hourly difference between start and current.
*/ */
public static int gainedPerHour(Timer runtime, int start, int current) { public static int gainedPerHour(Timer runtime, int start, int current) {
@@ -61,6 +61,7 @@ public class Equipment {
* Check if the Player is Wearing an Item based on the ID. * Check if the Player is Wearing an Item based on the ID.
* *
* @param id ID of the item to check for. * @param id ID of the item to check for.
*
* @return True if the Player is wearing the Item. * @return True if the Player is wearing the Item.
*/ */
public static boolean isWearing(int id) { public static boolean isWearing(int id) {
@@ -77,6 +78,7 @@ public class Equipment {
* Get's the item ID in slot. * Get's the item ID in slot.
* *
* @param slot Slot to get the item ID from. * @param slot Slot to get the item ID from.
*
* @return Item ID from given slot. * @return Item ID from given slot.
*/ */
public static int getItemId(Slot slot) { public static int getItemId(Slot slot) {
@@ -87,6 +89,7 @@ public class Equipment {
* Check's if there is an item in the given slot. * Check's if there is an item in the given slot.
* *
* @param slot Slot to check for Item. * @param slot Slot to check for Item.
*
* @return True if there is an Item in the given slot. * @return True if there is an Item in the given slot.
*/ */
public static boolean hasItem(Slot slot) { public static boolean hasItem(Slot slot) {
@@ -97,6 +100,7 @@ public class Equipment {
* Check's if the given slot is empty. * Check's if the given slot is empty.
* *
* @param slot Slot to check for Item. * @param slot Slot to check for Item.
*
* @return True if the given slot is empty. * @return True if the given slot is empty.
*/ */
public static boolean isEmpty(Slot slot) { public static boolean isEmpty(Slot slot) {
@@ -32,6 +32,7 @@ public class Game {
* Gets open interface id * Gets open interface id
* *
* @return interface id * @return interface id
*
* @deprecated Use {@link Interfaces #getOpenInterfaceId()} instead * @deprecated Use {@link Interfaces #getOpenInterfaceId()} instead
*/ */
@Deprecated @Deprecated
@@ -39,11 +40,11 @@ public class Game {
return Loader.getClient().getOpenInterfaceId(); return Loader.getClient().getOpenInterfaceId();
} }
/** /**
* Get open back dialog id * Get open back dialog id
* *
* @return back dialog id * @return back dialog id
*
* @deprecated Use {@link Interfaces #getBackDialogId()} instead * @deprecated Use {@link Interfaces #getBackDialogId()} instead
*/ */
@Deprecated @Deprecated
@@ -105,6 +106,7 @@ public class Game {
* Returns the settings within the client * Returns the settings within the client
* *
* @param index The index of the setting you want to gather * @param index The index of the setting you want to gather
*
* @return The specific setting for the given index * @return The specific setting for the given index
*/ */
public static int getSetting(int index) { public static int getSetting(int index) {
@@ -6,6 +6,7 @@ import org.rev317.min.Loader;
import org.rev317.min.accessors.Client; import org.rev317.min.accessors.Client;
import org.rev317.min.accessors.Deque; import org.rev317.min.accessors.Deque;
import org.rev317.min.accessors.Node; import org.rev317.min.accessors.Node;
import org.rev317.min.api.methods.utils.Settings;
import org.rev317.min.api.wrappers.GroundItem; import org.rev317.min.api.wrappers.GroundItem;
import org.rev317.min.api.wrappers.Tile; import org.rev317.min.api.wrappers.Tile;
@@ -24,7 +25,7 @@ public class GroundItems {
return n1.distanceTo() - n2.distanceTo(); return n1.distanceTo() - n2.distanceTo();
} }
}; };
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() { private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
@Override @Override
public boolean accept(GroundItem item) { public boolean accept(GroundItem item) {
@@ -67,6 +68,7 @@ public class GroundItems {
* *
* @param x - local region x * @param x - local region x
* @param y - local region y * @param y - local region y
*
* @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest. * @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest.
*/ */
public static final GroundItem[] getGroundItemsAt(final int x, final int y) { public static final GroundItem[] getGroundItemsAt(final int x, final int y) {
@@ -80,9 +82,9 @@ public class GroundItems {
return null; return null;
} }
ArrayList<GroundItem> list = new ArrayList<>(); ArrayList<GroundItem> list = new ArrayList<>();
final Node holder = deque.getHead(); final Node holder = deque.getHead();
Node curNode = holder.getNext(); Node curNode = holder.getNext();
while (curNode != null && curNode != holder while (curNode != null && curNode != holder
&& curNode != deque.getHead()) { && curNode != deque.getHead()) {
final org.rev317.min.accessors.Item groundItem = (org.rev317.min.accessors.Item) curNode; final org.rev317.min.accessors.Item groundItem = (org.rev317.min.accessors.Item) curNode;
@@ -102,6 +104,7 @@ public class GroundItems {
* Gets GroundItems at a specific tile using x and y location. * Gets GroundItems at a specific tile using x and y location.
* *
* @param tile Tile to get the GroundItems from. * @param tile Tile to get the GroundItems from.
*
* @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest. * @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest.
*/ */
public static final GroundItem[] getGroundItemsAt(final Tile tile) { public static final GroundItem[] getGroundItemsAt(final Tile tile) {
@@ -121,6 +124,7 @@ public class GroundItems {
* Gets the closest GroundItem which matches the given filter. * Gets the closest GroundItem which matches the given filter.
* *
* @param filter Filter that should be applied to the GroundItem. * @param filter Filter that should be applied to the GroundItem.
*
* @return closest GroundItem * @return closest GroundItem
*/ */
public static final GroundItem getClosest(final Filter<GroundItem> filter) { public static final GroundItem getClosest(final Filter<GroundItem> filter) {
@@ -136,6 +140,7 @@ public class GroundItems {
* Gets the closest GroundItems which matches the given ids. * Gets the closest GroundItems which matches the given ids.
* *
* @param ids ID's of the GroundItems to look for. * @param ids ID's of the GroundItems to look for.
*
* @return closest GroundItems * @return closest GroundItems
*/ */
public static final GroundItem getClosest(int... ids) { public static final GroundItem getClosest(int... ids) {
@@ -151,6 +156,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 Filter that should be applied to the GroundItem. * @param filter Filter that should be applied to the GroundItem.
*
* @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest. * @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest.
*/ */
public static final GroundItem[] getNearest(Filter<GroundItem> filter) { public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
@@ -173,6 +179,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 ids GroundItem ID's to look for. * @param ids GroundItem ID's to look for.
*
* @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest. * @return GroundItems Array of the Nearest GroundItems with the first index to be the nearest.
*/ */
public static final GroundItem[] getNearest(final int... ids) { public static final GroundItem[] getNearest(final int... ids) {
@@ -191,18 +198,18 @@ public class GroundItems {
} }
public enum Option { public enum Option {
FIRST(settings.get("menu_ground_item_first_interaction")), FIRST(Settings.getActionByName("menu_ground_item_first_interaction")),
SECOND(settings.get("menu_ground_item_second_interaction")), SECOND(Settings.getActionByName("menu_ground_item_second_interaction")),
THIRD(settings.get("menu_ground_item_third_interaction")), THIRD(Settings.getActionByName("menu_ground_item_third_interaction")),
TAKE(settings.get("menu_ground_item_third_interaction")), TAKE(Settings.getActionByName("menu_ground_item_third_interaction")),
FOURTH(settings.get("menu_ground_item_fourth_interaction")), FOURTH(Settings.getActionByName("menu_ground_item_fourth_interaction")),
FIFTH(settings.get("menu_ground_item_fifth_interaction")), FIFTH(Settings.getActionByName("menu_ground_item_fifth_interaction")),
EXAMINE(settings.get("menu_ground_item_examine_interaction")); EXAMINE(Settings.getActionByName("menu_ground_item_examine_interaction"));
private int actionId; private int actionId;
@@ -24,6 +24,7 @@ public class Interfaces {
* Get's the Interface from the Interface Cache using the given ID. * Get's the Interface from the Interface Cache using the given ID.
* *
* @param id Interface ID. * @param id Interface ID.
*
* @return Interface from the cache by the given ID. * @return Interface from the cache by the given ID.
*/ */
public static Interface getInterface(int id) { public static Interface getInterface(int id) {
@@ -79,6 +80,7 @@ public class Interfaces {
* Checks if the Interface or Back Dialog by the given ID is Open. * Checks if the Interface or Back Dialog by the given ID is Open.
* *
* @param id ID of the Interface or Back Dialog to check for. * @param id ID of the Interface or Back Dialog to check for.
*
* @return True is the Interface or Back Dialog is Open else will return false. * @return True is the Interface or Back Dialog is Open else will return false.
*/ */
public static boolean isOpen(int id) { public static boolean isOpen(int id) {
@@ -90,6 +92,7 @@ public class Interfaces {
* *
* @param id ID of the Interface or Back Dialog to check for depending on the backDialog boolean. * @param id ID of the Interface or Back Dialog to check for depending on the backDialog boolean.
* @param backDialog When tru it will check the Bank Dialog ID else it will check for the Interface ID. * @param backDialog When tru it will check the Bank Dialog ID else it will check for the Interface ID.
*
* @return True is the Interface or Back Dialog is Open else will return false. * @return True is the Interface or Back Dialog is Open else will return false.
*/ */
public static boolean isOpen(int id, boolean backDialog) { public static boolean isOpen(int id, boolean backDialog) {
@@ -6,18 +6,18 @@ import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition; import org.parabot.environment.scripts.framework.SleepCondition;
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.methods.utils.Settings;
import org.rev317.min.api.wrappers.Item; import org.rev317.min.api.wrappers.Item;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
/** /**
* @author Everel, JKetelaar, Fryslan * @author Everel, JKetelaar, Fryslan
*/ */
public class Inventory { public class Inventory {
private static final Filter<Item> ALL_FILTER = new Filter<Item>() { private static final Filter<Item> ALL_FILTER = new Filter<Item>() {
@Override @Override
public boolean accept(Item i) { public boolean accept(Item i) {
@@ -25,7 +25,7 @@ public class Inventory {
} }
}; };
private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings(); private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings();
/** /**
* Clears the inventory * Clears the inventory
@@ -58,7 +58,7 @@ public class Inventory {
* @return interface of inventory * @return interface of inventory
*/ */
public static Interface getInterface() { public static Interface getInterface() {
return Loader.getClient().getInterfaceCache()[settings.get("inventory_index")]; return Loader.getClient().getInterfaceCache()[Settings.getActionByName("inventory_index")];
} }
/** /**
@@ -74,6 +74,7 @@ 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 int getCount(int... ids) { public static int getCount(int... ids) {
@@ -84,6 +85,7 @@ 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 int getCount(final boolean includeStack) { public static int getCount(final boolean includeStack) {
@@ -91,8 +93,8 @@ public class Inventory {
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) {
@@ -107,6 +109,7 @@ public class 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 int getCount(final boolean includeStack, int... ids) { public static int getCount(final boolean includeStack, int... ids) {
@@ -114,8 +117,8 @@ public class Inventory {
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];
@@ -144,6 +147,7 @@ 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 Item[] getItems(final int... ids) { public static Item[] getItems(final int... ids) {
@@ -166,6 +170,7 @@ 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 Item[] getItems(final Filter<Item> filter) { public static Item[] getItems(final Filter<Item> filter) {
@@ -173,16 +178,16 @@ public class Inventory {
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<>(28); final ArrayList<Item> invItems = new ArrayList<>(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);
} }
@@ -212,6 +217,7 @@ public class Inventory {
* Checks if an item exists in the inventory * Checks if an item exists in the inventory
* *
* @param id The item id that will be looked for * @param id The item id that will be looked for
*
* @return True if the item exists in the inventory * @return True if the item exists in the inventory
*/ */
public static boolean contains(int... id) { public static boolean contains(int... id) {
@@ -227,6 +233,7 @@ public class Inventory {
* Returns the item in the inventory based on the given id * Returns the item in the inventory based on the given id
* *
* @param id The item id that will be used to find the item in the inventory * @param id The item id that will be used to find the item in the inventory
*
* @return First found item in the inventory * @return First found item in the inventory
*/ */
public static Item getItem(int id) { public static Item getItem(int id) {
@@ -243,6 +250,7 @@ public class Inventory {
* *
* @param itemOne The first item id that will be used to combine * @param itemOne The first item id that will be used to combine
* @param itemTwo The second item id that will be used to combine * @param itemTwo The second item id that will be used to combine
*
* @return True if nothing unexpected happened * @return True if nothing unexpected happened
*/ */
public static boolean combine(int itemOne, int itemTwo) { public static boolean combine(int itemOne, int itemTwo) {
@@ -267,6 +275,7 @@ public class Inventory {
* @param itemOne The first item id that will be used to combine * @param itemOne The first item id that will be used to combine
* @param itemTwo The second item id that will be used to combine * @param itemTwo The second item id that will be used to combine
* @param sleepCondition The sleep condition that will be used to check and wait until the condition is valid * @param sleepCondition The sleep condition that will be used to check and wait until the condition is valid
*
* @return True if the condition was true and nothing unexpected happened * @return True if the condition was true and nothing unexpected happened
*/ */
public static boolean combine(int itemOne, int itemTwo, SleepCondition sleepCondition) { public static boolean combine(int itemOne, int itemTwo, SleepCondition sleepCondition) {
@@ -7,6 +7,7 @@ import org.json.simple.parser.ParseException;
import org.parabot.core.Configuration; import org.parabot.core.Configuration;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.parabot.environment.api.utils.WebUtil; import org.parabot.environment.api.utils.WebUtil;
import org.rev317.min.api.methods.utils.Settings;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.HashMap; import java.util.HashMap;
@@ -18,11 +19,11 @@ public class Items {
/** /**
* TODO Cache results * TODO Cache results
*/ */
private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings(); private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings();
private static JSONParser jsonParser = new JSONParser(); private static JSONParser jsonParser = new JSONParser();
private static HashMap<Integer, Long> prices = new HashMap<>(); private static HashMap<Integer, Long> prices = new HashMap<>();
private static HashMap<Integer, String> names = new HashMap<>(); private static HashMap<Integer, String> names = new HashMap<>();
public static String getName(int id) { public static String getName(int id) {
String name; String name;
@@ -32,7 +33,7 @@ public class Items {
try { try {
String content = WebUtil.getContents(Configuration.ITEM_API + id); String content = WebUtil.getContents(Configuration.ITEM_API + id);
if (content.length() > 0) { if (content.length() > 0) {
JSONObject jsonObject = (JSONObject) jsonParser.parse(content); JSONObject jsonObject = (JSONObject) jsonParser.parse(content);
JSONObject itemInformation = (JSONObject) jsonObject.get("result"); JSONObject itemInformation = (JSONObject) jsonObject.get("result");
if (itemInformation.get("name") != null && !((String) itemInformation.get("name")).equalsIgnoreCase("null")) { if (itemInformation.get("name") != null && !((String) itemInformation.get("name")).equalsIgnoreCase("null")) {
name = (String) itemInformation.get("name"); name = (String) itemInformation.get("name");
@@ -53,7 +54,7 @@ public class Items {
String content = WebUtil.getContents(Configuration.ITEM_API + name); String content = WebUtil.getContents(Configuration.ITEM_API + name);
if (content.length() > 0) { if (content.length() > 0) {
JSONObject jsonObject = (JSONObject) jsonParser.parse(content); JSONObject jsonObject = (JSONObject) jsonParser.parse(content);
JSONArray array = (JSONArray) jsonObject.get("result"); JSONArray array = (JSONArray) jsonObject.get("result");
if (array.size() > 0) { if (array.size() > 0) {
int[] ids = new int[array.size()]; int[] ids = new int[array.size()];
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
@@ -73,6 +74,7 @@ public class Items {
* Returns an int array based on the string it starts with. getIdsStart(dragon) will return an int array with all items starting with dragon * Returns an int array based on the string it starts with. getIdsStart(dragon) will return an int array with all items starting with dragon
* *
* @param name * @param name
*
* @return * @return
*/ */
public static int[] getIdsStart(String name) { public static int[] getIdsStart(String name) {
@@ -80,7 +82,7 @@ public class Items {
String content = WebUtil.getContents(Configuration.ITEM_API + "starts/" + name); String content = WebUtil.getContents(Configuration.ITEM_API + "starts/" + name);
if (content.length() > 0) { if (content.length() > 0) {
JSONObject jsonObject = (JSONObject) jsonParser.parse(content); JSONObject jsonObject = (JSONObject) jsonParser.parse(content);
JSONArray array = (JSONArray) jsonObject.get("result"); JSONArray array = (JSONArray) jsonObject.get("result");
if (array.size() > 0) { if (array.size() > 0) {
int[] ids = new int[array.size()]; int[] ids = new int[array.size()];
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
@@ -100,6 +102,7 @@ public class Items {
* Returns an int array based on the string it contains. getIdsContain(dragon) will return an int array with all items containingdragon * Returns an int array based on the string it contains. getIdsContain(dragon) will return an int array with all items containingdragon
* *
* @param name * @param name
*
* @return * @return
*/ */
public static int[] getIdsContain(String name) { public static int[] getIdsContain(String name) {
@@ -107,7 +110,7 @@ public class Items {
String content = WebUtil.getContents(Configuration.ITEM_API + "contains/" + name); String content = WebUtil.getContents(Configuration.ITEM_API + "contains/" + name);
if (content.length() > 0) { if (content.length() > 0) {
JSONObject jsonObject = (JSONObject) jsonParser.parse(content); JSONObject jsonObject = (JSONObject) jsonParser.parse(content);
JSONArray array = (JSONArray) jsonObject.get("result"); JSONArray array = (JSONArray) jsonObject.get("result");
if (array.size() > 0) { if (array.size() > 0) {
int[] ids = new int[array.size()]; int[] ids = new int[array.size()];
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
@@ -130,7 +133,7 @@ public class Items {
try { try {
String content = WebUtil.getContents(Configuration.ITEM_API + id + "/" + Context.getInstance().getServerProviderInfo().getServerName()); String content = WebUtil.getContents(Configuration.ITEM_API + id + "/" + Context.getInstance().getServerProviderInfo().getServerName());
if (content.length() > 0) { if (content.length() > 0) {
JSONObject jsonObject = (JSONObject) jsonParser.parse(content); JSONObject jsonObject = (JSONObject) jsonParser.parse(content);
JSONObject itemInformation = (JSONObject) jsonObject.get("result"); JSONObject itemInformation = (JSONObject) jsonObject.get("result");
if (itemInformation.get("price") != null && !((String) itemInformation.get("price")).equalsIgnoreCase("null")) { if (itemInformation.get("price") != null && !((String) itemInformation.get("price")).equalsIgnoreCase("null")) {
long price = Long.parseLong((String) itemInformation.get("price")); long price = Long.parseLong((String) itemInformation.get("price"));
@@ -146,49 +149,49 @@ public class Items {
} }
public enum Option { public enum Option {
TRANSFORM_FIRST(settings.get("menu_transform_one_interaction")), TRANSFORM_FIRST(Settings.getActionByName("menu_transform_one_interaction")),
VALUE(settings.get("menu_transform_one_interaction")), VALUE(Settings.getActionByName("menu_transform_one_interaction")),
TRANSFORM_ONE(settings.get("menu_transform_one_interaction")), TRANSFORM_ONE(Settings.getActionByName("menu_transform_one_interaction")),
TRANSFORM_SECOND(settings.get("menu_transform_five_interaction")), TRANSFORM_SECOND(Settings.getActionByName("menu_transform_five_interaction")),
TRANSFORM_FIVE(settings.get("menu_transform_five_interaction")), TRANSFORM_FIVE(Settings.getActionByName("menu_transform_five_interaction")),
TRANSFORM_THIRD(settings.get("menu_transform_ten_interaction")), TRANSFORM_THIRD(Settings.getActionByName("menu_transform_ten_interaction")),
TRANSFORM_TEN(settings.get("menu_transform_ten_interaction")), TRANSFORM_TEN(Settings.getActionByName("menu_transform_ten_interaction")),
TRANSFORM_FOURTH(settings.get("menu_transform_all_interaction")), TRANSFORM_FOURTH(Settings.getActionByName("menu_transform_all_interaction")),
TRANSFORM_ALL(settings.get("menu_transform_all_interaction")), TRANSFORM_ALL(Settings.getActionByName("menu_transform_all_interaction")),
TRANSFORM_FIFTH(settings.get("menu_transform_x_interaction")), TRANSFORM_FIFTH(Settings.getActionByName("menu_transform_x_interaction")),
TRANSFORM_X(settings.get("menu_transform_x_interaction")), TRANSFORM_X(Settings.getActionByName("menu_transform_x_interaction")),
TRANSFORM_HUNDRED(settings.get("menu_transform_x_interaction")), TRANSFORM_HUNDRED(Settings.getActionByName("menu_transform_x_interaction")),
TRANSFORM_SIXTH(settings.get("menu_transform_all_but_one_interaction")), TRANSFORM_SIXTH(Settings.getActionByName("menu_transform_all_but_one_interaction")),
TRANSFORM_ALL_BUT_ONE(settings.get("menu_transform_all_but_one_interaction")), TRANSFORM_ALL_BUT_ONE(Settings.getActionByName("menu_transform_all_but_one_interaction")),
TRANSFORM_EXAMINE(settings.get("menu_transform_examine_interaction")), TRANSFORM_EXAMINE(Settings.getActionByName("menu_transform_examine_interaction")),
FIRST(settings.get("menu_item_first_interaction")), FIRST(Settings.getActionByName("menu_item_first_interaction")),
WEAR(settings.get("menu_item_first_interaction")), WEAR(Settings.getActionByName("menu_item_first_interaction")),
SECOND(settings.get("menu_item_second_interaction")), SECOND(Settings.getActionByName("menu_item_second_interaction")),
CONSUME(settings.get("menu_item_second_interaction")), CONSUME(Settings.getActionByName("menu_item_second_interaction")),
DRINK(settings.get("menu_item_second_interaction")), DRINK(Settings.getActionByName("menu_item_second_interaction")),
THIRD(settings.get("menu_item_third_interaction")), THIRD(Settings.getActionByName("menu_item_third_interaction")),
USE(settings.get("menu_item_third_interaction")), USE(Settings.getActionByName("menu_item_third_interaction")),
FOURTH(settings.get("menu_item_fourth_interaction")), FOURTH(Settings.getActionByName("menu_item_fourth_interaction")),
EMPTY(settings.get("menu_item_fourth_interaction")), EMPTY(Settings.getActionByName("menu_item_fourth_interaction")),
FIFTH(settings.get("menu_item_fifth_interaction")), FIFTH(Settings.getActionByName("menu_item_fifth_interaction")),
DROP(settings.get("menu_item_fifth_interaction")), DROP(Settings.getActionByName("menu_item_fifth_interaction")),
SIXTH(settings.get("menu_item_sixth_interaction")), SIXTH(Settings.getActionByName("menu_item_sixth_interaction")),
EXAMINE(settings.get("menu_item_sixth_interaction")), EXAMINE(Settings.getActionByName("menu_item_sixth_interaction")),
SEVENTH(settings.get("menu_item_seventh_interaction")), SEVENTH(Settings.getActionByName("menu_item_seventh_interaction")),
USE_WITH(settings.get("menu_item_seventh_interaction")); USE_WITH(Settings.getActionByName("menu_item_seventh_interaction"));
private int actionId; private int actionId;
@@ -3,6 +3,7 @@ package org.rev317.min.api.methods;
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;
import org.rev317.min.api.methods.utils.Settings;
import org.rev317.min.api.wrappers.Character; import org.rev317.min.api.wrappers.Character;
import org.rev317.min.api.wrappers.*; import org.rev317.min.api.wrappers.*;
@@ -34,6 +35,7 @@ public class Menu {
* *
* @param object * @param object
* @param actionIndex * @param actionIndex
*
* @deprecated * @deprecated
*/ */
public static void interact(SceneObject object, int actionIndex) { public static void interact(SceneObject object, int actionIndex) {
@@ -87,6 +89,7 @@ public class Menu {
* *
* @param character * @param character
* @param actionIndex * @param actionIndex
*
* @deprecated * @deprecated
*/ */
public static void interact(Character character, int actionIndex) { public static void interact(Character character, int actionIndex) {
@@ -129,6 +132,7 @@ public class Menu {
* @param item * @param item
* @param actionIndex * @param actionIndex
* @param interfaceParentId * @param interfaceParentId
*
* @deprecated * @deprecated
*/ */
public static void transformItem(Item item, int actionIndex, int interfaceParentId) { public static void transformItem(Item item, int actionIndex, int interfaceParentId) {
@@ -160,7 +164,7 @@ public class Menu {
* @param item * @param item
*/ */
public static void take(GroundItem item) { public static void take(GroundItem item) {
sendAction(settings.get("button_take_item"), item.getId(), item.getX(), item.getY()); sendAction(Settings.getActionByName("button_take_item"), item.getId(), item.getX(), item.getY());
} }
/** /**
@@ -178,6 +182,7 @@ public class Menu {
* *
* @param item * @param item
* @param action * @param action
*
* @deprecated * @deprecated
*/ */
public static void interact(GroundItem item, int action) { public static void interact(GroundItem item, int action) {
@@ -262,7 +267,7 @@ public class Menu {
* @param item * @param item
*/ */
public static void drop(Item item) { public static void drop(Item item) {
sendAction(settings.get("button_drop_item"), item.getId() - 1, item.getSlot(), settings.get("inventory_index")); sendAction(Settings.getActionByName("button_drop_item"), item.getId() - 1, item.getSlot(), Settings.getActionByName("inventory_index"));
} }
/** /**
@@ -271,7 +276,7 @@ public class Menu {
* @param id * @param id
*/ */
public static void clickButton(int id) { public static void clickButton(int id) {
sendAction(settings.get("button_action_click"), 0, 0, id); sendAction(Settings.getActionByName("button_action_click"), 0, 0, id);
} }
/** /**
@@ -4,6 +4,7 @@ import org.parabot.core.Context;
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.methods.utils.Settings;
import org.rev317.min.api.wrappers.Npc; import org.rev317.min.api.wrappers.Npc;
import java.util.ArrayList; import java.util.ArrayList;
@@ -25,7 +26,7 @@ public class Npcs {
}; };
private static final Filter<Npc> ALL_FILTER = new Filter<Npc>() { private static final Filter<Npc> ALL_FILTER = new Filter<Npc>() {
@Override @Override
public boolean accept(Npc n) { public boolean accept(Npc n) {
@@ -33,17 +34,18 @@ public class Npcs {
} }
}; };
private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings(); private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings();
/** /**
* 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) {
final Client client = Loader.getClient(); final Client client = Loader.getClient();
ArrayList<Npc> npcList = new ArrayList<>(); ArrayList<Npc> npcList = new ArrayList<>();
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) {
@@ -71,6 +73,7 @@ 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) {
@@ -86,6 +89,7 @@ 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) {
@@ -101,6 +105,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) {
@@ -114,6 +119,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) {
@@ -148,31 +154,31 @@ public class Npcs {
} }
public enum Option { public enum Option {
FIRST(settings.get("menu_character_first_interaction")), FIRST(Settings.getActionByName("menu_character_first_interaction")),
ATTACK(settings.get("menu_character_first_interaction")), ATTACK(Settings.getActionByName("menu_character_first_interaction")),
SECOND(settings.get("menu_character_second_interaction")), SECOND(Settings.getActionByName("menu_character_second_interaction")),
TALK_TO(settings.get("menu_character_second_interaction")), TALK_TO(Settings.getActionByName("menu_character_second_interaction")),
INTERACT(settings.get("menu_character_second_interaction")), INTERACT(Settings.getActionByName("menu_character_second_interaction")),
BAIT(settings.get("menu_character_second_interaction")), BAIT(Settings.getActionByName("menu_character_second_interaction")),
CAGE(settings.get("menu_character_second_interaction")), CAGE(Settings.getActionByName("menu_character_second_interaction")),
NET(settings.get("menu_character_second_interaction")), NET(Settings.getActionByName("menu_character_second_interaction")),
THIRD(settings.get("menu_character_third_interaction")), THIRD(Settings.getActionByName("menu_character_third_interaction")),
TRADE(settings.get("menu_character_third_interaction")), TRADE(Settings.getActionByName("menu_character_third_interaction")),
BANK(settings.get("menu_character_third_interaction")), BANK(Settings.getActionByName("menu_character_third_interaction")),
PICKPOCKET(settings.get("menu_character_third_interaction")), PICKPOCKET(Settings.getActionByName("menu_character_third_interaction")),
HARPOON(settings.get("menu_character_third_interaction")), HARPOON(Settings.getActionByName("menu_character_third_interaction")),
GET_TASK(settings.get("menu_character_third_interaction")), GET_TASK(Settings.getActionByName("menu_character_third_interaction")),
FOURTH(settings.get("menu_character_fourth_interaction")), FOURTH(Settings.getActionByName("menu_character_fourth_interaction")),
COLLECT(settings.get("menu_character_fourth_interaction")), COLLECT(Settings.getActionByName("menu_character_fourth_interaction")),
CHANGE_CLOTHES(settings.get("menu_character_fourth_interaction")), CHANGE_CLOTHES(Settings.getActionByName("menu_character_fourth_interaction")),
FIFTH(settings.get("menu_character_fifth_interaction")), FIFTH(Settings.getActionByName("menu_character_fifth_interaction")),
REWARD(settings.get("menu_character_fifth_interaction")), REWARD(Settings.getActionByName("menu_character_fifth_interaction")),
EXAMINE(settings.get("menu_character_examine")); EXAMINE(Settings.getActionByName("menu_character_examine"));
private int actionId; private int actionId;
@@ -4,6 +4,7 @@ import org.parabot.core.Context;
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.methods.utils.Settings;
import org.rev317.min.api.wrappers.Player; import org.rev317.min.api.wrappers.Player;
import java.util.ArrayList; import java.util.ArrayList;
@@ -25,7 +26,7 @@ public class Players {
}; };
private static final Filter<Player> ALL_FILTER = new Filter<Player>() { private static final Filter<Player> ALL_FILTER = new Filter<Player>() {
@Override @Override
public boolean accept(Player p) { public boolean accept(Player p) {
@@ -33,17 +34,18 @@ public class Players {
} }
}; };
private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings(); private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings();
/** /**
* 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<>(); ArrayList<Player> playerList = new ArrayList<>();
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) {
@@ -71,6 +73,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
* *
* @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) {
@@ -98,24 +101,24 @@ public class Players {
} }
public enum Option { public enum Option {
FIRST(settings.get("menu_character_first_interaction")), FIRST(Settings.getActionByName("menu_character_first_interaction")),
SECOND(settings.get("menu_character_second_interaction")), SECOND(Settings.getActionByName("menu_character_second_interaction")),
THIRD(settings.get("menu_character_third_interaction")), THIRD(Settings.getActionByName("menu_character_third_interaction")),
FOURTH(settings.get("menu_character_fourth_interaction")), FOURTH(Settings.getActionByName("menu_character_fourth_interaction")),
FIFTH(settings.get("menu_character_fifth_interaction")), FIFTH(Settings.getActionByName("menu_character_fifth_interaction")),
FOLLOW(settings.get("menu_character_follow")), FOLLOW(Settings.getActionByName("menu_character_follow")),
TRADE(settings.get("menu_character_trade")), TRADE(Settings.getActionByName("menu_character_trade")),
ATTACK(settings.get("menu_character_attack")), ATTACK(Settings.getActionByName("menu_character_attack")),
CHALLENGE(settings.get("menu_character_attack")), CHALLENGE(Settings.getActionByName("menu_character_attack")),
EXAMINE(settings.get("menu_character_examine")); EXAMINE(Settings.getActionByName("menu_character_examine"));
private int actionId; private int actionId;
@@ -5,6 +5,7 @@ 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.methods.utils.Settings;
import org.rev317.min.api.wrappers.SceneObject; import org.rev317.min.api.wrappers.SceneObject;
import java.util.*; import java.util.*;
@@ -23,7 +24,7 @@ public class SceneObjects {
}; };
private static final Filter<SceneObject> ALL_FILTER = new Filter<SceneObject>() { private static final Filter<SceneObject> ALL_FILTER = new Filter<SceneObject>() {
@Override @Override
public boolean accept(SceneObject object) { public boolean accept(SceneObject object) {
@@ -31,7 +32,7 @@ public class SceneObjects {
} }
}; };
private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings(); private static HashMap<String, Integer> settings = Context.getInstance().getServerProviderInfo().getSettings();
/** /**
* Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall * Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall
@@ -67,6 +68,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
* *
* @param filter * @param filter
*
* @return sceneobjects * @return sceneobjects
*/ */
public static final SceneObject[] getNearest(Filter<SceneObject> filter) { public static final SceneObject[] getNearest(Filter<SceneObject> filter) {
@@ -89,6 +91,7 @@ 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) {
@@ -175,10 +178,11 @@ public class SceneObjects {
* *
* @param x * @param x
* @param y * @param y
*
* @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) { public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y) {
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;
if (sceneTile != null) { if (sceneTile != null) {
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects(); final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
@@ -228,37 +232,36 @@ public class SceneObjects {
return sceneObjects; return sceneObjects;
} }
public enum Option { public enum Option {
FIRST(settings.get("menu_scene_object_first_interaction")), FIRST(Settings.getActionByName("menu_scene_object_first_interaction")),
TALK_TO(settings.get("menu_scene_object_first_interaction")), TALK_TO(Settings.getActionByName("menu_scene_object_first_interaction")),
CHOP_DOWN(settings.get("menu_scene_object_first_interaction")), CHOP_DOWN(Settings.getActionByName("menu_scene_object_first_interaction")),
CRAFT_RUNE(settings.get("menu_scene_object_first_interaction")), CRAFT_RUNE(Settings.getActionByName("menu_scene_object_first_interaction")),
PRAY_AT(settings.get("menu_scene_object_first_interaction")), PRAY_AT(Settings.getActionByName("menu_scene_object_first_interaction")),
OPEN(settings.get("menu_scene_object_first_interaction")), OPEN(Settings.getActionByName("menu_scene_object_first_interaction")),
DEPOSIT(settings.get("menu_scene_object_first_interaction")), DEPOSIT(Settings.getActionByName("menu_scene_object_first_interaction")),
USE(settings.get("menu_scene_object_first_interaction")), USE(Settings.getActionByName("menu_scene_object_first_interaction")),
SEARCH(settings.get("menu_scene_object_first_interaction")), SEARCH(Settings.getActionByName("menu_scene_object_first_interaction")),
CLOSE(settings.get("menu_scene_object_first_interaction")), CLOSE(Settings.getActionByName("menu_scene_object_first_interaction")),
CROSS(settings.get("menu_scene_object_first_interaction")), CROSS(Settings.getActionByName("menu_scene_object_first_interaction")),
MINE(settings.get("menu_scene_object_first_interaction")), MINE(Settings.getActionByName("menu_scene_object_first_interaction")),
SMELT(settings.get("menu_scene_object_first_interaction")), SMELT(Settings.getActionByName("menu_scene_object_first_interaction")),
SECOND(settings.get("menu_scene_object_second_interaction")), SECOND(Settings.getActionByName("menu_scene_object_second_interaction")),
TELEPORT(settings.get("menu_scene_object_second_interaction")), TELEPORT(Settings.getActionByName("menu_scene_object_second_interaction")),
STEAL_FROM(settings.get("menu_scene_object_second_interaction")), STEAL_FROM(Settings.getActionByName("menu_scene_object_second_interaction")),
PRAY(settings.get("menu_scene_object_second_interaction")), PRAY(Settings.getActionByName("menu_scene_object_second_interaction")),
USE_QUICKLY(settings.get("menu_scene_object_second_interaction")), USE_QUICKLY(Settings.getActionByName("menu_scene_object_second_interaction")),
INSPECT(settings.get("menu_scene_object_second_interaction")), INSPECT(Settings.getActionByName("menu_scene_object_second_interaction")),
THIRD(settings.get("menu_scene_object_third_interaction")), THIRD(Settings.getActionByName("menu_scene_object_third_interaction")),
FOURTH(settings.get("menu_scene_object_fourth_interaction")), FOURTH(Settings.getActionByName("menu_scene_object_fourth_interaction")),
GUIDE(settings.get("menu_scene_object_fourth_interaction")), GUIDE(Settings.getActionByName("menu_scene_object_fourth_interaction")),
FIFTH(settings.get("menu_scene_object_fifth_interaction")), FIFTH(Settings.getActionByName("menu_scene_object_fifth_interaction")),
EXAMINE(settings.get("menu_scene_object_examine")); EXAMINE(Settings.getActionByName("menu_scene_object_examine"));
private int actionId; private int actionId;
@@ -9,7 +9,7 @@ public enum Skill {
ATTACK, DEFENSE, STRENGTH, HITPOINTS, RANGE, PRAYER, MAGIC, COOKING, WOODCUTTING, FLETCHING, FISHING, FIREMAKING, CRAFTING, SMITHING, MINING, HERBLORE, AGILITY, THIEVING, SLAYER, FARMING, RUNECRAFTING, CONSTRUCTION, HUNTER, SUMMONING, DUNGEONEERING; ATTACK, DEFENSE, STRENGTH, HITPOINTS, RANGE, PRAYER, MAGIC, COOKING, WOODCUTTING, FLETCHING, FISHING, FIREMAKING, CRAFTING, SMITHING, MINING, HERBLORE, AGILITY, THIEVING, SLAYER, FARMING, RUNECRAFTING, CONSTRUCTION, HUNTER, 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,
@@ -24,12 +24,13 @@ 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 };
/** /**
* Returns the experience of the provided skill. * Returns the experience of the provided skill.
* *
* @param index the skill index. * @param index the skill index.
*
* @return the experience. * @return the experience.
*/ */
public static final int getCurrentExperience(int index) { public static final int getCurrentExperience(int index) {
@@ -40,6 +41,7 @@ public enum Skill {
* Returns the real level of the provided skill. * Returns the real level of the provided skill.
* *
* @param index the skill index. * @param index the skill index.
*
* @return the real skill level. * @return the real skill level.
*/ */
public static final int getRealLevel(int index) { public static final int getRealLevel(int index) {
@@ -50,6 +52,7 @@ public enum Skill {
* Returns the current level of the provided skill. (Will return de-buffed/buffed levels) * Returns the current level of the provided skill. (Will return de-buffed/buffed levels)
* *
* @param index the skill index. * @param index the skill index.
*
* @return the current skill level. Done by Bears * @return the current skill level. Done by Bears
*/ */
public static final int getCurrentLevel(int index) { public static final int getCurrentLevel(int index) {
@@ -60,6 +63,7 @@ public enum Skill {
* Returns the exact experience at the provided level. * Returns the exact experience at the provided level.
* *
* @param level the level. * @param level the level.
*
* @return the experience at the provided level. * @return the experience at the provided level.
*/ */
public static final int getExperienceByLevel(int level) { public static final int getExperienceByLevel(int level) {
@@ -74,6 +78,7 @@ public enum Skill {
* Returns the exact level with the provided experience. * Returns the exact level with the provided experience.
* *
* @param experience the experience. * @param experience the experience.
*
* @return the level at the provided experience. * @return the level at the provided experience.
*/ */
public static final int getLevelByExperience(int experience) { public static final int getLevelByExperience(int experience) {
@@ -90,6 +95,7 @@ public enum Skill {
* Returns the remaining experience for the provided skill to level up. * Returns the remaining experience for the provided skill to level up.
* *
* @param index the skill index. * @param index the skill index.
*
* @return the remaining experience. * @return the remaining experience.
*/ */
public static final int getRemainingExperience(int index) { public static final int getRemainingExperience(int index) {
@@ -105,11 +111,12 @@ public enum Skill {
* Returns the percentage to the next level for the provided skill. * Returns the percentage to the next level for the provided skill.
* *
* @param index the skill index. * @param index the skill index.
*
* @return the remaining percentage. * @return the remaining percentage.
*/ */
public static final int getPercentToNextLevel(int index) { public static final int getPercentToNextLevel(int index) {
int currentLevel = getLevelByExperience(getCurrentExperience(index)); int currentLevel = getLevelByExperience(getCurrentExperience(index));
int nextLevel = currentLevel + 1; int nextLevel = currentLevel + 1;
if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1 if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1
|| nextLevel < 1) { || nextLevel < 1) {
return 0; return 0;
@@ -4,6 +4,7 @@ import org.parabot.core.Context;
import org.parabot.environment.api.utils.Time; import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition; import org.parabot.environment.scripts.framework.SleepCondition;
import org.rev317.min.accessors.Interface; import org.rev317.min.accessors.Interface;
import org.rev317.min.api.methods.utils.Settings;
import org.rev317.min.api.wrappers.Item; import org.rev317.min.api.wrappers.Item;
import java.util.ArrayList; import java.util.ArrayList;
@@ -20,10 +21,11 @@ public class Trading {
* Checks if the first or the second screen is open, based on the given boolean * Checks if the first or the second screen is open, based on the given boolean
* *
* @param first If true, the first trade screen will be checked. If false, the second screen will be checked * @param first If true, the first trade screen will be checked. If false, the second screen will be checked
*
* @return True if the requested screen is open * @return True if the requested screen is open
*/ */
public static boolean isOpen(boolean first) { public static boolean isOpen(boolean first) {
return Interfaces.getOpenInterfaceId() == (first ? settings.get("first_trade_interface_id") : settings.get("second_trade_interface_id")); return Interfaces.getOpenInterfaceId() == (first ? Settings.getActionByName("first_trade_interface_id") : Settings.getActionByName("second_trade_interface_id"));
} }
/** /**
@@ -32,7 +34,7 @@ public class Trading {
* @return True if open, false if not open * @return True if open, false if not open
*/ */
public static boolean isOpen() { public static boolean isOpen() {
return Interfaces.getOpenInterfaceId() == settings.get("first_trade_interface_id") || Interfaces.getOpenInterfaceId() == settings.get("second_trade_interface_id"); return Interfaces.getOpenInterfaceId() == Settings.getActionByName("first_trade_interface_id") || Interfaces.getOpenInterfaceId() == Settings.getActionByName("second_trade_interface_id");
} }
/** /**
@@ -50,9 +52,9 @@ public class Trading {
} }
public static Item[] getMyOffer() { public static Item[] getMyOffer() {
ArrayList<Item> items = new ArrayList<>(); ArrayList<Item> items = new ArrayList<>();
int[] ids = getItemIDs(settings.get("my_offer_interface_id")); int[] ids = getItemIDs(Settings.getActionByName("my_offer_interface_id"));
int[] stacks = getItemStacks(settings.get("my_offer_interface_id")); int[] stacks = getItemStacks(Settings.getActionByName("my_offer_interface_id"));
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {
if (ids[i] > 0) { if (ids[i] > 0) {
items.add(new Item(ids[i], stacks[i], i)); items.add(new Item(ids[i], stacks[i], i));
@@ -62,9 +64,9 @@ public class Trading {
} }
public static Item[] getOpponentsOffer() { public static Item[] getOpponentsOffer() {
ArrayList<Item> items = new ArrayList<>(); ArrayList<Item> items = new ArrayList<>();
int[] ids = getItemIDs(settings.get("opponent_offer_interface_id")); int[] ids = getItemIDs(Settings.getActionByName("opponent_offer_interface_id"));
int[] stacks = getItemStacks(settings.get("opponent_offer_interface_id")); int[] stacks = getItemStacks(Settings.getActionByName("opponent_offer_interface_id"));
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {
if (ids[i] > 0) { if (ids[i] > 0) {
items.add(new Item(ids[i], stacks[i], i)); items.add(new Item(ids[i], stacks[i], i));
@@ -106,7 +108,7 @@ public class Trading {
Time.sleep(new SleepCondition() { Time.sleep(new SleepCondition() {
@Override @Override
public boolean isValid() { public boolean isValid() {
return Interfaces.getOpenInterfaceId() == settings.get("second_trade_interface_id"); return Interfaces.getOpenInterfaceId() == Settings.getActionByName("second_trade_interface_id");
} }
}, 2500); }, 2500);
} }
@@ -1,6 +1,5 @@
package org.rev317.min.api.methods; package org.rev317.min.api.methods;
import org.parabot.core.Context; import org.parabot.core.Context;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.api.wrappers.Tile; import org.rev317.min.api.wrappers.Tile;
@@ -36,6 +35,7 @@ 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) {
@@ -51,6 +51,7 @@ 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) {
@@ -0,0 +1,50 @@
package org.rev317.min.api.methods.utils;
/**
* @author EmmaStone
*/
public enum Emote {
YES(168),
NO(169),
BOW(164),
ANGRY(165),
THINK(162),
WAVE(163),
SHRUG(13370),
CHEER(171),
BECKON(167),
LAUGH(170),
JUMP_FOR_JOY(13366),
YAWN(13368),
DANCE(166),
JIG(13363),
SPIN(13364),
HEADBANG(13365),
CRY(161),
BLOW_KISS(11100),
PANIC(13362),
RASPBERRY(13367),
CLAP(172),
SALUTE(13369),
GOBLIN_BOW(13383),
GOBLIN_SALUTE(13384),
GLASS_BOX(667),
CLIMB_ROPE(6503),
LEAN_ON_AIR(6506),
GLASS_WALL(666),
ZOMBIE_WALK(18464),
ZOMBIE_DANCE(18465),
SCARED(15166),
RABBIT_HOP(18686),
SKILLCAPE_EMOTE(154);
private int action3;
Emote(int action3) {
this.action3 = action3;
}
public int getAction3() {
return action3;
}
}
@@ -0,0 +1,82 @@
package org.rev317.min.api.methods.utils;
/**
* @author EmmaStone
*/
public enum Settings {
BANK_INTERFACE_ID("bank_interface_id", 5292),
ITEM_INTERFACE_ID("item_interface_id", 5382),
BUTTON_CLOSE_BANK("button_close_bank", 5384),
BUTTON_DEPOSIT_ALL("button_deposit_all", 5386),
BUTTON_ACTION_CLICK("button_deposit_all", 646),
BUTTON_DROP_ITEM("button_drop_item", 847),
BUTTON_TAKE_ITEM("button_take_item", 234),
INVENTORY_PARENT_ID("inventory_parent_id", 5064),
BANK_OPEN_ID("bank_open_index", 1),
INVENTORY_INDEX("inventory_index", 3214),
MY_OFFER_INTERFACE_ID("my_offer_interface_id", 3415),
OPPONENT_OFFER_INTERFACE_ID("opponent_offer_interface_id", 3416),
FIRST_TRADE_INTERFACE_ID("first_trade_interface_id", 3323),
SECOND_TRADE_INTERFACE_ID("second_trade_interface_id", 3443),
MENU_SCENE_OBJECT_FIRST_INTERACTION("menu_scene_object_first_interaction", 502),
MENU_SCENE_OBJECT_SECOND_INTERACTION("menu_scene_object_second_interaction", 900),
MENU_SCENE_OBJECT_THIRD_INTERACTION("menu_scene_object_third_interaction", 113),
MENU_SCENE_OBJECT_FOURTH_INTERACTION("menu_scene_object_fourth_interaction", 872),
MENU_SCENE_OBJECT_FIFTH_INTERACTION("menu_scene_object_fifth_interaction", 1062),
MENU_SCENE_OBJECT_EXAMINE("menu_scene_object_examine", 1226),
MENU_CHARACTER_FOLLOW("menu_character_follow", 2779),
MENU_CHARACTER_TRADE("menu_character_trade", 2027),
MENU_CHARACTER_ATTACK("menu_character_attack", 2561),
MENU_CHARACTER_FIRST_INTERACTION("menu_character_first_interaction", 412),
MENU_CHARACTER_SECOND_INTERACTION("menu_character_second_interaction", 20),
MENU_CHARACTER_THIRD_INTERACTION("menu_character_third_interaction", 225),
MENU_CHARACTER_FOURTH_INTERACTION("menu_character_fourth_interaction", 965),
MENU_CHARACTER_FIFTH_INTERACTION("menu_character_fifth_interaction", 478),
MENU_CHARACTER_EXAMINE("menu_character_examine", 1025),
MENU_TRANSFORM_ONE_INTERACTION("menu_transform_one_interaction", 632),
MENU_TRANSFORM_FIVE_INTERACTION("menu_transform_five_interaction", 78),
MENU_TRANSFORM_TEN_INTERACTION("menu_transform_ten_interaction", 867),
MENU_TRANSFORM_ALL_INTERACTION("menu_transform_all_interaction", 431),
MENU_TRANSFORM_X_INTERACTION("menu_transform_x_interaction", 53),
MENU_TRANSFORM_ALL_BUT_ONE_INTERACTION("menu_transform_all_but_one_interaction", 775),
MENU_TRANSFORM_EXAMINE_INTERACTION("menu_transform_examine_interaction", 1125),
MENU_GROUND_ITEM_FIRST_INTERACTION("menu_ground_item_first_interaction", 652),
MENU_GROUND_ITEM_SECOND_INTERACTION("menu_ground_item_second_interaction", 567),
MENU_GROUND_ITEM_THIRD_INTERACTION("menu_ground_item_third_interaction", 234),
MENU_GROUND_ITEM_FOURTH_INTERACTION("menu_ground_item_fourth_interaction", 244),
MENU_GROUND_ITEM_FIFTH_INTERACTION("menu_ground_item_fifth_interaction", 213),
MENU_GROUND_ITEM_EXAMINE_INTERACTION("menu_ground_item_examine_interaction", 1448),
MENU_ITEM_FIRST_INTERACTION("menu_item_first_interaction", 454),
MENU_ITEM_SECOND_INTERACTION("menu_item_second_interaction", 74),
MENU_ITEM_THIRD_INTERACTION("menu_item_third_interaction", 447),
MENU_ITEM_FOURTH_INTERACTION("menu_item_fourth_interaction", 493),
MENU_ITEM_FIFTH_INTERACTION("menu_item_fifth_interaction", 847),
MENU_ITEM_SIXTH_INTERACTION("menu_item_sixth_interaction", 1125),
MENU_ITEM_SEVENTH_INTERACTION("menu_item_seventh_interaction", 870);
private String name;
private int id;
Settings(String name, int id) {
this.name = name;
this.id = id;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
public static int getActionByName(String name) {
for (Settings settings : Settings.values()) {
if (name.equalsIgnoreCase(settings.getName())) {
return settings.getId();
}
}
return 0;
}
}
@@ -50,11 +50,11 @@ public class Area {
* @return the tiles. * @return the tiles.
*/ */
public Tile[] getTiles() { public Tile[] getTiles() {
int lowestX = -1; int lowestX = -1;
int lowestY = -1; int lowestY = -1;
int highestX = -1; int highestX = -1;
int highestY = -1; int highestY = -1;
ArrayList<Tile> t = new ArrayList<>(); ArrayList<Tile> t = new ArrayList<>();
for (int i : p.xpoints) { for (int i : p.xpoints) {
if (i < lowestX || lowestX == -1) { if (i < lowestX || lowestX == -1) {
lowestX = i; lowestX = i;
@@ -86,6 +86,7 @@ public class Area {
* Checks if a tile is in the area * Checks if a tile is in the area
* *
* @param tile The tile to check * @param tile The tile to check
*
* @return <b>true</b> if area does contain the tile, otherwise <b>false</b> * @return <b>true</b> if area does contain the tile, otherwise <b>false</b>
*/ */
public boolean contains(Tile tile) { public boolean contains(Tile tile) {
@@ -97,11 +98,12 @@ public class Area {
* *
* @param x The x-axis from the tile * @param x The x-axis from the tile
* @param y The y-axis from the tile * @param y The y-axis from the tile
*
* @return True if the area does contain the tile, otherwise false * @return True if the area does contain the tile, otherwise false
*/ */
public boolean contains(int x, int y) { public boolean contains(int x, int y) {
int i; int i;
int j; int j;
boolean result = false; boolean result = false;
for (i = 0, j = p.npoints - 1; i < p.npoints; j = i++) { for (i = 0, j = p.npoints - 1; i < p.npoints; j = i++) {
if ((p.ypoints[i] > y - 1) != (p.ypoints[j] > y - 1) if ((p.ypoints[i] > y - 1) != (p.ypoints[j] > y - 1)
@@ -1,20 +1,23 @@
package org.rev317.min.api.wrappers; package org.rev317.min.api.wrappers;
import org.parabot.core.reflect.RefClass; import org.parabot.core.reflect.RefClass;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.rev317.min.Loader; import org.rev317.min.Loader;
import org.rev317.min.api.interfaces.Locatable; import org.rev317.min.api.interfaces.Locatable;
import org.rev317.min.api.methods.Calculations; import org.rev317.min.api.methods.Calculations;
import org.rev317.min.api.methods.Game; import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Menu; import org.rev317.min.api.methods.Menu;
import org.rev317.min.api.methods.Players; import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.utils.Emote;
/** /**
* @author Everel * @author Everel, EmmaStone
*/ */
public class Character implements Locatable { public class Character implements Locatable {
private org.rev317.min.accessors.Character accessor; private org.rev317.min.accessors.Character accessor;
private int index; private int index;
public Character(org.rev317.min.accessors.Character accessor, int index) { public Character(org.rev317.min.accessors.Character accessor, int index) {
this.accessor = accessor; this.accessor = accessor;
@@ -116,6 +119,7 @@ public class Character implements Locatable {
* Interacts with this character * Interacts with this character
* *
* @param i * @param i
*
* @deprecated * @deprecated
*/ */
public void interact(int i) { public void interact(int i) {
@@ -146,6 +150,21 @@ public class Character implements Locatable {
return null; return null;
} }
/**
* Performs an emote
*
* @param emote
*/
public void performEmote(Emote emote) {
Menu.clickButton(emote.getAction3());
Time.sleep(new SleepCondition() {
@Override
public boolean isValid() {
return Players.getMyPlayer().getAnimation() != -1;
}
}, 1500);
}
/** /**
* Gets the accessor class * Gets the accessor class
* *
@@ -157,8 +176,8 @@ public class Character implements Locatable {
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result result = prime * result
+ ((accessor == null) ? 0 : accessor.hashCode()); + ((accessor == null) ? 0 : accessor.hashCode());
result = prime * result + index; result = prime * result + index;
@@ -12,8 +12,8 @@ import org.rev317.min.api.methods.Menu;
*/ */
public class GroundItem implements Locatable { public class GroundItem implements Locatable {
private org.rev317.min.accessors.Item accessor; private org.rev317.min.accessors.Item accessor;
private int x; private int x;
private int y; private int y;
public GroundItem(org.rev317.min.accessors.Item accessor, int x, int y) { public GroundItem(org.rev317.min.accessors.Item accessor, int x, int y) {
this.accessor = accessor; this.accessor = accessor;
@@ -61,6 +61,7 @@ public class GroundItem implements Locatable {
* Interacts with this ground item * Interacts with this ground item
* *
* @param actionIndex * @param actionIndex
*
* @deprecated * @deprecated
*/ */
public void interact(int actionIndex) { public void interact(int actionIndex) {
@@ -71,6 +71,7 @@ public class Item {
* Interacts with this item * Interacts with this item
* *
* @param i * @param i
*
* @deprecated * @deprecated
*/ */
public void interact(int i) { public void interact(int i) {
@@ -81,6 +82,7 @@ public class Item {
* Interacts with this item * Interacts with this item
* *
* @param s * @param s
*
* @deprecated * @deprecated
*/ */
public void interact(String s) { public void interact(String s) {
@@ -90,6 +92,7 @@ public class Item {
/** /**
* @param actionIndex * @param actionIndex
* @param interfaceParentId * @param interfaceParentId
*
* @deprecated * @deprecated
*/ */
public void transform(int actionIndex, int interfaceParentId) { public void transform(int actionIndex, int interfaceParentId) {
@@ -15,7 +15,6 @@ public final class Npc extends Character {
this.accessor = accessor; this.accessor = accessor;
} }
/** /**
* Gets the definition of this npc * Gets the definition of this npc
* *
@@ -25,6 +25,7 @@ public class NpcDef {
* Gets id of this item * Gets id of this item
* *
* @param avoidLong defines if it should check if long id exists * @param avoidLong defines if it should check if long id exists
*
* @return id of this item * @return id of this item
*/ */
private int getId(boolean avoidLong) { private int getId(boolean avoidLong) {
@@ -38,7 +39,7 @@ public class NpcDef {
// } // }
// return (int) id; // return (int) id;
// } catch (Exception e) { // } catch (Exception e) {
return accessor.getId(); return accessor.getId();
// } // }
} }
} }
@@ -12,14 +12,14 @@ import org.rev317.min.api.methods.SceneObjects;
* @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
public static final int TYPE_WALLDECORATION = 1; // object2 public static final int TYPE_WALLDECORATION = 1; // object2
public static final int TYPE_GROUNDDECORATION = 2; // object3 public static final int TYPE_GROUNDDECORATION = 2; // object3
public static final int TYPE_GROUNDITEM = 3; // object4 public static final int TYPE_GROUNDITEM = 3; // object4
public static final int TYPE_INTERACTIVE = 4; // object5 public static final int TYPE_INTERACTIVE = 4; // object5
public SceneObjectTile accessor; public SceneObjectTile accessor;
private int type; private int type;
public SceneObject(SceneObjectTile accessor, int type) { public SceneObject(SceneObjectTile accessor, int type) {
this.accessor = accessor; this.accessor = accessor;
@@ -102,6 +102,7 @@ public class SceneObject implements Locatable {
* Interacts with this object * Interacts with this object
* *
* @param actionIndex * @param actionIndex
*
* @deprecated * @deprecated
*/ */
public void interact(int actionIndex) { public void interact(int actionIndex) {
@@ -139,6 +139,7 @@ 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) {
@@ -12,7 +12,7 @@ import org.rev317.min.script.ScriptEngine;
*/ */
public class MenuAction { public class MenuAction {
private static final String[][] outputs = { private static final String[][] outputs = {
{ {
"[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", "[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]",
"[id: %d, action1: %d, action2: %d, action3: %d, action4: %d, index: %d]" "[id: %d, action1: %d, action2: %d, action3: %d, action4: %d, index: %d]"
@@ -22,17 +22,17 @@ public class MenuAction {
"[id: %d, action1: %d, action2: %d, action3: %d, index: %d]" "[id: %d, action1: %d, action2: %d, action3: %d, index: %d]"
} }
}; };
private static int currentOutputIndex = 0; private static int currentOutputIndex = 0;
public static void intercept(int index) { public static void intercept(int index) {
int outputIndex = 0; int outputIndex = 0;
Client client = Loader.getClient(); Client client = Loader.getClient();
int action1 = client.getMenuAction1()[index]; int action1 = client.getMenuAction1()[index];
int action2 = client.getMenuAction2()[index]; int action2 = client.getMenuAction2()[index];
int action3 = client.getMenuAction3()[index]; int action3 = client.getMenuAction3()[index];
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];
@@ -3,7 +3,6 @@ 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;
public class MessageCallback { public class MessageCallback {
public static final void messageListenerHook(int type, String name, String message) { public static final void messageListenerHook(int type, String name, String message) {
@@ -14,13 +14,13 @@ public class DCollisionFlags extends AbstractDebugger {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
PaintDebugger p = Context.getInstance().getPaintDebugger(); PaintDebugger p = Context.getInstance().getPaintDebugger();
Tile location = Players.getMyPlayer().getLocation(); Tile location = Players.getMyPlayer().getLocation();
Tile north = new Tile(location.getX(), location.getY() + 1); Tile north = new Tile(location.getX(), location.getY() + 1);
Tile south = new Tile(location.getX(), location.getY() - 1); Tile south = new Tile(location.getX(), location.getY() - 1);
Tile west = new Tile(location.getX() - 1, location.getY()); Tile west = new Tile(location.getX() - 1, location.getY());
Tile east = new Tile(location.getX() + 1, location.getY()); Tile east = new Tile(location.getX() + 1, location.getY());
int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()]; int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()];
p.addLine("Collision flag: 0x" + String.format("%X", flag)); p.addLine("Collision flag: 0x" + String.format("%X", flag));
p.addLine("Reachable: [ cur: " + location.isReachable() + ", north: " + north.isReachable() + ", south: " + south.isReachable() + ", east: " + east.isReachable() + ", west: " + west.isReachable() + " ]"); p.addLine("Reachable: [ cur: " + location.isReachable() + ", north: " + north.isReachable() + ", south: " + south.isReachable() + ", east: " + east.isReachable() + ", west: " + west.isReachable() + " ]");
p.addLine("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]"); p.addLine("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]");
@@ -17,7 +17,7 @@ public class DMessages extends AbstractDebugger implements MessageListener {
private String message; private String message;
private String sender; private String sender;
private int type; private int type;
@Override @Override
public void toggle() { public void toggle() {
@@ -20,8 +20,9 @@ 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(
@@ -21,10 +21,10 @@ import java.util.HashMap;
*/ */
public class ScriptEngine { public class ScriptEngine {
private static HashMap<Context, ScriptEngine> instances = new HashMap<>(); private static HashMap<Context, ScriptEngine> instances = new HashMap<>();
private ArrayList<MouseListener> mouseListeners; private ArrayList<MouseListener> mouseListeners;
private ArrayList<MouseMotionListener> mouseMotionListeners; private ArrayList<MouseMotionListener> mouseMotionListeners;
private ArrayList<MessageListener> messageListeners; private ArrayList<MessageListener> messageListeners;
private ArrayList<GameActionListener> actionListeners; private ArrayList<GameActionListener> actionListeners;
private Script script = null; private Script script = null;
+13 -13
View File
@@ -19,21 +19,21 @@ public class BotMenu implements ActionListener {
JMenu debug = new JMenu("Debug"); JMenu debug = new JMenu("Debug");
JMenu actions = new JMenu("Actions"); JMenu actions = new JMenu("Actions");
JMenuItem enableActions = newItem("Enable Actions"); JMenuItem enableActions = newItem("Enable Actions");
JMenuItem animation = newItem("Animation"); JMenuItem animation = newItem("Animation");
JMenuItem bank = newItem("Bank"); JMenuItem bank = newItem("Bank");
JMenuItem flags = newItem("Collision flags"); JMenuItem flags = newItem("Collision flags");
JMenuItem items = newItem("GroundItems"); JMenuItem items = newItem("GroundItems");
JMenuItem interfaces = newItem("Interfaces"); JMenuItem interfaces = newItem("Interfaces");
JMenuItem inventory = newItem("Inventory"); JMenuItem inventory = newItem("Inventory");
JMenuItem map = newItem("Map"); JMenuItem map = newItem("Map");
JMenuItem messages = newItem("Messages"); JMenuItem messages = newItem("Messages");
JMenuItem mouse = newItem("Mouse"); JMenuItem mouse = newItem("Mouse");
JMenuItem npcs = newItem("Npcs"); JMenuItem npcs = newItem("Npcs");
JMenuItem objects = newItem("Objects"); JMenuItem objects = newItem("Objects");
JMenuItem players = newItem("Players"); JMenuItem players = newItem("Players");
debugger.addDebugger("Enable Actions", new DActions()); debugger.addDebugger("Enable Actions", new DActions());
debugger.addDebugger("Animation", new DAnimation()); debugger.addDebugger("Animation", new DAnimation());
@@ -68,7 +68,7 @@ public class BotMenu implements ActionListener {
ButtonGroup group = new ButtonGroup(); ButtonGroup group = new ButtonGroup();
for (int i = 0; i < MenuAction.getOutputs().length; i++) { for (int i = 0; i < MenuAction.getOutputs().length; i++) {
final int index = i; final int index = i;
JMenuItem debugOutput = new JRadioButtonMenuItem("Output: " + index); JMenuItem debugOutput = new JRadioButtonMenuItem("Output: " + index);
debugOutput.addActionListener(new ActionListener() { debugOutput.addActionListener(new ActionListener() {
@Override @Override