mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-03 08:39:09 +00:00
[CLEANUP] Code cleanup
This commit is contained in:
@@ -40,9 +40,11 @@ public class Loader extends ServerProvider {
|
||||
final ASMClassLoader classLoader = context.getASMClassLoader();
|
||||
final Class<?> clientClass = classLoader.loadClass(Context.getInstance().getServerProviderInfo().getClientClass());
|
||||
Object instance = clientClass.newInstance();
|
||||
|
||||
return (Applet) instance;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -100,4 +102,4 @@ public class Loader extends ServerProvider {
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ public interface Client {
|
||||
|
||||
CollisionMap[] getCollisionMap();
|
||||
|
||||
// args switched
|
||||
boolean walkTo(int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation);
|
||||
|
||||
boolean walkToPKH(boolean flag1, boolean flag2, int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation);
|
||||
|
||||
@@ -4,6 +4,5 @@ package org.rev317.min.accessors;
|
||||
public interface CollisionMap {
|
||||
|
||||
int[][] getFlags();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,5 +5,4 @@ public interface Deque {
|
||||
Node getHead();
|
||||
|
||||
Node getCurrent();
|
||||
|
||||
}
|
||||
|
||||
@@ -11,5 +11,4 @@ public interface Ground {
|
||||
SceneObjectTile getGroundItem();
|
||||
|
||||
SceneObjectTile[] getInteractiveObjects();
|
||||
|
||||
}
|
||||
|
||||
@@ -6,13 +6,7 @@ public interface Interface {
|
||||
|
||||
int[] getStackSizes();
|
||||
|
||||
/**
|
||||
* This is meant for the clients that have a long value as their stacksizes, simply because they have no logic...
|
||||
*
|
||||
* @return long version of #getStackSizes
|
||||
*/
|
||||
long[] getLongStackSizes();
|
||||
|
||||
String getMessage();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,5 @@ package org.rev317.min.accessors;
|
||||
public interface Item {
|
||||
|
||||
int getId();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,4 @@ package org.rev317.min.accessors;
|
||||
public interface Node {
|
||||
|
||||
Node getNext();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,5 +3,4 @@ package org.rev317.min.accessors;
|
||||
public interface Npc extends Character {
|
||||
|
||||
NpcDef getDef();
|
||||
|
||||
}
|
||||
@@ -4,4 +4,5 @@ public interface NpcDef {
|
||||
|
||||
int getId();
|
||||
|
||||
long getLongId();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.rev317.min.accessors;
|
||||
|
||||
public interface Player extends Character {
|
||||
|
||||
String getName();
|
||||
}
|
||||
|
||||
@@ -3,5 +3,4 @@ package org.rev317.min.accessors;
|
||||
public interface Scene {
|
||||
|
||||
Ground[][][] getGroundArray();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,5 +3,4 @@ package org.rev317.min.accessors;
|
||||
public interface SceneObjectTile {
|
||||
|
||||
int getHash();
|
||||
|
||||
}
|
||||
@@ -38,5 +38,4 @@ public final class GameActionEvent {
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,5 +29,4 @@ public final class MessageEvent {
|
||||
public final String getSender() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,4 @@ public interface Locatable {
|
||||
* @return distance from player to locatable
|
||||
*/
|
||||
int distanceTo();
|
||||
|
||||
}
|
||||
|
||||
@@ -14,5 +14,4 @@ public interface TileFlags {
|
||||
int UNKNOWN = 0x80000;
|
||||
int BLOCKED_TILE = 0x200000;
|
||||
int UNLOADED_TILE = 0x1000000;
|
||||
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ public class Bank {
|
||||
* @return <b>true</b> if successfully interacted
|
||||
*/
|
||||
public static boolean open() {
|
||||
|
||||
if (isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SceneObject bank = getBank();
|
||||
Npc banker = getBanker();
|
||||
|
||||
@@ -100,7 +100,6 @@ public class Bank {
|
||||
}
|
||||
|
||||
Item b = getItem(id);
|
||||
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
@@ -139,6 +138,7 @@ public class Bank {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ public class Bank {
|
||||
return 0;
|
||||
}
|
||||
Item item;
|
||||
|
||||
return ((item = getItem(id)) != null ? item.getStackSize() : 0);
|
||||
}
|
||||
|
||||
@@ -165,7 +166,6 @@ public class Bank {
|
||||
if (isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bank.getLocation().distanceTo() > 8) {
|
||||
bank.getLocation().walkTo();
|
||||
Time.sleep(new SleepCondition() {
|
||||
@@ -176,6 +176,7 @@ public class Bank {
|
||||
}, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
bank.interact(SceneObjects.Option.USE);
|
||||
}
|
||||
|
||||
@@ -187,6 +188,7 @@ public class Bank {
|
||||
if (!isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Menu.sendAction(200, -1, -1, settings.get("button_close_bank"));
|
||||
}
|
||||
|
||||
@@ -229,6 +231,7 @@ public class Bank {
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getItems();
|
||||
}
|
||||
|
||||
@@ -241,6 +244,7 @@ public class Bank {
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getStackSizes();
|
||||
}
|
||||
|
||||
@@ -253,6 +257,7 @@ public class Bank {
|
||||
if (!isOpen()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<Item> items = new ArrayList<Item>();
|
||||
int[] ids = getBankItemIDs();
|
||||
int[] stacks = getBankStacks();
|
||||
@@ -263,6 +268,7 @@ public class Bank {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items.toArray(new Item[items.size()]);
|
||||
}
|
||||
|
||||
@@ -275,6 +281,7 @@ public class Bank {
|
||||
if (!isOpen()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int[] items;
|
||||
return ((items = getBankItemIDs()) != null ? items.length : 0);
|
||||
}
|
||||
@@ -287,5 +294,4 @@ public class Bank {
|
||||
public static boolean isOpen() {
|
||||
return Loader.getClient().getOpenInterfaceId() == settings.get("bank_interface_id");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Calculations {
|
||||
public static final double distanceBetween(Tile a, Tile b) {
|
||||
int x = b.getX() - a.getX();
|
||||
int y = b.getY() - a.getY();
|
||||
|
||||
return Math.sqrt((x * x) + (y * y));
|
||||
}
|
||||
|
||||
@@ -145,6 +146,7 @@ public class Calculations {
|
||||
dist[curr_x + 1][curr_y + 1] = cost;
|
||||
}
|
||||
}
|
||||
|
||||
return foundPath ? dist[curr_x][curr_y] : -1;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
@@ -185,6 +187,7 @@ public class Calculations {
|
||||
if (foundPath(from, to)) {
|
||||
return dijkstraDist(from.getX(), from.getY(), to.getX(), to.getY(), false);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -200,6 +203,7 @@ public class Calculations {
|
||||
if (foundPath(from, to)) {
|
||||
return dijkstraDist(from.getX(), from.getY(), to.getX(), to.getY(), isObject);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -267,5 +271,4 @@ public class Calculations {
|
||||
public static int gainedPerHour(Timer runtime, int start, int current) {
|
||||
return runtime.getPerHour(gained(start, current));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class Equipment {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,9 +146,10 @@ public class Game {
|
||||
Time.sleep(new SleepCondition() {
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return isLoggedIn();
|
||||
return !isLoggedIn();
|
||||
}
|
||||
}, 2500);
|
||||
|
||||
return !isLoggedIn();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,10 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class GroundItems {
|
||||
private static final Comparator<GroundItem> NEAREST_SORTER = new Comparator<GroundItem>() {
|
||||
|
||||
@Override
|
||||
public int compare(GroundItem n1, GroundItem n2) {
|
||||
return n1.distanceTo() - n2.distanceTo();
|
||||
}
|
||||
|
||||
};
|
||||
private static final Filter<GroundItem> ALL_FILTER = new Filter<GroundItem>() {
|
||||
|
||||
@@ -60,6 +58,7 @@ public class GroundItems {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items.toArray(new GroundItem[items.size()]);
|
||||
}
|
||||
|
||||
@@ -75,10 +74,12 @@ public class GroundItems {
|
||||
if (client == null) {
|
||||
client = Loader.getClient();
|
||||
}
|
||||
|
||||
final Deque deque = client.getGroundItems()[Game.getPlane()][x][y];
|
||||
if (deque == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<GroundItem> list = new ArrayList<>();
|
||||
final Node holder = deque.getHead();
|
||||
Node curNode = holder.getNext();
|
||||
@@ -88,10 +89,12 @@ public class GroundItems {
|
||||
list.add(new GroundItem(groundItem, x, y));
|
||||
curNode = curNode.getNext();
|
||||
}
|
||||
|
||||
return list.toArray(new GroundItem[list.size()]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -125,6 +128,7 @@ public class GroundItems {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return objects[0];
|
||||
}
|
||||
|
||||
@@ -139,6 +143,7 @@ public class GroundItems {
|
||||
if (objects == null || objects.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return objects[0];
|
||||
}
|
||||
|
||||
@@ -151,6 +156,7 @@ public class GroundItems {
|
||||
public static final GroundItem[] getNearest(Filter<GroundItem> filter) {
|
||||
final GroundItem[] objects = getGroundItems(filter);
|
||||
Arrays.sort(objects, NEAREST_SORTER);
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
@@ -171,7 +177,6 @@ public class GroundItems {
|
||||
*/
|
||||
public static final GroundItem[] getNearest(final int... ids) {
|
||||
return getNearest(new Filter<GroundItem>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(GroundItem object) {
|
||||
for (final int id : ids) {
|
||||
@@ -179,9 +184,9 @@ public class GroundItems {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,7 +204,7 @@ public class GroundItems {
|
||||
|
||||
EXAMINE(settings.get("menu_ground_item_examine_interaction"));
|
||||
|
||||
int actionId;
|
||||
private int actionId;
|
||||
|
||||
Option(int actionId) {
|
||||
this.actionId = actionId;
|
||||
|
||||
@@ -40,9 +40,11 @@ public class Items {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException | ParseException ignored) {
|
||||
} catch (MalformedURLException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -60,8 +62,10 @@ public class Items {
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException | ParseException ignored) {
|
||||
} catch (MalformedURLException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@@ -85,8 +89,10 @@ public class Items {
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException | ParseException ignored) {
|
||||
} catch (MalformedURLException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@@ -110,8 +116,10 @@ public class Items {
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException | ParseException ignored) {
|
||||
} catch (MalformedURLException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@@ -130,7 +138,8 @@ public class Items {
|
||||
return price;
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException | ParseException ignored) {
|
||||
} catch (MalformedURLException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -181,7 +190,7 @@ public class Items {
|
||||
SEVENTH(settings.get("menu_item_seventh_interaction")),
|
||||
USE_WITH(settings.get("menu_item_seventh_interaction"));
|
||||
|
||||
int actionId;
|
||||
private int actionId;
|
||||
|
||||
Option(int actionId) {
|
||||
this.actionId = actionId;
|
||||
|
||||
@@ -108,6 +108,7 @@ public class Menu {
|
||||
actionId = 478;
|
||||
break;
|
||||
}
|
||||
|
||||
sendAction(actionId, character.getIndex(), 0, 0);
|
||||
}
|
||||
|
||||
@@ -118,10 +119,8 @@ public class Menu {
|
||||
* @param action
|
||||
* @param interfaceParentId
|
||||
*/
|
||||
public static void transformItem(Item item, Items.Option action,
|
||||
int interfaceParentId) {
|
||||
sendAction(action.getActionId(), item.getId() - 1, item.getSlot(),
|
||||
interfaceParentId);
|
||||
public static void transformItem(Item item, Items.Option action, int interfaceParentId) {
|
||||
sendAction(action.getActionId(), item.getId() - 1, item.getSlot(), interfaceParentId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,8 +131,7 @@ public class Menu {
|
||||
* @param interfaceParentId
|
||||
* @deprecated
|
||||
*/
|
||||
public static void transformItem(Item item, int actionIndex,
|
||||
int interfaceParentId) {
|
||||
public static void transformItem(Item item, int actionIndex, int interfaceParentId) {
|
||||
int actionId = Items.Option.TRANSFORM_FIRST.getActionId();
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
@@ -264,8 +262,7 @@ public class Menu {
|
||||
* @param item
|
||||
*/
|
||||
public static void drop(Item item) {
|
||||
sendAction(settings.get("button_drop_item"), item.getId() - 1, item.getSlot(),
|
||||
settings.get("inventory_index"));
|
||||
sendAction(settings.get("button_drop_item"), item.getId() - 1, item.getSlot(), settings.get("inventory_index"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,7 +320,6 @@ public class Menu {
|
||||
}
|
||||
client.getMenuActionId()[index] = action;
|
||||
|
||||
|
||||
client.doAction(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public class Npcs {
|
||||
npcList.add(npc);
|
||||
}
|
||||
}
|
||||
|
||||
return npcList.toArray(new Npc[npcList.size()]);
|
||||
}
|
||||
|
||||
@@ -77,6 +78,7 @@ public class Npcs {
|
||||
if (npcs == null || npcs.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return npcs[0];
|
||||
}
|
||||
|
||||
@@ -91,6 +93,7 @@ public class Npcs {
|
||||
if (npcs == null || npcs.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return npcs[0];
|
||||
}
|
||||
|
||||
@@ -103,6 +106,7 @@ public class Npcs {
|
||||
public static final Npc[] getNearest(final Filter<Npc> filter) {
|
||||
final Npc[] npcs = getNpcs(filter);
|
||||
Arrays.sort(npcs, NEAREST_SORTER);
|
||||
|
||||
return npcs;
|
||||
}
|
||||
|
||||
@@ -124,11 +128,13 @@ public class Npcs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
Arrays.sort(npcs, NEAREST_SORTER);
|
||||
|
||||
return npcs;
|
||||
}
|
||||
|
||||
@@ -168,7 +174,7 @@ public class Npcs {
|
||||
|
||||
EXAMINE(settings.get("menu_character_examine"));
|
||||
|
||||
int actionId;
|
||||
private int actionId;
|
||||
|
||||
Option(int actionId) {
|
||||
this.actionId = actionId;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Players {
|
||||
*/
|
||||
public static final Player[] getPlayers(final Filter<Player> filter) {
|
||||
final Client client = Loader.getClient();
|
||||
ArrayList<Player> playerList = new ArrayList<Player>();
|
||||
ArrayList<Player> playerList = new ArrayList<>();
|
||||
final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers();
|
||||
for (int i = 0; i < accPlayers.length; i++) {
|
||||
if (accPlayers[i] == null) {
|
||||
@@ -54,6 +54,7 @@ public class Players {
|
||||
playerList.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return playerList.toArray(new Player[playerList.size()]);
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ public class Players {
|
||||
|
||||
EXAMINE(settings.get("menu_character_examine"));
|
||||
|
||||
int actionId;
|
||||
private int actionId;
|
||||
|
||||
Option(int actionId) {
|
||||
this.actionId = actionId;
|
||||
|
||||
@@ -52,6 +52,7 @@ public class Prayer {
|
||||
prayers.add(curse);
|
||||
}
|
||||
}
|
||||
|
||||
return prayers.toArray(new Book[prayers.size()]);
|
||||
}
|
||||
|
||||
@@ -225,12 +226,12 @@ public class Prayer {
|
||||
}
|
||||
|
||||
public interface Book {
|
||||
public int getSetting();
|
||||
int getSetting();
|
||||
|
||||
public int getAction();
|
||||
int getAction();
|
||||
|
||||
public int getLevel();
|
||||
int getLevel();
|
||||
|
||||
public String getName();
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,16 +40,17 @@ public class SceneObjects {
|
||||
* @return scene objects
|
||||
*/
|
||||
public static final SceneObject[] getSceneObjects(Filter<SceneObject> filter) {
|
||||
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
||||
ArrayList<SceneObject> sceneObjects = new ArrayList<>();
|
||||
for (int x = 0; x < 104; x++) {
|
||||
for (int y = 0; y < 104; y++) {
|
||||
final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true);
|
||||
final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y);
|
||||
if (sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) {
|
||||
sceneObjects.add(sceneObjectAtTile);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ public class SceneObjects {
|
||||
public static final SceneObject[] getNearest(Filter<SceneObject> filter) {
|
||||
final SceneObject[] objects = getSceneObjects(filter);
|
||||
Arrays.sort(objects, NEAREST_SORTER);
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
@@ -99,6 +101,7 @@ public class SceneObjects {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -107,7 +110,6 @@ public class SceneObjects {
|
||||
|
||||
public static final SceneObject getClosest(final int... ids) {
|
||||
SceneObject[] nearestObjects = getNearest(new Filter<SceneObject>() {
|
||||
|
||||
@Override
|
||||
public boolean accept(SceneObject object) {
|
||||
for (final int id : ids) {
|
||||
@@ -115,34 +117,37 @@ public class SceneObjects {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
if (nearestObjects == null || nearestObjects.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return nearestObjects[0];
|
||||
}
|
||||
|
||||
private static SceneObject getSceneObjectAtTile(int x, int y, boolean useCached) {
|
||||
private static SceneObject getSceneObjectAtTile(int x, int y) {
|
||||
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
|
||||
if (sceneTile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects();
|
||||
if (interactiveObjects != null) {
|
||||
for (final SceneObjectTile interactiveObject : interactiveObjects) {
|
||||
// get top
|
||||
if (interactiveObject != null) {
|
||||
return new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SceneObjectTile sceneObjectTile = sceneTile.getWallObject();
|
||||
if (sceneObjectTile != null) {
|
||||
return new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -152,15 +157,16 @@ public class SceneObjects {
|
||||
* @return every loaded scene object in game
|
||||
*/
|
||||
public static final SceneObject[] getAllSceneObjects() {
|
||||
ArrayList<SceneObject> sceneObjects = new ArrayList<SceneObject>();
|
||||
ArrayList<SceneObject> sceneObjects = new ArrayList<>();
|
||||
for (int x = 0; x < 104; x++) {
|
||||
for (int y = 0; y < 104; y++) {
|
||||
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true);
|
||||
final Collection<SceneObject> sceneObjectsAtTile = getSceneObjectsAtTile(x, y);
|
||||
if (sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) {
|
||||
sceneObjects.addAll(sceneObjectsAtTile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sceneObjects.toArray(new SceneObject[sceneObjects.size()]);
|
||||
}
|
||||
|
||||
@@ -169,10 +175,9 @@ public class SceneObjects {
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param useCached
|
||||
* @return array of sceneobjects, or null if there aren't any
|
||||
*/
|
||||
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y, boolean useCached) {
|
||||
public static final Collection<SceneObject> getSceneObjectsAtTile(int x, int y) {
|
||||
Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y];
|
||||
ArrayList<SceneObject> sceneObjects = null;
|
||||
if (sceneTile != null) {
|
||||
@@ -219,9 +224,11 @@ public class SceneObjects {
|
||||
sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDITEM));
|
||||
}
|
||||
}
|
||||
|
||||
return sceneObjects;
|
||||
}
|
||||
|
||||
|
||||
public enum Option {
|
||||
FIRST(settings.get("menu_scene_object_first_interaction")),
|
||||
TALK_TO(settings.get("menu_scene_object_first_interaction")),
|
||||
@@ -253,7 +260,7 @@ public class SceneObjects {
|
||||
|
||||
EXAMINE(settings.get("menu_scene_object_examine"));
|
||||
|
||||
int actionId;
|
||||
private int actionId;
|
||||
|
||||
Option(int actionId) {
|
||||
this.actionId = actionId;
|
||||
@@ -263,6 +270,4 @@ public class SceneObjects {
|
||||
return actionId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public enum Skill {
|
||||
if (level > 99 || level < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EXPERIENCE[level];
|
||||
}
|
||||
|
||||
@@ -81,6 +82,7 @@ public enum Skill {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,6 +97,7 @@ public enum Skill {
|
||||
if (level >= 99 || level < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EXPERIENCE[(level + 1)] - getCurrentExperience(index);
|
||||
}
|
||||
|
||||
@@ -111,11 +114,12 @@ public enum Skill {
|
||||
|| nextLevel < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Deprecated use Skill.ordinal() instead Returns the skill's index.
|
||||
* @deprecated use Skill.ordinal() instead Returns the skill's index.
|
||||
*/
|
||||
public int getIndex() {
|
||||
return ordinal();
|
||||
@@ -125,22 +129,21 @@ public enum Skill {
|
||||
* Returns the name of the skill.
|
||||
*/
|
||||
public final String getName() {
|
||||
return Character.toUpperCase(name().charAt(0))
|
||||
+ name().toLowerCase().substring(1);
|
||||
return Character.toUpperCase(name().charAt(0)) + name().toLowerCase().substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current experience.
|
||||
*/
|
||||
public final int getExperience() {
|
||||
return Skill.getCurrentExperience(this.getIndex());
|
||||
return Skill.getCurrentExperience(this.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the real level.
|
||||
*/
|
||||
public final int getRealLevel() {
|
||||
return Skill.getRealLevel(this.getIndex());
|
||||
return Skill.getRealLevel(this.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,21 +151,21 @@ public enum Skill {
|
||||
* stat; it will return the buffed level.) Done by Bears
|
||||
*/
|
||||
public final int getLevel() {
|
||||
return Skill.getCurrentLevel(this.getIndex());
|
||||
return Skill.getCurrentLevel(this.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remaining experience until the next level.
|
||||
*/
|
||||
public final int getRemaining() {
|
||||
return Skill.getRemainingExperience(this.getIndex());
|
||||
return Skill.getRemainingExperience(this.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percentage until the next level.
|
||||
*/
|
||||
public final int getPercentage() {
|
||||
return Skill.getPercentToNextLevel(this.getIndex());
|
||||
return Skill.getPercentToNextLevel(this.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +173,6 @@ public enum Skill {
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / "
|
||||
+ this.getRealLevel() + "]";
|
||||
return "Skill: [" + this.getName() + ": " + this.getLevel() + " / " + this.getRealLevel() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class Walking {
|
||||
if (tilePath.hasReached()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
tilePath.traverse();
|
||||
return false;
|
||||
}
|
||||
@@ -61,8 +62,7 @@ public class Walking {
|
||||
tile = new Tile((loc.getX() + tile.getX()) / 2,
|
||||
(loc.getY() + tile.getY()) / 2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,10 @@ public class Area {
|
||||
*/
|
||||
public Tile[] getPoints() {
|
||||
Tile[] tiles = new Tile[p.npoints];
|
||||
for (int i = 0; i < tiles.length; i++)
|
||||
for (int i = 0; i < tiles.length; i++) {
|
||||
tiles[i] = new Tile(p.xpoints[i], p.ypoints[i]);
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
@@ -76,6 +78,7 @@ public class Area {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return t.toArray(new Tile[t.size()]);
|
||||
}
|
||||
|
||||
@@ -107,7 +110,7 @@ public class Area {
|
||||
result = !result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ public class Character implements Locatable {
|
||||
return Players.getMyPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -161,26 +162,32 @@ public class Character implements Locatable {
|
||||
result = prime * result
|
||||
+ ((accessor == null) ? 0 : accessor.hashCode());
|
||||
result = prime * result + index;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Character other = (Character) obj;
|
||||
if (accessor == null) {
|
||||
if (other.accessor != null)
|
||||
if (other.accessor != null) {
|
||||
return false;
|
||||
} else if (!accessor.equals(other.accessor))
|
||||
}
|
||||
} else if (!accessor.equals(other.accessor)) {
|
||||
return false;
|
||||
if (index != other.index)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return index == other.index;
|
||||
}
|
||||
|
||||
public org.rev317.min.accessors.Character getAccessor() {
|
||||
|
||||
@@ -100,5 +100,4 @@ public class GroundItem implements Locatable {
|
||||
public RefClass getRefClass() {
|
||||
return new RefClass(this.accessor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,5 +42,4 @@ public final class Npc extends Character {
|
||||
public void interact(Npcs.Option option) {
|
||||
Menu.interact(this, option);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,12 +23,13 @@ public class NpcDef {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private long getLongId() {
|
||||
if (accessor != null) {
|
||||
if (accessor.getId() < Integer.MAX_VALUE) {
|
||||
if (accessor.getLongId() < Integer.MAX_VALUE) {
|
||||
return (long) accessor.getId();
|
||||
}
|
||||
}
|
||||
@@ -45,5 +46,4 @@ public class NpcDef {
|
||||
public RefClass getRefClass() {
|
||||
return new RefClass(this.accessor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,5 +121,4 @@ public class SceneObject implements Locatable {
|
||||
public String toString() {
|
||||
return String.format("[ID: %d, X: %d, Y: %d]", getId(), getLocalRegionX(), getLocalRegionY());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ public final class Tile implements TileFlags, Locatable {
|
||||
hash = 31 * hash + this.x;
|
||||
hash = 31 * hash + this.y;
|
||||
hash = 31 * hash + this.z;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -171,5 +172,4 @@ public final class Tile implements TileFlags, Locatable {
|
||||
public Tile getLocation() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,11 +27,12 @@ public class TilePath {
|
||||
*/
|
||||
public final Tile getNextTile() {
|
||||
Tile next = null;
|
||||
for (int x = 0; x < tiles.length; x++) {
|
||||
if (tiles[x].isOnMinimap()) {
|
||||
next = tiles[x];
|
||||
for (Tile tile : tiles) {
|
||||
if (tile.isOnMinimap()) {
|
||||
next = tile;
|
||||
}
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
@@ -61,6 +62,7 @@ public class TilePath {
|
||||
if (next == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
next.walkTo();
|
||||
}
|
||||
|
||||
@@ -71,10 +73,10 @@ public class TilePath {
|
||||
*/
|
||||
public final TilePath reverse() {
|
||||
Tile[] newTiles = new Tile[tiles.length];
|
||||
for (int i = 0; i < tiles.length; i++)
|
||||
for (int i = 0; i < tiles.length; i++) {
|
||||
newTiles[i] = tiles[tiles.length - i - 1];
|
||||
}
|
||||
|
||||
return new TilePath(newTiles);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ import org.rev317.min.debug.DActions;
|
||||
import org.rev317.min.script.ScriptEngine;
|
||||
|
||||
/**
|
||||
* @author Everel
|
||||
* @author JKetelaar
|
||||
* @author Matt123337
|
||||
* @author Everel, JKetelaar, Matt123337
|
||||
*/
|
||||
public class MenuAction {
|
||||
|
||||
|
||||
@@ -10,5 +10,4 @@ public class MessageCallback {
|
||||
final MessageEvent messageEvent = new MessageEvent(type, name, message);
|
||||
ScriptEngine.getInstance().dispatch(messageEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ public class DActions extends AbstractDebugger {
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,5 +23,4 @@ public class DAnimation extends AbstractDebugger {
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class DBank extends AbstractDebugger {
|
||||
if (!Bank.isOpen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item[] items;
|
||||
if ((items = Bank.getBankItems()) != null) {
|
||||
for (int i = items.length - 1; i >= 0; i--) {
|
||||
@@ -32,5 +33,4 @@ public class DBank extends AbstractDebugger {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,5 +35,4 @@ public class DCollisionFlags extends AbstractDebugger {
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,5 +28,4 @@ public class DGroundItems extends AbstractDebugger {
|
||||
System.out.println("ID: " + item.getId() + " Location: " + item.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,5 +26,4 @@ public class DInterfaces extends AbstractDebugger {
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class DInventory extends AbstractDebugger {
|
||||
return item.getId();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,4 @@ public class DMap extends AbstractDebugger {
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ public class DMouse extends AbstractDebugger {
|
||||
public void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,5 @@ public class DNpcs extends AbstractDebugger {
|
||||
for (Npc n : Npcs.getNearest()) {
|
||||
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,5 @@ public class DPlayers extends AbstractDebugger {
|
||||
|
||||
@Override
|
||||
public void paint(Graphics graphics) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,4 @@ public class DSceneObjects extends AbstractDebugger {
|
||||
" Distance: " + objects[i].distanceTo());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.HashMap;
|
||||
* @author matt123337
|
||||
*/
|
||||
public class ScriptEngine {
|
||||
private static HashMap<Context, ScriptEngine> instances = new HashMap<Context, ScriptEngine>();
|
||||
private static HashMap<Context, ScriptEngine> instances = new HashMap<>();
|
||||
private ArrayList<MouseListener> mouseListeners;
|
||||
private ArrayList<MouseMotionListener> mouseMotionListeners;
|
||||
private ArrayList<MessageListener> messageListeners;
|
||||
@@ -29,10 +29,10 @@ public class ScriptEngine {
|
||||
private Script script = null;
|
||||
|
||||
private ScriptEngine() {
|
||||
this.mouseListeners = new ArrayList<MouseListener>();
|
||||
this.mouseMotionListeners = new ArrayList<MouseMotionListener>();
|
||||
this.messageListeners = new ArrayList<MessageListener>();
|
||||
this.actionListeners = new ArrayList<GameActionListener>();
|
||||
this.mouseListeners = new ArrayList<>();
|
||||
this.mouseMotionListeners = new ArrayList<>();
|
||||
this.messageListeners = new ArrayList<>();
|
||||
this.actionListeners = new ArrayList<>();
|
||||
instances.put(Context.getInstance(), this);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ public class ScriptEngine {
|
||||
if (script instanceof Paintable) {
|
||||
Context.getInstance().removePaintable((Paintable) script);
|
||||
}
|
||||
|
||||
this.script = null;
|
||||
}
|
||||
|
||||
@@ -134,6 +135,7 @@ public class ScriptEngine {
|
||||
if (!(event instanceof MouseEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MouseEvent e = (MouseEvent) event;
|
||||
for (final MouseListener m : mouseListeners) {
|
||||
switch (e.getID()) {
|
||||
@@ -176,6 +178,4 @@ public class ScriptEngine {
|
||||
a.onGameAction(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ public class BotMenu implements ActionListener {
|
||||
private JMenuItem newItem(String name) {
|
||||
JMenuItem item = new JCheckBoxMenuItem(name);
|
||||
item.addActionListener(this);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -94,5 +95,4 @@ public class BotMenu implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Context.getInstance().getPaintDebugger().toggle(e.getActionCommand());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user