From 2da56102c9836b810a39f77cf1e26693490a3c63 Mon Sep 17 00:00:00 2001 From: JKetelaar Date: Sun, 13 Sep 2015 22:55:23 +0200 Subject: [PATCH] Added Messages debugging and moved to Maven --- pom.xml | 53 ++ .../java}/org/rev317/min/Loader.java | 204 +++--- .../org/rev317/min/accessors/Character.java | 42 +- .../org/rev317/min/accessors/Client.java | 114 ++-- .../rev317/min/accessors/CollisionMap.java | 18 +- .../java}/org/rev317/min/accessors/Deque.java | 18 +- .../org/rev317/min/accessors/Ground.java | 30 +- .../org/rev317/min/accessors/Interface.java | 22 +- .../java}/org/rev317/min/accessors/Item.java | 16 +- .../java}/org/rev317/min/accessors/Node.java | 14 +- .../java}/org/rev317/min/accessors/Npc.java | 12 +- .../org/rev317/min/accessors/NpcDef.java | 14 +- .../org/rev317/min/accessors/Player.java | 10 +- .../java}/org/rev317/min/accessors/Scene.java | 14 +- .../rev317/min/accessors/SceneObjectTile.java | 12 +- .../min/api/events/GameActionEvent.java | 0 .../rev317/min/api/events/MessageEvent.java | 64 +- .../events/listeners/GameActionListener.java | 0 .../api/events/listeners/MessageListener.java | 24 +- .../rev317/min/api/interfaces/Locatable.java | 48 +- .../rev317/min/api/interfaces/TileFlags.java | 36 +- .../org/rev317/min/api/methods/Bank.java | 586 ++++++++--------- .../rev317/min/api/methods/Calculations.java | 316 ++++----- .../org/rev317/min/api/methods/Game.java | 266 ++++---- .../rev317/min/api/methods/GroundItems.java | 350 +++++----- .../rev317/min/api/methods/Interfaces.java | 0 .../org/rev317/min/api/methods/Inventory.java | 598 +++++++++--------- .../org/rev317/min/api/methods/Items.java | 0 .../org/rev317/min/api/methods/Menu.java | 0 .../org/rev317/min/api/methods/Npcs.java | 362 +++++------ .../org/rev317/min/api/methods/Players.java | 254 ++++---- .../org/rev317/min/api/methods/Prayer.java | 0 .../rev317/min/api/methods/SceneObjects.java | 542 ++++++++-------- .../org/rev317/min/api/methods/Skill.java | 366 +++++------ .../org/rev317/min/api/methods/Trading.java | 0 .../org/rev317/min/api/methods/Walking.java | 124 ++-- .../org/rev317/min/api/wrappers/Area.java | 0 .../rev317/min/api/wrappers/Character.java | 380 +++++------ .../rev317/min/api/wrappers/GroundItem.java | 204 +++--- .../org/rev317/min/api/wrappers/Item.java | 204 +++--- .../org/rev317/min/api/wrappers/Npc.java | 92 +-- .../org/rev317/min/api/wrappers/NpcDef.java | 68 +- .../org/rev317/min/api/wrappers/Player.java | 54 +- .../rev317/min/api/wrappers/SceneObject.java | 252 ++++---- .../org/rev317/min/api/wrappers/Tile.java | 352 +++++------ .../org/rev317/min/api/wrappers/TilePath.java | 160 ++--- .../org/rev317/min/callback/MenuAction.java | 72 +-- .../rev317/min/callback/MessageCallback.java | 28 +- .../java}/org/rev317/min/debug/DActions.java | 56 +- .../org/rev317/min/debug/DAnimation.java | 54 +- .../java}/org/rev317/min/debug/DBank.java | 0 .../org/rev317/min/debug/DCollisionFlags.java | 78 +-- .../org/rev317/min/debug/DGroundItems.java | 64 +- .../org/rev317/min/debug/DInterfaces.java | 60 +- .../org/rev317/min/debug/DInventory.java | 0 .../java}/org/rev317/min/debug/DMap.java | 62 +- .../java}/org/rev317/min/debug/DMessages.java | 0 .../java}/org/rev317/min/debug/DMouse.java | 0 .../java}/org/rev317/min/debug/DNpcs.java | 58 +- .../java}/org/rev317/min/debug/DPlayers.java | 0 .../org/rev317/min/debug/DSceneObjects.java | 70 +- .../org/rev317/min/script/ScriptEngine.java | 362 +++++------ .../java}/org/rev317/min/ui/BotMenu.java | 154 ++--- target/maven-archiver/pom.properties | 5 + 64 files changed, 3738 insertions(+), 3680 deletions(-) create mode 100644 pom.xml rename src/{ => main/java}/org/rev317/min/Loader.java (96%) rename src/{ => main/java}/org/rev317/min/accessors/Character.java (93%) rename src/{ => main/java}/org/rev317/min/accessors/Client.java (95%) rename src/{ => main/java}/org/rev317/min/accessors/CollisionMap.java (92%) rename src/{ => main/java}/org/rev317/min/accessors/Deque.java (93%) rename src/{ => main/java}/org/rev317/min/accessors/Ground.java (95%) rename src/{ => main/java}/org/rev317/min/accessors/Interface.java (93%) rename src/{ => main/java}/org/rev317/min/accessors/Item.java (91%) rename src/{ => main/java}/org/rev317/min/accessors/Node.java (92%) rename src/{ => main/java}/org/rev317/min/accessors/Npc.java (94%) rename src/{ => main/java}/org/rev317/min/accessors/NpcDef.java (92%) rename src/{ => main/java}/org/rev317/min/accessors/Player.java (95%) rename src/{ => main/java}/org/rev317/min/accessors/Scene.java (93%) rename src/{ => main/java}/org/rev317/min/accessors/SceneObjectTile.java (94%) rename src/{ => main/java}/org/rev317/min/api/events/GameActionEvent.java (100%) rename src/{ => main/java}/org/rev317/min/api/events/MessageEvent.java (95%) rename src/{ => main/java}/org/rev317/min/api/events/listeners/GameActionListener.java (100%) rename src/{ => main/java}/org/rev317/min/api/events/listeners/MessageListener.java (94%) rename src/{ => main/java}/org/rev317/min/api/interfaces/Locatable.java (94%) rename src/{ => main/java}/org/rev317/min/api/interfaces/TileFlags.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Bank.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Calculations.java (97%) rename src/{ => main/java}/org/rev317/min/api/methods/Game.java (95%) rename src/{ => main/java}/org/rev317/min/api/methods/GroundItems.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Interfaces.java (100%) rename src/{ => main/java}/org/rev317/min/api/methods/Inventory.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Items.java (100%) rename src/{ => main/java}/org/rev317/min/api/methods/Menu.java (100%) rename src/{ => main/java}/org/rev317/min/api/methods/Npcs.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Players.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Prayer.java (100%) rename src/{ => main/java}/org/rev317/min/api/methods/SceneObjects.java (97%) rename src/{ => main/java}/org/rev317/min/api/methods/Skill.java (96%) rename src/{ => main/java}/org/rev317/min/api/methods/Trading.java (100%) rename src/{ => main/java}/org/rev317/min/api/methods/Walking.java (96%) rename src/{ => main/java}/org/rev317/min/api/wrappers/Area.java (100%) rename src/{ => main/java}/org/rev317/min/api/wrappers/Character.java (95%) rename src/{ => main/java}/org/rev317/min/api/wrappers/GroundItem.java (94%) rename src/{ => main/java}/org/rev317/min/api/wrappers/Item.java (94%) rename src/{ => main/java}/org/rev317/min/api/wrappers/Npc.java (95%) rename src/{ => main/java}/org/rev317/min/api/wrappers/NpcDef.java (94%) rename src/{ => main/java}/org/rev317/min/api/wrappers/Player.java (95%) rename src/{ => main/java}/org/rev317/min/api/wrappers/SceneObject.java (95%) rename src/{ => main/java}/org/rev317/min/api/wrappers/Tile.java (95%) rename src/{ => main/java}/org/rev317/min/api/wrappers/TilePath.java (95%) rename src/{ => main/java}/org/rev317/min/callback/MenuAction.java (97%) rename src/{ => main/java}/org/rev317/min/callback/MessageCallback.java (96%) rename src/{ => main/java}/org/rev317/min/debug/DActions.java (94%) rename src/{ => main/java}/org/rev317/min/debug/DAnimation.java (95%) rename src/{ => main/java}/org/rev317/min/debug/DBank.java (100%) rename src/{ => main/java}/org/rev317/min/debug/DCollisionFlags.java (97%) rename src/{ => main/java}/org/rev317/min/debug/DGroundItems.java (95%) rename src/{ => main/java}/org/rev317/min/debug/DInterfaces.java (95%) rename src/{ => main/java}/org/rev317/min/debug/DInventory.java (100%) rename src/{ => main/java}/org/rev317/min/debug/DMap.java (95%) rename src/{ => main/java}/org/rev317/min/debug/DMessages.java (100%) rename src/{ => main/java}/org/rev317/min/debug/DMouse.java (100%) rename src/{ => main/java}/org/rev317/min/debug/DNpcs.java (95%) rename src/{ => main/java}/org/rev317/min/debug/DPlayers.java (100%) rename src/{ => main/java}/org/rev317/min/debug/DSceneObjects.java (96%) rename src/{ => main/java}/org/rev317/min/script/ScriptEngine.java (96%) rename src/{ => main/java}/org/rev317/min/ui/BotMenu.java (97%) create mode 100644 target/maven-archiver/pom.properties diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..726ae44 --- /dev/null +++ b/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + + org.parabot + 317-API-Minified + 1.0 + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + 1.7 + + + + + git-parabot + Parabot's Git based repo + https://github.com/parabot/Maven-Repository/raw/master/ + + + + + + org.parabot + client + 2.2 + + + + + 317-API-Minified + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + ${jdk.version} + ${jdk.version} + + + + + \ No newline at end of file diff --git a/src/org/rev317/min/Loader.java b/src/main/java/org/rev317/min/Loader.java similarity index 96% rename from src/org/rev317/min/Loader.java rename to src/main/java/org/rev317/min/Loader.java index ace2c7e..bdced28 100644 --- a/src/org/rev317/min/Loader.java +++ b/src/main/java/org/rev317/min/Loader.java @@ -1,103 +1,103 @@ -package org.rev317.min; - -import org.parabot.core.Context; -import org.parabot.core.Core; -import org.parabot.core.Directories; -import org.parabot.core.asm.ASMClassLoader; -import org.parabot.core.asm.adapters.AddInterfaceAdapter; -import org.parabot.core.asm.hooks.HookFile; -import org.parabot.core.desc.ServerProviderInfo; -import org.parabot.core.ui.components.VerboseLoader; -import org.parabot.environment.api.utils.WebUtil; -import org.parabot.environment.scripts.Script; -import org.parabot.environment.servers.ServerManifest; -import org.parabot.environment.servers.ServerProvider; -import org.parabot.environment.servers.Type; -import org.rev317.min.accessors.Client; -import org.rev317.min.script.ScriptEngine; -import org.rev317.min.ui.BotMenu; - -import javax.swing.*; -import java.applet.Applet; -import java.io.File; -import java.net.URL; - -/** -* @author Everel, JKetelaar -*/ -@ServerManifest(author = "Everel & JKetelaar", name = "Server name here", type = Type.INJECTION, version = 2.1) -public class Loader extends ServerProvider { - private boolean extended = true; - - public static Client getClient() { - return (Client) Context.getInstance().getClient(); - } - - @Override - public Applet fetchApplet() { - try { - final Context context = Context.getInstance(); - 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; - } - } - - @Override - public URL getJar() { - ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo(); - - File target = new File(Directories.getCachePath(), serverProvider.getClientCRC32() + ".jar"); - if (!target.exists()) { - WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get()); - } - - return WebUtil.toURL(target); - } - - @Override - public void addMenuItems(JMenuBar bar) { - new BotMenu(bar); - } - - @Override - public void injectHooks() { - AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/"); - try { - super.injectHooks(); - } catch (Exception e) { - if (Core.inVerboseMode()){ - e.printStackTrace(); - } - this.extended = false; - super.injectHooks(); - } - } - - @Override - public void initScript(Script script) { - ScriptEngine.getInstance().setScript(script); - ScriptEngine.getInstance().init(); - } - - @Override - public HookFile getHookFile() { - if (this.extended){ - return new HookFile(Context.getInstance().getServerProviderInfo().getExtendedHookFile(), HookFile.TYPE_XML); - }else{ - return new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML); - } - } - - public void unloadScript(Script script) { - ScriptEngine.getInstance().unload(); - } - - @Override - public void init() { - } +package org.rev317.min; + +import org.parabot.core.Context; +import org.parabot.core.Core; +import org.parabot.core.Directories; +import org.parabot.core.asm.ASMClassLoader; +import org.parabot.core.asm.adapters.AddInterfaceAdapter; +import org.parabot.core.asm.hooks.HookFile; +import org.parabot.core.desc.ServerProviderInfo; +import org.parabot.core.ui.components.VerboseLoader; +import org.parabot.environment.api.utils.WebUtil; +import org.parabot.environment.scripts.Script; +import org.parabot.environment.servers.ServerManifest; +import org.parabot.environment.servers.ServerProvider; +import org.parabot.environment.servers.Type; +import org.rev317.min.accessors.Client; +import org.rev317.min.script.ScriptEngine; +import org.rev317.min.ui.BotMenu; + +import javax.swing.*; +import java.applet.Applet; +import java.io.File; +import java.net.URL; + +/** +* @author Everel, JKetelaar +*/ +@ServerManifest(author = "Everel & JKetelaar", name = "Server name here", type = Type.INJECTION, version = 2.1) +public class Loader extends ServerProvider { + private boolean extended = true; + + public static Client getClient() { + return (Client) Context.getInstance().getClient(); + } + + @Override + public Applet fetchApplet() { + try { + final Context context = Context.getInstance(); + 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; + } + } + + @Override + public URL getJar() { + ServerProviderInfo serverProvider = Context.getInstance().getServerProviderInfo(); + + File target = new File(Directories.getCachePath(), serverProvider.getClientCRC32() + ".jar"); + if (!target.exists()) { + WebUtil.downloadFile(serverProvider.getClient(), target, VerboseLoader.get()); + } + + return WebUtil.toURL(target); + } + + @Override + public void addMenuItems(JMenuBar bar) { + new BotMenu(bar); + } + + @Override + public void injectHooks() { + AddInterfaceAdapter.setAccessorPackage("org/rev317/min/accessors/"); + try { + super.injectHooks(); + } catch (Exception e) { + if (Core.inVerboseMode()){ + e.printStackTrace(); + } + this.extended = false; + super.injectHooks(); + } + } + + @Override + public void initScript(Script script) { + ScriptEngine.getInstance().setScript(script); + ScriptEngine.getInstance().init(); + } + + @Override + public HookFile getHookFile() { + if (this.extended){ + return new HookFile(Context.getInstance().getServerProviderInfo().getExtendedHookFile(), HookFile.TYPE_XML); + }else{ + return new HookFile(Context.getInstance().getServerProviderInfo().getHookFile(), HookFile.TYPE_XML); + } + } + + public void unloadScript(Script script) { + ScriptEngine.getInstance().unload(); + } + + @Override + public void init() { + } } \ No newline at end of file diff --git a/src/org/rev317/min/accessors/Character.java b/src/main/java/org/rev317/min/accessors/Character.java similarity index 93% rename from src/org/rev317/min/accessors/Character.java rename to src/main/java/org/rev317/min/accessors/Character.java index 4e9ac2a..148f9ab 100644 --- a/src/org/rev317/min/accessors/Character.java +++ b/src/main/java/org/rev317/min/accessors/Character.java @@ -1,21 +1,21 @@ -package org.rev317.min.accessors; - -public interface Character { - - public int getX(); - - public int getY(); - - public int getAnimation(); - - public int getLoopCycleStatus(); - - public int getCurrentHealth(); - - public int getMaxHealth(); - - public int getInteractingEntity(); - - String getName(); -} - +package org.rev317.min.accessors; + +public interface Character { + + public int getX(); + + public int getY(); + + public int getAnimation(); + + public int getLoopCycleStatus(); + + public int getCurrentHealth(); + + public int getMaxHealth(); + + public int getInteractingEntity(); + + String getName(); +} + diff --git a/src/org/rev317/min/accessors/Client.java b/src/main/java/org/rev317/min/accessors/Client.java similarity index 95% rename from src/org/rev317/min/accessors/Client.java rename to src/main/java/org/rev317/min/accessors/Client.java index 415fd81..a5fb9f2 100644 --- a/src/org/rev317/min/accessors/Client.java +++ b/src/main/java/org/rev317/min/accessors/Client.java @@ -1,57 +1,57 @@ -package org.rev317.min.accessors; - -public interface Client { - - public Scene getScene(); - - public Player getMyPlayer(); - - public Interface[] getInterfaceCache(); - - public Npc[] getNpcs(); - - public Player[] getPlayers(); - - public int getOpenInterfaceId(); - - public int getBaseX(); - - public int getBaseY(); - - public void setInterface(int id); - - public int[] getCurrentExp(); - - public Deque[][][] getGroundItems(); - - public int getLoopCycle(); - - public int getBackDialogId(); - - public int getPlane(); - - public int[] getMenuActionId(); - - public int[] getMenuAction1(); - - public int[] getMenuAction2(); - - public int[] getMenuAction3(); - - public int[] getMenuAction4(); - - public CollisionMap[] getCollisionMap(); - - // args switched - public boolean walkTo(int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation); - - public void doAction(int i); - - public void dropClient(); - - public int[] getCurrentStats(); - - public int[] getSettings(); - - public boolean isLoggedIn(); -} +package org.rev317.min.accessors; + +public interface Client { + + public Scene getScene(); + + public Player getMyPlayer(); + + public Interface[] getInterfaceCache(); + + public Npc[] getNpcs(); + + public Player[] getPlayers(); + + public int getOpenInterfaceId(); + + public int getBaseX(); + + public int getBaseY(); + + public void setInterface(int id); + + public int[] getCurrentExp(); + + public Deque[][][] getGroundItems(); + + public int getLoopCycle(); + + public int getBackDialogId(); + + public int getPlane(); + + public int[] getMenuActionId(); + + public int[] getMenuAction1(); + + public int[] getMenuAction2(); + + public int[] getMenuAction3(); + + public int[] getMenuAction4(); + + public CollisionMap[] getCollisionMap(); + + // args switched + public boolean walkTo(int clickType, int sizeX, int sizeY, int startX, int startY, int destX, int destY, int type, int face, boolean arbitrary, int rotation); + + public void doAction(int i); + + public void dropClient(); + + public int[] getCurrentStats(); + + public int[] getSettings(); + + public boolean isLoggedIn(); +} diff --git a/src/org/rev317/min/accessors/CollisionMap.java b/src/main/java/org/rev317/min/accessors/CollisionMap.java similarity index 92% rename from src/org/rev317/min/accessors/CollisionMap.java rename to src/main/java/org/rev317/min/accessors/CollisionMap.java index 5c05ac5..b59c57b 100644 --- a/src/org/rev317/min/accessors/CollisionMap.java +++ b/src/main/java/org/rev317/min/accessors/CollisionMap.java @@ -1,9 +1,9 @@ -package org.rev317.min.accessors; - - -public interface CollisionMap { - - public int[][] getFlags(); - -} - +package org.rev317.min.accessors; + + +public interface CollisionMap { + + public int[][] getFlags(); + +} + diff --git a/src/org/rev317/min/accessors/Deque.java b/src/main/java/org/rev317/min/accessors/Deque.java similarity index 93% rename from src/org/rev317/min/accessors/Deque.java rename to src/main/java/org/rev317/min/accessors/Deque.java index cd98d3a..c1b73cd 100644 --- a/src/org/rev317/min/accessors/Deque.java +++ b/src/main/java/org/rev317/min/accessors/Deque.java @@ -1,9 +1,9 @@ -package org.rev317.min.accessors; - -public interface Deque { - - public Node getHead(); - - public Node getCurrent(); - -} +package org.rev317.min.accessors; + +public interface Deque { + + public Node getHead(); + + public Node getCurrent(); + +} diff --git a/src/org/rev317/min/accessors/Ground.java b/src/main/java/org/rev317/min/accessors/Ground.java similarity index 95% rename from src/org/rev317/min/accessors/Ground.java rename to src/main/java/org/rev317/min/accessors/Ground.java index c7ab0fc..5ca2b8e 100644 --- a/src/org/rev317/min/accessors/Ground.java +++ b/src/main/java/org/rev317/min/accessors/Ground.java @@ -1,15 +1,15 @@ -package org.rev317.min.accessors; - -public interface Ground { - - public SceneObjectTile getWallObject(); - - public SceneObjectTile getWallDecoration(); - - public SceneObjectTile getGroundDecoration(); - - public SceneObjectTile getGroundItem(); - - public SceneObjectTile[] getInteractiveObjects(); - -} +package org.rev317.min.accessors; + +public interface Ground { + + public SceneObjectTile getWallObject(); + + public SceneObjectTile getWallDecoration(); + + public SceneObjectTile getGroundDecoration(); + + public SceneObjectTile getGroundItem(); + + public SceneObjectTile[] getInteractiveObjects(); + +} diff --git a/src/org/rev317/min/accessors/Interface.java b/src/main/java/org/rev317/min/accessors/Interface.java similarity index 93% rename from src/org/rev317/min/accessors/Interface.java rename to src/main/java/org/rev317/min/accessors/Interface.java index 3d07791..30cf76a 100644 --- a/src/org/rev317/min/accessors/Interface.java +++ b/src/main/java/org/rev317/min/accessors/Interface.java @@ -1,11 +1,11 @@ -package org.rev317.min.accessors; - -public interface Interface { - - public int[] getItems(); - - public int[] getStackSizes(); - - public String getMessage(); - -} +package org.rev317.min.accessors; + +public interface Interface { + + public int[] getItems(); + + public int[] getStackSizes(); + + public String getMessage(); + +} diff --git a/src/org/rev317/min/accessors/Item.java b/src/main/java/org/rev317/min/accessors/Item.java similarity index 91% rename from src/org/rev317/min/accessors/Item.java rename to src/main/java/org/rev317/min/accessors/Item.java index 7fa8478..1f9c46c 100644 --- a/src/org/rev317/min/accessors/Item.java +++ b/src/main/java/org/rev317/min/accessors/Item.java @@ -1,8 +1,8 @@ -package org.rev317.min.accessors; - -public interface Item { - - public int getId(); - -} - +package org.rev317.min.accessors; + +public interface Item { + + public int getId(); + +} + diff --git a/src/org/rev317/min/accessors/Node.java b/src/main/java/org/rev317/min/accessors/Node.java similarity index 92% rename from src/org/rev317/min/accessors/Node.java rename to src/main/java/org/rev317/min/accessors/Node.java index 40ce9ef..9ecbb2d 100644 --- a/src/org/rev317/min/accessors/Node.java +++ b/src/main/java/org/rev317/min/accessors/Node.java @@ -1,7 +1,7 @@ -package org.rev317.min.accessors; - -public interface Node { - - public Node getNext(); - -} +package org.rev317.min.accessors; + +public interface Node { + + public Node getNext(); + +} diff --git a/src/org/rev317/min/accessors/Npc.java b/src/main/java/org/rev317/min/accessors/Npc.java similarity index 94% rename from src/org/rev317/min/accessors/Npc.java rename to src/main/java/org/rev317/min/accessors/Npc.java index 19e30cd..bb7e68e 100644 --- a/src/org/rev317/min/accessors/Npc.java +++ b/src/main/java/org/rev317/min/accessors/Npc.java @@ -1,7 +1,7 @@ -package org.rev317.min.accessors; - -public interface Npc extends Character { - - public NpcDef getDef(); - +package org.rev317.min.accessors; + +public interface Npc extends Character { + + public NpcDef getDef(); + } \ No newline at end of file diff --git a/src/org/rev317/min/accessors/NpcDef.java b/src/main/java/org/rev317/min/accessors/NpcDef.java similarity index 92% rename from src/org/rev317/min/accessors/NpcDef.java rename to src/main/java/org/rev317/min/accessors/NpcDef.java index a295d1c..0f346c6 100644 --- a/src/org/rev317/min/accessors/NpcDef.java +++ b/src/main/java/org/rev317/min/accessors/NpcDef.java @@ -1,7 +1,7 @@ -package org.rev317.min.accessors; - -public interface NpcDef { - - public int getId(); - -} +package org.rev317.min.accessors; + +public interface NpcDef { + + public int getId(); + +} diff --git a/src/org/rev317/min/accessors/Player.java b/src/main/java/org/rev317/min/accessors/Player.java similarity index 95% rename from src/org/rev317/min/accessors/Player.java rename to src/main/java/org/rev317/min/accessors/Player.java index 78ce27e..10b4d6a 100644 --- a/src/org/rev317/min/accessors/Player.java +++ b/src/main/java/org/rev317/min/accessors/Player.java @@ -1,5 +1,5 @@ -package org.rev317.min.accessors; - -public interface Player extends Character { - String getName(); -} +package org.rev317.min.accessors; + +public interface Player extends Character { + String getName(); +} diff --git a/src/org/rev317/min/accessors/Scene.java b/src/main/java/org/rev317/min/accessors/Scene.java similarity index 93% rename from src/org/rev317/min/accessors/Scene.java rename to src/main/java/org/rev317/min/accessors/Scene.java index 680f873..a659d8f 100644 --- a/src/org/rev317/min/accessors/Scene.java +++ b/src/main/java/org/rev317/min/accessors/Scene.java @@ -1,7 +1,7 @@ -package org.rev317.min.accessors; - -public interface Scene { - - public Ground[][][] getGroundArray(); - -} +package org.rev317.min.accessors; + +public interface Scene { + + public Ground[][][] getGroundArray(); + +} diff --git a/src/org/rev317/min/accessors/SceneObjectTile.java b/src/main/java/org/rev317/min/accessors/SceneObjectTile.java similarity index 94% rename from src/org/rev317/min/accessors/SceneObjectTile.java rename to src/main/java/org/rev317/min/accessors/SceneObjectTile.java index ea15dff..793bfd3 100644 --- a/src/org/rev317/min/accessors/SceneObjectTile.java +++ b/src/main/java/org/rev317/min/accessors/SceneObjectTile.java @@ -1,7 +1,7 @@ -package org.rev317.min.accessors; - -public interface SceneObjectTile { - - public int getHash(); - +package org.rev317.min.accessors; + +public interface SceneObjectTile { + + public int getHash(); + } \ No newline at end of file diff --git a/src/org/rev317/min/api/events/GameActionEvent.java b/src/main/java/org/rev317/min/api/events/GameActionEvent.java similarity index 100% rename from src/org/rev317/min/api/events/GameActionEvent.java rename to src/main/java/org/rev317/min/api/events/GameActionEvent.java diff --git a/src/org/rev317/min/api/events/MessageEvent.java b/src/main/java/org/rev317/min/api/events/MessageEvent.java similarity index 95% rename from src/org/rev317/min/api/events/MessageEvent.java rename to src/main/java/org/rev317/min/api/events/MessageEvent.java index 8b43e66..ce1dfdf 100644 --- a/src/org/rev317/min/api/events/MessageEvent.java +++ b/src/main/java/org/rev317/min/api/events/MessageEvent.java @@ -1,33 +1,33 @@ -package org.rev317.min.api.events; - -/** - * @author Everel, Matt - */ -public final class MessageEvent { - public static final int TYPE_GENERIC = 0; - public static final int TYPE_PLAYER = 2; - public static final int TYPE_TRADE = 4; - public static final int TYPE_DUEL = 8; - private int type; - private String name; - private String message; - - public MessageEvent(final int type, String name, String msg) { - this.type = type; - this.name = name; - this.message = msg; - } - - public final String getMessage() { - return message; - } - - public final int getType() { - return type; - } - - public final String getSender() { - return name; - } - +package org.rev317.min.api.events; + +/** + * @author Everel, Matt + */ +public final class MessageEvent { + public static final int TYPE_GENERIC = 0; + public static final int TYPE_PLAYER = 2; + public static final int TYPE_TRADE = 4; + public static final int TYPE_DUEL = 8; + private int type; + private String name; + private String message; + + public MessageEvent(final int type, String name, String msg) { + this.type = type; + this.name = name; + this.message = msg; + } + + public final String getMessage() { + return message; + } + + public final int getType() { + return type; + } + + public final String getSender() { + return name; + } + } \ No newline at end of file diff --git a/src/org/rev317/min/api/events/listeners/GameActionListener.java b/src/main/java/org/rev317/min/api/events/listeners/GameActionListener.java similarity index 100% rename from src/org/rev317/min/api/events/listeners/GameActionListener.java rename to src/main/java/org/rev317/min/api/events/listeners/GameActionListener.java diff --git a/src/org/rev317/min/api/events/listeners/MessageListener.java b/src/main/java/org/rev317/min/api/events/listeners/MessageListener.java similarity index 94% rename from src/org/rev317/min/api/events/listeners/MessageListener.java rename to src/main/java/org/rev317/min/api/events/listeners/MessageListener.java index 0256f36..895627f 100644 --- a/src/org/rev317/min/api/events/listeners/MessageListener.java +++ b/src/main/java/org/rev317/min/api/events/listeners/MessageListener.java @@ -1,12 +1,12 @@ -package org.rev317.min.api.events.listeners; - -import org.rev317.min.api.events.MessageEvent; - - -public interface MessageListener { - - public void messageReceived(MessageEvent event); - -} - - +package org.rev317.min.api.events.listeners; + +import org.rev317.min.api.events.MessageEvent; + + +public interface MessageListener { + + public void messageReceived(MessageEvent event); + +} + + diff --git a/src/org/rev317/min/api/interfaces/Locatable.java b/src/main/java/org/rev317/min/api/interfaces/Locatable.java similarity index 94% rename from src/org/rev317/min/api/interfaces/Locatable.java rename to src/main/java/org/rev317/min/api/interfaces/Locatable.java index e29f1e7..bf0c144 100644 --- a/src/org/rev317/min/api/interfaces/Locatable.java +++ b/src/main/java/org/rev317/min/api/interfaces/Locatable.java @@ -1,24 +1,24 @@ -package org.rev317.min.api.interfaces; - -import org.rev317.min.api.wrappers.Tile; - -/** - * @author Everel - */ -public interface Locatable { - - /** - * Gets location of this locatable instance - * - * @return location - */ - public Tile getLocation(); - - /** - * Gets distance to this locatable instance - * - * @return distance from player to locatable - */ - public int distanceTo(); - -} +package org.rev317.min.api.interfaces; + +import org.rev317.min.api.wrappers.Tile; + +/** + * @author Everel + */ +public interface Locatable { + + /** + * Gets location of this locatable instance + * + * @return location + */ + public Tile getLocation(); + + /** + * Gets distance to this locatable instance + * + * @return distance from player to locatable + */ + public int distanceTo(); + +} diff --git a/src/org/rev317/min/api/interfaces/TileFlags.java b/src/main/java/org/rev317/min/api/interfaces/TileFlags.java similarity index 96% rename from src/org/rev317/min/api/interfaces/TileFlags.java rename to src/main/java/org/rev317/min/api/interfaces/TileFlags.java index a592e3d..bf386b6 100644 --- a/src/org/rev317/min/api/interfaces/TileFlags.java +++ b/src/main/java/org/rev317/min/api/interfaces/TileFlags.java @@ -1,18 +1,18 @@ -package org.rev317.min.api.interfaces; - -public interface TileFlags { - - public int WALL_NORTHWEST = 0x1; - public int WALL_NORTH = 0x2; - public int WALL_NORTHEAST = 0x4; - public int WALL_EAST = 0x8; - public int WALL_SOUTHEAST = 0x10; - public int WALL_SOUTH = 0x20; - public int WALL_SOUTHWEST = 0x40; - public int WALL_WEST = 0x80; - public int OBJECT_TILE = 0x100; - public int UNKNOWN = 0x80000; - public int BLOCKED_TILE = 0x200000; - public int UNLOADED_TILE = 0x1000000; - -} +package org.rev317.min.api.interfaces; + +public interface TileFlags { + + public int WALL_NORTHWEST = 0x1; + public int WALL_NORTH = 0x2; + public int WALL_NORTHEAST = 0x4; + public int WALL_EAST = 0x8; + public int WALL_SOUTHEAST = 0x10; + public int WALL_SOUTH = 0x20; + public int WALL_SOUTHWEST = 0x40; + public int WALL_WEST = 0x80; + public int OBJECT_TILE = 0x100; + public int UNKNOWN = 0x80000; + public int BLOCKED_TILE = 0x200000; + public int UNLOADED_TILE = 0x1000000; + +} diff --git a/src/org/rev317/min/api/methods/Bank.java b/src/main/java/org/rev317/min/api/methods/Bank.java similarity index 96% rename from src/org/rev317/min/api/methods/Bank.java rename to src/main/java/org/rev317/min/api/methods/Bank.java index afa7d4f..6925c5b 100644 --- a/src/org/rev317/min/api/methods/Bank.java +++ b/src/main/java/org/rev317/min/api/methods/Bank.java @@ -1,293 +1,293 @@ -package org.rev317.min.api.methods; - -import org.parabot.core.Context; -import org.parabot.environment.api.utils.Time; -import org.parabot.environment.input.Keyboard; -import org.parabot.environment.scripts.framework.SleepCondition; -import org.rev317.min.Loader; -import org.rev317.min.api.wrappers.Item; -import org.rev317.min.api.wrappers.Npc; -import org.rev317.min.api.wrappers.SceneObject; - -import java.util.ArrayList; -import java.util.HashMap; - -/** - * @author Everel, Matt123337, JKetelaar - */ -public class Bank { - public static final int[] BANKERS = new int[]{44, 45, 494, 495, 498, 499, - 909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457, - 4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948, - 9710, 14367}; - public static final int[] BANKS = new int[]{782, 2213, 2995, 5276, 6084, - 10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808, - 26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693, - 4483, 12308, 20607, 21301, 27663, 42192}; - private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); - - /** - * Gets nearest banker - * - * @return nearest banker - */ - public static Npc getBanker() { - return Npcs.getClosest(BANKERS); - } - - /** - * Gets nearest bank booths - * - * @return bank booths - */ - public static SceneObject[] getNearestBanks() { - return SceneObjects.getNearest(BANKS); - } - - /** - * Gets nearest bank booths - * - * @return bank booth - */ - public static SceneObject getBank() { - SceneObject[] banks = getNearestBanks(); - if (banks != null && banks[0] != null) { - return banks[0]; - } - return null; - } - - /** - * Opens bank using banker or bank booth - * - * @return true if successfully interacted - */ - public static boolean open() { - - if (isOpen()) { - return false; - } - SceneObject bank = getBank(); - Npc banker = getBanker(); - - if (bank != null) { - bank.interact(SceneObjects.Option.USE); - return true; - } else if (banker != null) { - banker.interact(Npcs.Option.BANK); - return true; - } - - return false; - } - - /** - * Deposits all items - */ - public static void depositAll() { - Menu.clickButton(settings.get("button_deposit_all")); - } - - /** - * Withdraws items at bank based on given parameters - * - * @param id - * @param amount - */ - public static void withdraw(int id, int amount, int sleep) { - if (!isOpen()) { - return; - } - - Item b = getItem(id); - - if (b == null) { - return; - } - - if (amount == 1) { - b.transform(Items.Option.TRANSFORM_ONE, settings.get("item_interface_id")); - } else if (amount == 5) { - b.transform(Items.Option.TRANSFORM_FIVE, settings.get("item_interface_id")); - } else if (amount == 10) { - b.transform(Items.Option.TRANSFORM_TEN, settings.get("item_interface_id")); - } else if (amount == 0) { - b.transform(Items.Option.TRANSFORM_ALL, settings.get("item_interface_id")); - } else { - b.transform(Items.Option.TRANSFORM_X, settings.get("item_interface_id")); - Time.sleep(1500 + sleep); - Keyboard.getInstance().sendKeys("" + amount); - } - } - - /** - * Gets bank item with given id - * - * @param id - * - * @return bank item - */ - public static Item getItem(int id) { - if (!isOpen()) { - return null; - } - - Item[] items; - if ((items = Bank.getBankItems()) != null) { - for (Item i : items) { - if (i.getId() == id) { - return i; - } - } - } - return null; - } - - /** - * Counts the amount of items with given id in bank - * - * @param id - * - * @return count - */ - public static int getCount(int id) { - if (!isOpen()) { - return 0; - } - Item item; - return ((item = getItem(id)) != null ? item.getStackSize() : 0); - } - - /** - * Opens the bank - * - * @param bank booth - */ - public static void open(final SceneObject bank) { - if (isOpen()) { - return; - } - - if (bank.getLocation().distanceTo() > 8) { - bank.getLocation().walkTo(); - Time.sleep(new SleepCondition() { - @Override - public boolean isValid() { - return bank.distanceTo() < 8; - } - }, 5000); - return; - } - bank.interact(SceneObjects.Option.USE); - } - - - /** - * Closes the bank interface - */ - public static void close() { - if (!isOpen()) { - return; - } - Menu.sendAction(200, -1, -1, settings.get("button_close_bank")); - } - - /** - * Deposits all items except the given ids - * - * @param exceptions the item indexes that will be ignored. - */ - public static void depositAllExcept(int... exceptions) { - if (Bank.isOpen()) { - final ArrayList ignored = new ArrayList<>(); - for (int i : exceptions) { - ignored.add(i); - } - - for (Item i : Inventory.getItems()) { - if (!ignored.contains(i.getId())) { - while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) { - i.transform(Items.Option.TRANSFORM_ALL, settings.get("inventory_parent_id")); - ignored.add(i.getId()); - final int previous = Inventory.getCount(true); - Time.sleep(new SleepCondition() { - @Override - public boolean isValid() { - return Inventory.getCount(true) != previous; - } - }, 500); - } - } - } - } - } - - /** - * Gets all bank item ids in bank - * - * @return bank items - */ - public static int[] getBankItemIDs() { - if (!isOpen()) { - return null; - } - return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getItems(); - } - - /** - * Gets all stack sizes in bank - * - * @return stack sizes - */ - public static int[] getBankStacks() { - if (!isOpen()) { - return null; - } - return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getStackSizes(); - } - - /** - * Gets all bank items in bank - * - * @return bank items - */ - public static Item[] getBankItems() { - if (!isOpen()) { - return null; - } - ArrayList items = new ArrayList(); - int[] ids = getBankItemIDs(); - int[] stacks = getBankStacks(); - if (ids != null && stacks != null) { - for (int i = 0; i < ids.length; i++) { - if (ids[i] > 0) { - items.add(new Item(ids[i], stacks[i], i)); - } - } - } - return items.toArray(new Item[items.size()]); - } - - /** - * Counts total amount of items in bank - * - * @return total amount of items - */ - public static int getBankCount() { - if (!isOpen()) { - return 0; - } - int[] items; - return ((items = getBankItemIDs()) != null ? items.length : 0); - } - - /** - * Determines if bank is open - * - * @return true if bank is open - */ - public static boolean isOpen() { - return Loader.getClient().getOpenInterfaceId() == settings.get("bank_interface_id"); - } - -} +package org.rev317.min.api.methods; + +import org.parabot.core.Context; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.input.Keyboard; +import org.parabot.environment.scripts.framework.SleepCondition; +import org.rev317.min.Loader; +import org.rev317.min.api.wrappers.Item; +import org.rev317.min.api.wrappers.Npc; +import org.rev317.min.api.wrappers.SceneObject; + +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @author Everel, Matt123337, JKetelaar + */ +public class Bank { + public static final int[] BANKERS = new int[]{44, 45, 494, 495, 498, 499, + 909, 958, 1036, 2271, 2354, 2355, 3824, 5488, 5901, 4456, 4457, + 4458, 4459, 5912, 5913, 6362, 6532, 6533, 6534, 6535, 7605, 8948, + 9710, 14367}; + public static final int[] BANKS = new int[]{782, 2213, 2995, 5276, 6084, + 10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 25808, + 26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015, 2019, 693, + 4483, 12308, 20607, 21301, 27663, 42192}; + private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); + + /** + * Gets nearest banker + * + * @return nearest banker + */ + public static Npc getBanker() { + return Npcs.getClosest(BANKERS); + } + + /** + * Gets nearest bank booths + * + * @return bank booths + */ + public static SceneObject[] getNearestBanks() { + return SceneObjects.getNearest(BANKS); + } + + /** + * Gets nearest bank booths + * + * @return bank booth + */ + public static SceneObject getBank() { + SceneObject[] banks = getNearestBanks(); + if (banks != null && banks[0] != null) { + return banks[0]; + } + return null; + } + + /** + * Opens bank using banker or bank booth + * + * @return true if successfully interacted + */ + public static boolean open() { + + if (isOpen()) { + return false; + } + SceneObject bank = getBank(); + Npc banker = getBanker(); + + if (bank != null) { + bank.interact(SceneObjects.Option.USE); + return true; + } else if (banker != null) { + banker.interact(Npcs.Option.BANK); + return true; + } + + return false; + } + + /** + * Deposits all items + */ + public static void depositAll() { + Menu.clickButton(settings.get("button_deposit_all")); + } + + /** + * Withdraws items at bank based on given parameters + * + * @param id + * @param amount + */ + public static void withdraw(int id, int amount, int sleep) { + if (!isOpen()) { + return; + } + + Item b = getItem(id); + + if (b == null) { + return; + } + + if (amount == 1) { + b.transform(Items.Option.TRANSFORM_ONE, settings.get("item_interface_id")); + } else if (amount == 5) { + b.transform(Items.Option.TRANSFORM_FIVE, settings.get("item_interface_id")); + } else if (amount == 10) { + b.transform(Items.Option.TRANSFORM_TEN, settings.get("item_interface_id")); + } else if (amount == 0) { + b.transform(Items.Option.TRANSFORM_ALL, settings.get("item_interface_id")); + } else { + b.transform(Items.Option.TRANSFORM_X, settings.get("item_interface_id")); + Time.sleep(1500 + sleep); + Keyboard.getInstance().sendKeys("" + amount); + } + } + + /** + * Gets bank item with given id + * + * @param id + * + * @return bank item + */ + public static Item getItem(int id) { + if (!isOpen()) { + return null; + } + + Item[] items; + if ((items = Bank.getBankItems()) != null) { + for (Item i : items) { + if (i.getId() == id) { + return i; + } + } + } + return null; + } + + /** + * Counts the amount of items with given id in bank + * + * @param id + * + * @return count + */ + public static int getCount(int id) { + if (!isOpen()) { + return 0; + } + Item item; + return ((item = getItem(id)) != null ? item.getStackSize() : 0); + } + + /** + * Opens the bank + * + * @param bank booth + */ + public static void open(final SceneObject bank) { + if (isOpen()) { + return; + } + + if (bank.getLocation().distanceTo() > 8) { + bank.getLocation().walkTo(); + Time.sleep(new SleepCondition() { + @Override + public boolean isValid() { + return bank.distanceTo() < 8; + } + }, 5000); + return; + } + bank.interact(SceneObjects.Option.USE); + } + + + /** + * Closes the bank interface + */ + public static void close() { + if (!isOpen()) { + return; + } + Menu.sendAction(200, -1, -1, settings.get("button_close_bank")); + } + + /** + * Deposits all items except the given ids + * + * @param exceptions the item indexes that will be ignored. + */ + public static void depositAllExcept(int... exceptions) { + if (Bank.isOpen()) { + final ArrayList ignored = new ArrayList<>(); + for (int i : exceptions) { + ignored.add(i); + } + + for (Item i : Inventory.getItems()) { + if (!ignored.contains(i.getId())) { + while (Bank.isOpen() && Inventory.getCount(i.getId()) > 0) { + i.transform(Items.Option.TRANSFORM_ALL, settings.get("inventory_parent_id")); + ignored.add(i.getId()); + final int previous = Inventory.getCount(true); + Time.sleep(new SleepCondition() { + @Override + public boolean isValid() { + return Inventory.getCount(true) != previous; + } + }, 500); + } + } + } + } + } + + /** + * Gets all bank item ids in bank + * + * @return bank items + */ + public static int[] getBankItemIDs() { + if (!isOpen()) { + return null; + } + return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getItems(); + } + + /** + * Gets all stack sizes in bank + * + * @return stack sizes + */ + public static int[] getBankStacks() { + if (!isOpen()) { + return null; + } + return Loader.getClient().getInterfaceCache()[settings.get("item_interface_id")].getStackSizes(); + } + + /** + * Gets all bank items in bank + * + * @return bank items + */ + public static Item[] getBankItems() { + if (!isOpen()) { + return null; + } + ArrayList items = new ArrayList(); + int[] ids = getBankItemIDs(); + int[] stacks = getBankStacks(); + if (ids != null && stacks != null) { + for (int i = 0; i < ids.length; i++) { + if (ids[i] > 0) { + items.add(new Item(ids[i], stacks[i], i)); + } + } + } + return items.toArray(new Item[items.size()]); + } + + /** + * Counts total amount of items in bank + * + * @return total amount of items + */ + public static int getBankCount() { + if (!isOpen()) { + return 0; + } + int[] items; + return ((items = getBankItemIDs()) != null ? items.length : 0); + } + + /** + * Determines if bank is open + * + * @return true if bank is open + */ + public static boolean isOpen() { + return Loader.getClient().getOpenInterfaceId() == settings.get("bank_interface_id"); + } + +} diff --git a/src/org/rev317/min/api/methods/Calculations.java b/src/main/java/org/rev317/min/api/methods/Calculations.java similarity index 97% rename from src/org/rev317/min/api/methods/Calculations.java rename to src/main/java/org/rev317/min/api/methods/Calculations.java index f642775..9151b2e 100644 --- a/src/org/rev317/min/api/methods/Calculations.java +++ b/src/main/java/org/rev317/min/api/methods/Calculations.java @@ -1,158 +1,158 @@ -package org.rev317.min.api.methods; - -import org.rev317.min.api.wrappers.Tile; - -/** - * @author Everel - */ -public class Calculations { - - /** - * Calculates distance between local player and given tile - * - * @param tile - * - * @return distance between local player and given tile - */ - public static final double distanceTo(Tile tile) { - return distanceBetween(tile, Players.getMyPlayer().getLocation()); - } - - /** - * Calculates distance between two given tiles - * - * @param a - * @param b - * - * @return distance between a and b - */ - public static final double distanceBetween(Tile a, Tile b) { - int x = b.getX() - a.getX(); - int y = b.getY() - a.getY(); - return Math.sqrt((x * x) + (y * y)); - } - - - /** - * @param startX the startX (0 < startX < 104) - * @param startY the startY (0 < startY < 104) - * @param destX the destX (0 < destX < 104) - * @param destY the destY (0 < destY < 104) - * @param findAdjacent if it's an object, it will find path which touches it. - * - * @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was - * found. - */ - public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) { - try { - final int[][] prev = new int[104][104]; - final int[][] dist = new int[104][104]; - final int[] path_x = new int[4000]; - final int[] path_y = new int[4000]; - for (int xx = 0; xx < 104; xx++) { - for (int yy = 0; yy < 104; yy++) { - prev[xx][yy] = 0; - dist[xx][yy] = 99999999; - } - } - int curr_x = startX; - int curr_y = startY; - prev[startX][startY] = 99; - dist[startX][startY] = 0; - int path_ptr = 0; - int step_ptr = 0; - path_x[path_ptr] = startX; - path_y[path_ptr++] = startY; - final int blocks[][] = Game.getCollisionFlags(); - final int pathLength = path_x.length; - boolean foundPath = false; - while (step_ptr != path_ptr) { - curr_x = path_x[step_ptr]; - curr_y = path_y[step_ptr]; - if (Math.abs(curr_x - destX) + Math.abs(curr_y - destY) == (findAdjacent ? 1 : 0)) { - foundPath = true; - break; - } - step_ptr = (step_ptr + 1) % pathLength; - final int cost = dist[curr_x][curr_y] + 1; - // south - if (curr_y > 0 && prev[curr_x][curr_y - 1] == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) { - path_x[path_ptr] = curr_x; - path_y[path_ptr] = curr_y - 1; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x][curr_y - 1] = 1; - dist[curr_x][curr_y - 1] = cost; - } - // west - if (curr_x > 0 && prev[curr_x - 1][curr_y] == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0) { - path_x[path_ptr] = curr_x - 1; - path_y[path_ptr] = curr_y; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x - 1][curr_y] = 2; - dist[curr_x - 1][curr_y] = cost; - } - // north - if (curr_y < 104 - 1 && prev[curr_x][curr_y + 1] == 0 && (blocks[curr_x][curr_y + 1] & - 0x1280120) == 0) { - path_x[path_ptr] = curr_x; - path_y[path_ptr] = curr_y + 1; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x][curr_y + 1] = 4; - dist[curr_x][curr_y + 1] = cost; - } - // east - if (curr_x < 104 - 1 && prev[curr_x + 1][curr_y] == 0 && (blocks[curr_x + 1][curr_y] & - 0x1280180) == 0) { - path_x[path_ptr] = curr_x + 1; - path_y[path_ptr] = curr_y; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x + 1][curr_y] = 8; - dist[curr_x + 1][curr_y] = cost; - } - // south west - if (curr_x > 0 && curr_y > 0 && prev[curr_x - 1][curr_y - 1] == 0 && (blocks[curr_x - 1][curr_y - 1] & - 0x128010E) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0 && (blocks[curr_x - ][curr_y - 1] & 0x1280102) == 0) { - path_x[path_ptr] = curr_x - 1; - path_y[path_ptr] = curr_y - 1; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x - 1][curr_y - 1] = 3; - dist[curr_x - 1][curr_y - 1] = cost; - } - // north west - if (curr_x > 0 && curr_y < 104 - 1 && prev[curr_x - 1][curr_y + 1] == 0 && (blocks[curr_x - 1][curr_y + 1] & 0x1280138) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == - 0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) { - path_x[path_ptr] = curr_x - 1; - path_y[path_ptr] = curr_y + 1; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x - 1][curr_y + 1] = 6; - dist[curr_x - 1][curr_y + 1] = cost; - } - // south east - if (curr_x < 104 - 1 && curr_y > 0 && prev[curr_x + 1][curr_y - 1] == 0 && (blocks[curr_x + - 1][curr_y - 1] & 0x1280183) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) { - path_x[path_ptr] = curr_x + 1; - path_y[path_ptr] = curr_y - 1; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x + 1][curr_y - 1] = 9; - dist[curr_x + 1][curr_y - 1] = cost; - } - // north east - if (curr_x < 104 - 1 && curr_y < 104 - 1 && prev[curr_x + 1][curr_y + 1] == 0 && (blocks[curr_x - + 1][curr_y + 1] & 0x12801E0) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) { - path_x[path_ptr] = curr_x + 1; - path_y[path_ptr] = curr_y + 1; - path_ptr = (path_ptr + 1) % pathLength; - prev[curr_x + 1][curr_y + 1] = 12; - dist[curr_x + 1][curr_y + 1] = cost; - } - } - return foundPath ? dist[curr_x][curr_y] : -1; - } catch (Exception e) { - return -1; - } - } - - - -} +package org.rev317.min.api.methods; + +import org.rev317.min.api.wrappers.Tile; + +/** + * @author Everel + */ +public class Calculations { + + /** + * Calculates distance between local player and given tile + * + * @param tile + * + * @return distance between local player and given tile + */ + public static final double distanceTo(Tile tile) { + return distanceBetween(tile, Players.getMyPlayer().getLocation()); + } + + /** + * Calculates distance between two given tiles + * + * @param a + * @param b + * + * @return distance between a and b + */ + public static final double distanceBetween(Tile a, Tile b) { + int x = b.getX() - a.getX(); + int y = b.getY() - a.getY(); + return Math.sqrt((x * x) + (y * y)); + } + + + /** + * @param startX the startX (0 < startX < 104) + * @param startY the startY (0 < startY < 104) + * @param destX the destX (0 < destX < 104) + * @param destY the destY (0 < destY < 104) + * @param findAdjacent if it's an object, it will find path which touches it. + * + * @return The distance of the shortest path to the destination; or -1 if no valid path to the destination was + * found. + */ + public static int dijkstraDist(final int startX, final int startY, final int destX, final int destY, final boolean findAdjacent) { + try { + final int[][] prev = new int[104][104]; + final int[][] dist = new int[104][104]; + final int[] path_x = new int[4000]; + final int[] path_y = new int[4000]; + for (int xx = 0; xx < 104; xx++) { + for (int yy = 0; yy < 104; yy++) { + prev[xx][yy] = 0; + dist[xx][yy] = 99999999; + } + } + int curr_x = startX; + int curr_y = startY; + prev[startX][startY] = 99; + dist[startX][startY] = 0; + int path_ptr = 0; + int step_ptr = 0; + path_x[path_ptr] = startX; + path_y[path_ptr++] = startY; + final int blocks[][] = Game.getCollisionFlags(); + final int pathLength = path_x.length; + boolean foundPath = false; + while (step_ptr != path_ptr) { + curr_x = path_x[step_ptr]; + curr_y = path_y[step_ptr]; + if (Math.abs(curr_x - destX) + Math.abs(curr_y - destY) == (findAdjacent ? 1 : 0)) { + foundPath = true; + break; + } + step_ptr = (step_ptr + 1) % pathLength; + final int cost = dist[curr_x][curr_y] + 1; + // south + if (curr_y > 0 && prev[curr_x][curr_y - 1] == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) { + path_x[path_ptr] = curr_x; + path_y[path_ptr] = curr_y - 1; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x][curr_y - 1] = 1; + dist[curr_x][curr_y - 1] = cost; + } + // west + if (curr_x > 0 && prev[curr_x - 1][curr_y] == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0) { + path_x[path_ptr] = curr_x - 1; + path_y[path_ptr] = curr_y; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x - 1][curr_y] = 2; + dist[curr_x - 1][curr_y] = cost; + } + // north + if (curr_y < 104 - 1 && prev[curr_x][curr_y + 1] == 0 && (blocks[curr_x][curr_y + 1] & + 0x1280120) == 0) { + path_x[path_ptr] = curr_x; + path_y[path_ptr] = curr_y + 1; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x][curr_y + 1] = 4; + dist[curr_x][curr_y + 1] = cost; + } + // east + if (curr_x < 104 - 1 && prev[curr_x + 1][curr_y] == 0 && (blocks[curr_x + 1][curr_y] & + 0x1280180) == 0) { + path_x[path_ptr] = curr_x + 1; + path_y[path_ptr] = curr_y; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x + 1][curr_y] = 8; + dist[curr_x + 1][curr_y] = cost; + } + // south west + if (curr_x > 0 && curr_y > 0 && prev[curr_x - 1][curr_y - 1] == 0 && (blocks[curr_x - 1][curr_y - 1] & + 0x128010E) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == 0 && (blocks[curr_x + ][curr_y - 1] & 0x1280102) == 0) { + path_x[path_ptr] = curr_x - 1; + path_y[path_ptr] = curr_y - 1; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x - 1][curr_y - 1] = 3; + dist[curr_x - 1][curr_y - 1] = cost; + } + // north west + if (curr_x > 0 && curr_y < 104 - 1 && prev[curr_x - 1][curr_y + 1] == 0 && (blocks[curr_x - 1][curr_y + 1] & 0x1280138) == 0 && (blocks[curr_x - 1][curr_y] & 0x1280108) == + 0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) { + path_x[path_ptr] = curr_x - 1; + path_y[path_ptr] = curr_y + 1; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x - 1][curr_y + 1] = 6; + dist[curr_x - 1][curr_y + 1] = cost; + } + // south east + if (curr_x < 104 - 1 && curr_y > 0 && prev[curr_x + 1][curr_y - 1] == 0 && (blocks[curr_x + + 1][curr_y - 1] & 0x1280183) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y - 1] & 0x1280102) == 0) { + path_x[path_ptr] = curr_x + 1; + path_y[path_ptr] = curr_y - 1; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x + 1][curr_y - 1] = 9; + dist[curr_x + 1][curr_y - 1] = cost; + } + // north east + if (curr_x < 104 - 1 && curr_y < 104 - 1 && prev[curr_x + 1][curr_y + 1] == 0 && (blocks[curr_x + + 1][curr_y + 1] & 0x12801E0) == 0 && (blocks[curr_x + 1][curr_y] & 0x1280180) == 0 && (blocks[curr_x][curr_y + 1] & 0x1280120) == 0) { + path_x[path_ptr] = curr_x + 1; + path_y[path_ptr] = curr_y + 1; + path_ptr = (path_ptr + 1) % pathLength; + prev[curr_x + 1][curr_y + 1] = 12; + dist[curr_x + 1][curr_y + 1] = cost; + } + } + return foundPath ? dist[curr_x][curr_y] : -1; + } catch (Exception e) { + return -1; + } + } + + + +} diff --git a/src/org/rev317/min/api/methods/Game.java b/src/main/java/org/rev317/min/api/methods/Game.java similarity index 95% rename from src/org/rev317/min/api/methods/Game.java rename to src/main/java/org/rev317/min/api/methods/Game.java index 648c1b4..a8da913 100644 --- a/src/org/rev317/min/api/methods/Game.java +++ b/src/main/java/org/rev317/min/api/methods/Game.java @@ -1,133 +1,133 @@ -package org.rev317.min.api.methods; - -import org.parabot.environment.api.utils.Time; -import org.parabot.environment.scripts.framework.SleepCondition; -import org.rev317.min.Loader; - -/** - * @author Everel, JKetelaar - */ -public class Game { - - /** - * Gets BaseX - * - * @return baseX - */ - public static int getBaseX() { - return Loader.getClient().getBaseX(); - } - - /** - * Gets BaseY - * - * @return baseY - */ - public static int getBaseY() { - return Loader.getClient().getBaseY(); - } - - /** - * Gets open interface id - * - * @return interface id - */ - public static int getOpenInterfaceId() { - return Loader.getClient().getOpenInterfaceId(); - } - - /** - * Get open back dialog id - * - * @return back dialog id - */ - public static int getOpenBackDialogId() { - return Loader.getClient().getBackDialogId(); - } - - /** - * Gets loop cycle - * - * @return loop cycle - */ - public static int getLoopCycle() { - return Loader.getClient().getLoopCycle(); - } - - /** - * Get collision flags - * - * @return collision flags - */ - public static int[][] getCollisionFlags() { - return Loader.getClient().getCollisionMap()[Game.getPlane()].getFlags(); - } - - /** - * Gets current plane - * - * @return current plane - */ - public static int getPlane() { - return Loader.getClient().getPlane(); - } - - /** - * Determines whether this client has action 4 hooked - * - * @return true if action 4 is hooked - */ - public static boolean hasAction4() { - try { - Loader.getClient().getMenuAction4(); - return true; - } catch (AbstractMethodError e) { - return false; - } - } - - /** - * Returns the settings within the client - * - * @param index The index of the setting you want to gather - * - * @return The specific setting for the given index - */ - public static int getSetting(int index){ - return Loader.getClient().getSettings()[index]; - } - - /** - * Returns all the settings within the client - * - * @return All settings - */ - public static int[] getSettings(){ - return Loader.getClient().getSettings(); - } - - /** - * Determines if the entity is logged in - * - * @return true if entity is logged in - */ - public static boolean isLoggedIn() { - return Loader.getClient().isLoggedIn(); - } - - /** - * Drops the client and returns if the game is logged out or not - * @return True if game is logged out, false if not - */ - public static boolean dropClient(){ - Loader.getClient().dropClient(); - Time.sleep(new SleepCondition() { - @Override - public boolean isValid() { - return isLoggedIn(); - } - }, 2500); - return !isLoggedIn(); - } - -} +package org.rev317.min.api.methods; + +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.SleepCondition; +import org.rev317.min.Loader; + +/** + * @author Everel, JKetelaar + */ +public class Game { + + /** + * Gets BaseX + * + * @return baseX + */ + public static int getBaseX() { + return Loader.getClient().getBaseX(); + } + + /** + * Gets BaseY + * + * @return baseY + */ + public static int getBaseY() { + return Loader.getClient().getBaseY(); + } + + /** + * Gets open interface id + * + * @return interface id + */ + public static int getOpenInterfaceId() { + return Loader.getClient().getOpenInterfaceId(); + } + + /** + * Get open back dialog id + * + * @return back dialog id + */ + public static int getOpenBackDialogId() { + return Loader.getClient().getBackDialogId(); + } + + /** + * Gets loop cycle + * + * @return loop cycle + */ + public static int getLoopCycle() { + return Loader.getClient().getLoopCycle(); + } + + /** + * Get collision flags + * + * @return collision flags + */ + public static int[][] getCollisionFlags() { + return Loader.getClient().getCollisionMap()[Game.getPlane()].getFlags(); + } + + /** + * Gets current plane + * + * @return current plane + */ + public static int getPlane() { + return Loader.getClient().getPlane(); + } + + /** + * Determines whether this client has action 4 hooked + * + * @return true if action 4 is hooked + */ + public static boolean hasAction4() { + try { + Loader.getClient().getMenuAction4(); + return true; + } catch (AbstractMethodError e) { + return false; + } + } + + /** + * Returns the settings within the client + * + * @param index The index of the setting you want to gather + * + * @return The specific setting for the given index + */ + public static int getSetting(int index){ + return Loader.getClient().getSettings()[index]; + } + + /** + * Returns all the settings within the client + * + * @return All settings + */ + public static int[] getSettings(){ + return Loader.getClient().getSettings(); + } + + /** + * Determines if the entity is logged in + * + * @return true if entity is logged in + */ + public static boolean isLoggedIn() { + return Loader.getClient().isLoggedIn(); + } + + /** + * Drops the client and returns if the game is logged out or not + * @return True if game is logged out, false if not + */ + public static boolean dropClient(){ + Loader.getClient().dropClient(); + Time.sleep(new SleepCondition() { + @Override + public boolean isValid() { + return isLoggedIn(); + } + }, 2500); + return !isLoggedIn(); + } + +} diff --git a/src/org/rev317/min/api/methods/GroundItems.java b/src/main/java/org/rev317/min/api/methods/GroundItems.java similarity index 96% rename from src/org/rev317/min/api/methods/GroundItems.java rename to src/main/java/org/rev317/min/api/methods/GroundItems.java index 5615313..39c81e9 100644 --- a/src/org/rev317/min/api/methods/GroundItems.java +++ b/src/main/java/org/rev317/min/api/methods/GroundItems.java @@ -1,176 +1,176 @@ -package org.rev317.min.api.methods; - -import org.parabot.core.Context; -import org.parabot.environment.api.utils.Filter; -import org.rev317.min.Loader; -import org.rev317.min.accessors.Client; -import org.rev317.min.accessors.Deque; -import org.rev317.min.accessors.Node; -import org.rev317.min.api.wrappers.GroundItem; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; - -/** - * @author Everel, JKetelaar - */ -public class GroundItems { - private static final Comparator NEAREST_SORTER = new Comparator() { - - @Override - public int compare(GroundItem n1, GroundItem n2) { - return n1.distanceTo() - n2.distanceTo(); - } - - }; - private static final Filter ALL_FILTER = new Filter() { - - @Override - public boolean accept(GroundItem item) { - return true; - } - - }; - private static Client client; - private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); - - /** - * Gets all loaded ground items - * - * @return ground item array - */ - public final static GroundItem[] getGroundItems( - final Filter filter) { - if (client == null) { - client = Loader.getClient(); - } - final ArrayList items = new ArrayList<>(); - for (int x = 0; x < 104; x++) { - for (int y = 0; y < 104; y++) { - final GroundItem[] groundItemsAtTile = getGroundItemsAt(x, y); - if (groundItemsAtTile != null) { - for (final GroundItem item : groundItemsAtTile) { - if (filter.accept(item)) { - items.add(item); - } - } - } - } - } - return items.toArray(new GroundItem[items.size()]); - } - - /** - * Gets a ground item - * - * @param x - local region x - * @param y - local region y - * - * @return ground item array - */ - public static final GroundItem[] getGroundItemsAt(final int x, final int y) { - try { - if (client == null) { - client = Loader.getClient(); - } - final Deque deque = client.getGroundItems()[Game.getPlane()][x][y]; - if (deque == null) { - return null; - } - ArrayList list = new ArrayList<>(); - final Node holder = deque.getHead(); - Node curNode = holder.getNext(); - while (curNode != null && curNode != holder - && curNode != deque.getHead()) { - final org.rev317.min.accessors.Item groundItem = (org.rev317.min.accessors.Item) curNode; - list.add(new GroundItem(groundItem, x, y)); - curNode = curNode.getNext(); - } - return list.toArray(new GroundItem[list.size()]); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * Gets all ground items in game - * - * @return ground items - */ - public static final GroundItem[] getGroundItems() { - return getGroundItems(ALL_FILTER); - } - - /** - * Returns array of GroundItems with the first index to be the nearest - * - * @param filter - * - * @return GroundItems - */ - public static final GroundItem[] getNearest(Filter filter) { - final GroundItem[] objects = getGroundItems(filter); - Arrays.sort(objects, NEAREST_SORTER); - return objects; - } - - /** - * Returns array of GroundItems with the first index to be the nearest - * - * @return GroundItems - */ - public static final GroundItem[] getNearest() { - return getNearest(ALL_FILTER); - } - - /** - * Returns nearest ground items with given id - * - * @param ids - * - * @return GroundItems - */ - public static final GroundItem[] getNearest(final int... ids) { - return getNearest(new Filter() { - - @Override - public boolean accept(GroundItem object) { - for (final int id : ids) { - if (id == object.getId()) { - return true; - } - } - return false; - } - - }); - } - - public enum Option{ - FIRST(settings.get("menu_ground_item_first_interaction")), - - SECOND(settings.get("menu_ground_item_second_interaction")), - - THIRD(settings.get("menu_ground_item_third_interaction")), - TAKE(settings.get("menu_ground_item_third_interaction")), - - FOURTH(settings.get("menu_ground_item_fourth_interaction")), - - FIFTH(settings.get("menu_ground_item_fifth_interaction")), - - EXAMINE(settings.get("menu_ground_item_examine_interaction")); - - int actionId; - - Option(int actionId) { - this.actionId = actionId; - } - - public int getActionId() { - return actionId; - } - } +package org.rev317.min.api.methods; + +import org.parabot.core.Context; +import org.parabot.environment.api.utils.Filter; +import org.rev317.min.Loader; +import org.rev317.min.accessors.Client; +import org.rev317.min.accessors.Deque; +import org.rev317.min.accessors.Node; +import org.rev317.min.api.wrappers.GroundItem; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; + +/** + * @author Everel, JKetelaar + */ +public class GroundItems { + private static final Comparator NEAREST_SORTER = new Comparator() { + + @Override + public int compare(GroundItem n1, GroundItem n2) { + return n1.distanceTo() - n2.distanceTo(); + } + + }; + private static final Filter ALL_FILTER = new Filter() { + + @Override + public boolean accept(GroundItem item) { + return true; + } + + }; + private static Client client; + private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); + + /** + * Gets all loaded ground items + * + * @return ground item array + */ + public final static GroundItem[] getGroundItems( + final Filter filter) { + if (client == null) { + client = Loader.getClient(); + } + final ArrayList items = new ArrayList<>(); + for (int x = 0; x < 104; x++) { + for (int y = 0; y < 104; y++) { + final GroundItem[] groundItemsAtTile = getGroundItemsAt(x, y); + if (groundItemsAtTile != null) { + for (final GroundItem item : groundItemsAtTile) { + if (filter.accept(item)) { + items.add(item); + } + } + } + } + } + return items.toArray(new GroundItem[items.size()]); + } + + /** + * Gets a ground item + * + * @param x - local region x + * @param y - local region y + * + * @return ground item array + */ + public static final GroundItem[] getGroundItemsAt(final int x, final int y) { + try { + if (client == null) { + client = Loader.getClient(); + } + final Deque deque = client.getGroundItems()[Game.getPlane()][x][y]; + if (deque == null) { + return null; + } + ArrayList list = new ArrayList<>(); + final Node holder = deque.getHead(); + Node curNode = holder.getNext(); + while (curNode != null && curNode != holder + && curNode != deque.getHead()) { + final org.rev317.min.accessors.Item groundItem = (org.rev317.min.accessors.Item) curNode; + list.add(new GroundItem(groundItem, x, y)); + curNode = curNode.getNext(); + } + return list.toArray(new GroundItem[list.size()]); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * Gets all ground items in game + * + * @return ground items + */ + public static final GroundItem[] getGroundItems() { + return getGroundItems(ALL_FILTER); + } + + /** + * Returns array of GroundItems with the first index to be the nearest + * + * @param filter + * + * @return GroundItems + */ + public static final GroundItem[] getNearest(Filter filter) { + final GroundItem[] objects = getGroundItems(filter); + Arrays.sort(objects, NEAREST_SORTER); + return objects; + } + + /** + * Returns array of GroundItems with the first index to be the nearest + * + * @return GroundItems + */ + public static final GroundItem[] getNearest() { + return getNearest(ALL_FILTER); + } + + /** + * Returns nearest ground items with given id + * + * @param ids + * + * @return GroundItems + */ + public static final GroundItem[] getNearest(final int... ids) { + return getNearest(new Filter() { + + @Override + public boolean accept(GroundItem object) { + for (final int id : ids) { + if (id == object.getId()) { + return true; + } + } + return false; + } + + }); + } + + public enum Option{ + FIRST(settings.get("menu_ground_item_first_interaction")), + + SECOND(settings.get("menu_ground_item_second_interaction")), + + THIRD(settings.get("menu_ground_item_third_interaction")), + TAKE(settings.get("menu_ground_item_third_interaction")), + + FOURTH(settings.get("menu_ground_item_fourth_interaction")), + + FIFTH(settings.get("menu_ground_item_fifth_interaction")), + + EXAMINE(settings.get("menu_ground_item_examine_interaction")); + + int actionId; + + Option(int actionId) { + this.actionId = actionId; + } + + public int getActionId() { + return actionId; + } + } } \ No newline at end of file diff --git a/src/org/rev317/min/api/methods/Interfaces.java b/src/main/java/org/rev317/min/api/methods/Interfaces.java similarity index 100% rename from src/org/rev317/min/api/methods/Interfaces.java rename to src/main/java/org/rev317/min/api/methods/Interfaces.java diff --git a/src/org/rev317/min/api/methods/Inventory.java b/src/main/java/org/rev317/min/api/methods/Inventory.java similarity index 96% rename from src/org/rev317/min/api/methods/Inventory.java rename to src/main/java/org/rev317/min/api/methods/Inventory.java index 624b329..a2a3e66 100644 --- a/src/org/rev317/min/api/methods/Inventory.java +++ b/src/main/java/org/rev317/min/api/methods/Inventory.java @@ -1,299 +1,299 @@ -package org.rev317.min.api.methods; - -import org.parabot.core.Context; -import org.parabot.environment.api.utils.Filter; -import org.parabot.environment.api.utils.Time; -import org.parabot.environment.scripts.framework.SleepCondition; -import org.rev317.min.Loader; -import org.rev317.min.accessors.Interface; -import org.rev317.min.api.wrappers.Item; - -import java.util.ArrayList; -import java.util.HashMap; - - -/** - * @author Everel, JKetelaar, Fryslan - */ -public class Inventory { - - private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); - - private static final Filter ALL_FILTER = new Filter() { - - @Override - public boolean accept(Item i) { - return true; - } - - }; - - /** - * Clears the inventory - */ - public static void clear() { - for (Item item : Inventory.getItems()) { - item.drop(); - Time.sleep(60, 80); - } - } - - /** - * Clears the inventory except for certain item ids - * - * @param ids The ids that should not be cleared - */ - public static void clearExcept(int... ids) { - for (Item item : getItems()) { - for (int id : ids) { - if (item.getId() != id) { - item.drop(); - } - } - } - } - - /** - * Gets inventory interface - * - * @return interface of inventory - */ - public static Interface getInterface() { - return Loader.getClient().getInterfaceCache()[settings.get("inventory_index")]; - } - - /** - * Gets the amount of items in inventory, excludes the stack sizes - * - * @return amount of items - */ - public static int getCount() { - return getCount(false); - } - - /** - * Gets the amount of items with given ids in inventory, excludes the stack sizes - * - * @param ids - * - * @return amount of items - */ - public static int getCount(int... ids) { - return getCount(false, ids); - } - - /** - * Gets the amount of items in inventory - * - * @param includeStack - true for including stack sizes to the counting - * - * @return amount of items - */ - public static int getCount(final boolean includeStack) { - final Interface inventory = getInterface(); - if (inventory == null) { - return -1; - } - int count = 0; - final int[] items = inventory.getItems(); - final int[] stackSizes = includeStack ? inventory.getStackSizes() : null; - for (int i = 0; i < items.length; i++) { - if (items[i] > 0) { - count += includeStack ? stackSizes[i] : 1; - } - } - return count; - } - - /** - * Gets the amount of items with given ids in inventory - * - * @param includeStack - true for including stack sizes to the counting - * @param ids - * - * @return amount of items - */ - public static int getCount(final boolean includeStack, int... ids) { - final Interface inventory = getInterface(); - if (inventory == null) { - return -1; - } - int count = 0; - final int[] items = inventory.getItems(); - final int[] stackSizes = includeStack ? inventory.getStackSizes() : null; - for (int i = 0; i < items.length; i++) { - final int itemId = items[i]; - if (itemId > 0) { - for (final int id : ids) { - if (id == itemId) { - count += includeStack ? stackSizes[i] : 1; - break; - } - } - } - } - return count; - } - - /** - * Gets every item in inventory - * - * @return items - */ - public static Item[] getItems() { - return getItems(ALL_FILTER); - } - - /** - * Gets all items with given ids - * - * @param ids - * - * @return items - */ - public static Item[] getItems(final int... ids) { - return getItems(new Filter() { - - @Override - public boolean accept(Item e) { - for (int id : ids) { - if (e.getId() == id) { - return true; - } - } - return false; - } - - }); - } - - /** - * Gets all items accepted by filter - * - * @param filter - * - * @return items - */ - public static Item[] getItems(final Filter filter) { - final Interface inventory = getInterface(); - if (inventory == null) { - return null; - } - final int[] items = inventory.getItems(); - final int[] stackSizes = inventory.getStackSizes(); - final ArrayList invItems = new ArrayList<>(28); - for (int i = 0; i < items.length; i++) { - final int itemId = items[i]; - if (itemId < 1) { - continue; - } - final int stackSize = stackSizes[i]; - final Item item = new Item(itemId, stackSize, i); - if (filter.accept(item)) { - invItems.add(item); - } - } - return invItems.toArray(new Item[invItems.size()]); - } - - /** - * Determines if inventory is full - * - * @return true if inventory is full, otherwise false - */ - public static boolean isFull() { - return Inventory.getCount() == 28; - } - - /** - * Determines if inventory is empty - * - * @return true if inventory is empty, otherwise false - */ - public static boolean isEmpty() { - return Inventory.getCount() == 0; - } - - /** - * Checks if an item exists in the inventory - * - * @param id The item id that will be looked for - * - * @return True if the item exists in the inventory - */ - public static boolean contains(int... id) { - return getCount(id) > 0; - } - - @Deprecated - public static boolean containts(int... id) { - return contains(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 - * - * @return First found item in the inventory - */ - public static Item getItem(int id) { - for (Item i : getItems(id)) { - if (i != null) { - return i; - } - } - return null; - } - - /** - * Combines two items by using it on each other - * - * @param itemOne The first 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 - */ - public static boolean combine(int itemOne, int itemTwo) { - Item io = getItem(itemOne); - Item it = getItem(itemTwo); - - if (io != null) { - if (it != null) { - Menu.interact(io, Items.Option.USE.getActionId()); - Time.sleep(50, 100); - Menu.interact(it, Items.Option.USE_WITH.getActionId()); - Time.sleep(50, 100); - return true; - } - } - return false; - } - - /** - * Combines two items by using it on each other - * - * @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 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 - */ - public static boolean combine(int itemOne, int itemTwo, SleepCondition sleepCondition) { - Item io = getItem(itemOne); - Item it = getItem(itemTwo); - - if (io != null) { - if (it != null) { - Menu.interact(io, Items.Option.USE.getActionId()); - Time.sleep(50, 100); - Menu.interact(it, Items.Option.USE_WITH.getActionId()); - Time.sleep(50, 100); - sleepCondition.isValid(); - return true; - } - } - return false; - } -} - +package org.rev317.min.api.methods; + +import org.parabot.core.Context; +import org.parabot.environment.api.utils.Filter; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.SleepCondition; +import org.rev317.min.Loader; +import org.rev317.min.accessors.Interface; +import org.rev317.min.api.wrappers.Item; + +import java.util.ArrayList; +import java.util.HashMap; + + +/** + * @author Everel, JKetelaar, Fryslan + */ +public class Inventory { + + private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); + + private static final Filter ALL_FILTER = new Filter() { + + @Override + public boolean accept(Item i) { + return true; + } + + }; + + /** + * Clears the inventory + */ + public static void clear() { + for (Item item : Inventory.getItems()) { + item.drop(); + Time.sleep(60, 80); + } + } + + /** + * Clears the inventory except for certain item ids + * + * @param ids The ids that should not be cleared + */ + public static void clearExcept(int... ids) { + for (Item item : getItems()) { + for (int id : ids) { + if (item.getId() != id) { + item.drop(); + } + } + } + } + + /** + * Gets inventory interface + * + * @return interface of inventory + */ + public static Interface getInterface() { + return Loader.getClient().getInterfaceCache()[settings.get("inventory_index")]; + } + + /** + * Gets the amount of items in inventory, excludes the stack sizes + * + * @return amount of items + */ + public static int getCount() { + return getCount(false); + } + + /** + * Gets the amount of items with given ids in inventory, excludes the stack sizes + * + * @param ids + * + * @return amount of items + */ + public static int getCount(int... ids) { + return getCount(false, ids); + } + + /** + * Gets the amount of items in inventory + * + * @param includeStack - true for including stack sizes to the counting + * + * @return amount of items + */ + public static int getCount(final boolean includeStack) { + final Interface inventory = getInterface(); + if (inventory == null) { + return -1; + } + int count = 0; + final int[] items = inventory.getItems(); + final int[] stackSizes = includeStack ? inventory.getStackSizes() : null; + for (int i = 0; i < items.length; i++) { + if (items[i] > 0) { + count += includeStack ? stackSizes[i] : 1; + } + } + return count; + } + + /** + * Gets the amount of items with given ids in inventory + * + * @param includeStack - true for including stack sizes to the counting + * @param ids + * + * @return amount of items + */ + public static int getCount(final boolean includeStack, int... ids) { + final Interface inventory = getInterface(); + if (inventory == null) { + return -1; + } + int count = 0; + final int[] items = inventory.getItems(); + final int[] stackSizes = includeStack ? inventory.getStackSizes() : null; + for (int i = 0; i < items.length; i++) { + final int itemId = items[i]; + if (itemId > 0) { + for (final int id : ids) { + if (id == itemId) { + count += includeStack ? stackSizes[i] : 1; + break; + } + } + } + } + return count; + } + + /** + * Gets every item in inventory + * + * @return items + */ + public static Item[] getItems() { + return getItems(ALL_FILTER); + } + + /** + * Gets all items with given ids + * + * @param ids + * + * @return items + */ + public static Item[] getItems(final int... ids) { + return getItems(new Filter() { + + @Override + public boolean accept(Item e) { + for (int id : ids) { + if (e.getId() == id) { + return true; + } + } + return false; + } + + }); + } + + /** + * Gets all items accepted by filter + * + * @param filter + * + * @return items + */ + public static Item[] getItems(final Filter filter) { + final Interface inventory = getInterface(); + if (inventory == null) { + return null; + } + final int[] items = inventory.getItems(); + final int[] stackSizes = inventory.getStackSizes(); + final ArrayList invItems = new ArrayList<>(28); + for (int i = 0; i < items.length; i++) { + final int itemId = items[i]; + if (itemId < 1) { + continue; + } + final int stackSize = stackSizes[i]; + final Item item = new Item(itemId, stackSize, i); + if (filter.accept(item)) { + invItems.add(item); + } + } + return invItems.toArray(new Item[invItems.size()]); + } + + /** + * Determines if inventory is full + * + * @return true if inventory is full, otherwise false + */ + public static boolean isFull() { + return Inventory.getCount() == 28; + } + + /** + * Determines if inventory is empty + * + * @return true if inventory is empty, otherwise false + */ + public static boolean isEmpty() { + return Inventory.getCount() == 0; + } + + /** + * Checks if an item exists in the inventory + * + * @param id The item id that will be looked for + * + * @return True if the item exists in the inventory + */ + public static boolean contains(int... id) { + return getCount(id) > 0; + } + + @Deprecated + public static boolean containts(int... id) { + return contains(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 + * + * @return First found item in the inventory + */ + public static Item getItem(int id) { + for (Item i : getItems(id)) { + if (i != null) { + return i; + } + } + return null; + } + + /** + * Combines two items by using it on each other + * + * @param itemOne The first 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 + */ + public static boolean combine(int itemOne, int itemTwo) { + Item io = getItem(itemOne); + Item it = getItem(itemTwo); + + if (io != null) { + if (it != null) { + Menu.interact(io, Items.Option.USE.getActionId()); + Time.sleep(50, 100); + Menu.interact(it, Items.Option.USE_WITH.getActionId()); + Time.sleep(50, 100); + return true; + } + } + return false; + } + + /** + * Combines two items by using it on each other + * + * @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 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 + */ + public static boolean combine(int itemOne, int itemTwo, SleepCondition sleepCondition) { + Item io = getItem(itemOne); + Item it = getItem(itemTwo); + + if (io != null) { + if (it != null) { + Menu.interact(io, Items.Option.USE.getActionId()); + Time.sleep(50, 100); + Menu.interact(it, Items.Option.USE_WITH.getActionId()); + Time.sleep(50, 100); + sleepCondition.isValid(); + return true; + } + } + return false; + } +} + diff --git a/src/org/rev317/min/api/methods/Items.java b/src/main/java/org/rev317/min/api/methods/Items.java similarity index 100% rename from src/org/rev317/min/api/methods/Items.java rename to src/main/java/org/rev317/min/api/methods/Items.java diff --git a/src/org/rev317/min/api/methods/Menu.java b/src/main/java/org/rev317/min/api/methods/Menu.java similarity index 100% rename from src/org/rev317/min/api/methods/Menu.java rename to src/main/java/org/rev317/min/api/methods/Menu.java diff --git a/src/org/rev317/min/api/methods/Npcs.java b/src/main/java/org/rev317/min/api/methods/Npcs.java similarity index 96% rename from src/org/rev317/min/api/methods/Npcs.java rename to src/main/java/org/rev317/min/api/methods/Npcs.java index 6cc5720..b84ae79 100644 --- a/src/org/rev317/min/api/methods/Npcs.java +++ b/src/main/java/org/rev317/min/api/methods/Npcs.java @@ -1,181 +1,181 @@ -package org.rev317.min.api.methods; - -import org.parabot.core.Context; -import org.parabot.environment.api.utils.Filter; -import org.rev317.min.Loader; -import org.rev317.min.accessors.Client; -import org.rev317.min.api.wrappers.Npc; - -import java.util.*; - -/** - * @author Everel, JKetelaar - */ -public class Npcs { - - private static final Comparator NEAREST_SORTER = new Comparator() { - - @Override - public int compare(Npc n1, Npc n2) { - return n1.distanceTo() - n2.distanceTo(); - } - - }; - - private static final Filter ALL_FILTER = new Filter() { - - @Override - public boolean accept(Npc n) { - return true; - } - - }; - private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); - - /** - * Gets all Npcs except local Npc - * - * @param filter - * - * @return all Npcs - */ - public static final Npc[] getNpcs(final Filter filter) { - final Client client = Loader.getClient(); - ArrayList npcList = new ArrayList<>(); - final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs(); - for (int i = 0; i < accNpcs.length; i++) { - if (accNpcs[i] == null) { - continue; - } - final Npc npc = new Npc(accNpcs[i], i); - if (filter.accept(npc)) { - npcList.add(npc); - } - } - return npcList.toArray(new Npc[npcList.size()]); - } - - /** - * Gets all Npcs - * - * @return all Npcs - */ - public static final Npc[] getNpcs() { - return getNpcs(ALL_FILTER); - } - - /** - * Gets the closest npc which matches the given filter - * - * @param filter - * - * @return closest npc - */ - public static final Npc getClosest(final Filter filter) { - Npc[] npcs = getNearest(filter); - if (npcs == null || npcs.length == 0) { - return null; - } - return npcs[0]; - } - - /** - * Gets the closest npc which matches the given ids - * - * @param ids - * - * @return closest npc - */ - public static final Npc getClosest(int... ids) { - Npc[] npcs = getNearest(ids); - if (npcs == null || npcs.length == 0) { - return null; - } - return npcs[0]; - } - - /** - * Returns array with the first index to be the nearest Npc - * - * @param filter - * - * @return nearest Npcs - */ - public static final Npc[] getNearest(final Filter filter) { - final Npc[] npcs = getNpcs(filter); - Arrays.sort(npcs, NEAREST_SORTER); - return npcs; - } - - /** - * Gets nearest npcs which hold given id(s) - * - * @param ids - * - * @return array of npcs with the first index to be the nearest - */ - public static final Npc[] getNearest(final int... ids) { - final Npc[] npcs = getNpcs(new Filter() { - - @Override - public boolean accept(Npc npc) { - for (final int id : ids) { - if (id == npc.getDef().getId()) { - return true; - } - } - return false; - } - - }); - Arrays.sort(npcs, NEAREST_SORTER); - return npcs; - } - - /** - * Returns array with the first index to be the nearest Npc - * - * @return nearest Npcs - */ - public static final Npc[] getNearest() { - return getNearest(ALL_FILTER); - } - - public enum Option{ - FIRST(settings.get("menu_character_first_interaction")), - ATTACK(settings.get("menu_character_first_interaction")), - - SECOND(settings.get("menu_character_second_interaction")), - TALK_TO(settings.get("menu_character_second_interaction")), - INTERACT(settings.get("menu_character_second_interaction")), - BAIT(settings.get("menu_character_second_interaction")), - CAGE(settings.get("menu_character_second_interaction")), - NET(settings.get("menu_character_second_interaction")), - - THIRD(settings.get("menu_character_third_interaction")), - TRADE(settings.get("menu_character_third_interaction")), - BANK(settings.get("menu_character_third_interaction")), - PICKPOCKET(settings.get("menu_character_third_interaction")), - HARPOON(settings.get("menu_character_third_interaction")), - GET_TASK(settings.get("menu_character_third_interaction")), - - FOURTH(settings.get("menu_character_fourth_interaction")), - COLLECT(settings.get("menu_character_fourth_interaction")), - CHANGE_CLOTHES(settings.get("menu_character_fourth_interaction")), - - FIFTH(settings.get("menu_character_fifth_interaction")), - REWARD(settings.get("menu_character_fifth_interaction")), - - EXAMINE(settings.get("menu_character_examine")); - - int actionId; - - Option(int actionId) { - this.actionId = actionId; - } - - public int getActionId() { - return actionId; - } - } -} +package org.rev317.min.api.methods; + +import org.parabot.core.Context; +import org.parabot.environment.api.utils.Filter; +import org.rev317.min.Loader; +import org.rev317.min.accessors.Client; +import org.rev317.min.api.wrappers.Npc; + +import java.util.*; + +/** + * @author Everel, JKetelaar + */ +public class Npcs { + + private static final Comparator NEAREST_SORTER = new Comparator() { + + @Override + public int compare(Npc n1, Npc n2) { + return n1.distanceTo() - n2.distanceTo(); + } + + }; + + private static final Filter ALL_FILTER = new Filter() { + + @Override + public boolean accept(Npc n) { + return true; + } + + }; + private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); + + /** + * Gets all Npcs except local Npc + * + * @param filter + * + * @return all Npcs + */ + public static final Npc[] getNpcs(final Filter filter) { + final Client client = Loader.getClient(); + ArrayList npcList = new ArrayList<>(); + final org.rev317.min.accessors.Npc[] accNpcs = client.getNpcs(); + for (int i = 0; i < accNpcs.length; i++) { + if (accNpcs[i] == null) { + continue; + } + final Npc npc = new Npc(accNpcs[i], i); + if (filter.accept(npc)) { + npcList.add(npc); + } + } + return npcList.toArray(new Npc[npcList.size()]); + } + + /** + * Gets all Npcs + * + * @return all Npcs + */ + public static final Npc[] getNpcs() { + return getNpcs(ALL_FILTER); + } + + /** + * Gets the closest npc which matches the given filter + * + * @param filter + * + * @return closest npc + */ + public static final Npc getClosest(final Filter filter) { + Npc[] npcs = getNearest(filter); + if (npcs == null || npcs.length == 0) { + return null; + } + return npcs[0]; + } + + /** + * Gets the closest npc which matches the given ids + * + * @param ids + * + * @return closest npc + */ + public static final Npc getClosest(int... ids) { + Npc[] npcs = getNearest(ids); + if (npcs == null || npcs.length == 0) { + return null; + } + return npcs[0]; + } + + /** + * Returns array with the first index to be the nearest Npc + * + * @param filter + * + * @return nearest Npcs + */ + public static final Npc[] getNearest(final Filter filter) { + final Npc[] npcs = getNpcs(filter); + Arrays.sort(npcs, NEAREST_SORTER); + return npcs; + } + + /** + * Gets nearest npcs which hold given id(s) + * + * @param ids + * + * @return array of npcs with the first index to be the nearest + */ + public static final Npc[] getNearest(final int... ids) { + final Npc[] npcs = getNpcs(new Filter() { + + @Override + public boolean accept(Npc npc) { + for (final int id : ids) { + if (id == npc.getDef().getId()) { + return true; + } + } + return false; + } + + }); + Arrays.sort(npcs, NEAREST_SORTER); + return npcs; + } + + /** + * Returns array with the first index to be the nearest Npc + * + * @return nearest Npcs + */ + public static final Npc[] getNearest() { + return getNearest(ALL_FILTER); + } + + public enum Option{ + FIRST(settings.get("menu_character_first_interaction")), + ATTACK(settings.get("menu_character_first_interaction")), + + SECOND(settings.get("menu_character_second_interaction")), + TALK_TO(settings.get("menu_character_second_interaction")), + INTERACT(settings.get("menu_character_second_interaction")), + BAIT(settings.get("menu_character_second_interaction")), + CAGE(settings.get("menu_character_second_interaction")), + NET(settings.get("menu_character_second_interaction")), + + THIRD(settings.get("menu_character_third_interaction")), + TRADE(settings.get("menu_character_third_interaction")), + BANK(settings.get("menu_character_third_interaction")), + PICKPOCKET(settings.get("menu_character_third_interaction")), + HARPOON(settings.get("menu_character_third_interaction")), + GET_TASK(settings.get("menu_character_third_interaction")), + + FOURTH(settings.get("menu_character_fourth_interaction")), + COLLECT(settings.get("menu_character_fourth_interaction")), + CHANGE_CLOTHES(settings.get("menu_character_fourth_interaction")), + + FIFTH(settings.get("menu_character_fifth_interaction")), + REWARD(settings.get("menu_character_fifth_interaction")), + + EXAMINE(settings.get("menu_character_examine")); + + int actionId; + + Option(int actionId) { + this.actionId = actionId; + } + + public int getActionId() { + return actionId; + } + } +} diff --git a/src/org/rev317/min/api/methods/Players.java b/src/main/java/org/rev317/min/api/methods/Players.java similarity index 96% rename from src/org/rev317/min/api/methods/Players.java rename to src/main/java/org/rev317/min/api/methods/Players.java index c5edd07..9f0a574 100644 --- a/src/org/rev317/min/api/methods/Players.java +++ b/src/main/java/org/rev317/min/api/methods/Players.java @@ -1,128 +1,128 @@ -package org.rev317.min.api.methods; - -import org.parabot.core.Context; -import org.parabot.environment.api.utils.Filter; -import org.rev317.min.Loader; -import org.rev317.min.accessors.Client; -import org.rev317.min.api.wrappers.Player; - -import java.util.*; - -/** - * @author Everel, JKetelaar - */ -public class Players { - - private static final Comparator NEAREST_SORTER = new Comparator() { - - @Override - public int compare(Player p1, Player p2) { - return p1.distanceTo() - p2.distanceTo(); - } - - }; - - private static final Filter ALL_FILTER = new Filter() { - - @Override - public boolean accept(Player p) { - return true; - } - - }; - private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); - - /** - * Gets all players except local player - * - * @param filter - * - * @return all players - */ - public static final Player[] getPlayers(final Filter filter) { - final Client client = Loader.getClient(); - ArrayList playerList = new ArrayList(); - final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers(); - for (int i = 0; i < accPlayers.length; i++) { - if (accPlayers[i] == null) { - continue; - } - final Player player = new Player(accPlayers[i], i); - if (filter.accept(player)) { - playerList.add(player); - } - } - return playerList.toArray(new Player[playerList.size()]); - } - - /** - * Gets all players except local player - * - * @return all players - */ - public static final Player[] getPlayers() { - return getPlayers(ALL_FILTER); - } - - /** - * Returns array with the first index to be the nearest player - * - * @param filter - * - * @return nearest players - */ - public static final Player[] getNearest(final Filter filter) { - final Player[] players = getPlayers(filter); - Arrays.sort(players, NEAREST_SORTER); - return players; - } - - /** - * Returns array with the first index to be the nearest player - * - * @return nearest players - */ - public static final Player[] getNearest() { - return getNearest(ALL_FILTER); - } - - /** - * Gets local player - * - * @return local player - */ - public static Player getMyPlayer() { - return new Player(Loader.getClient().getMyPlayer(), -1); - } - - public enum Option{ - FIRST(settings.get("menu_character_first_interaction")), - - SECOND(settings.get("menu_character_second_interaction")), - - THIRD(settings.get("menu_character_third_interaction")), - - FOURTH(settings.get("menu_character_fourth_interaction")), - - FIFTH(settings.get("menu_character_fifth_interaction")), - - FOLLOW(settings.get("menu_character_follow")), - - TRADE(settings.get("menu_character_trade")), - - ATTACK(settings.get("menu_character_attack")), - CHALLENGE(settings.get("menu_character_attack")), - - EXAMINE(settings.get("menu_character_examine")); - - int actionId; - - Option(int actionId) { - this.actionId = actionId; - } - - public int getActionId() { - return actionId; - } - } +package org.rev317.min.api.methods; + +import org.parabot.core.Context; +import org.parabot.environment.api.utils.Filter; +import org.rev317.min.Loader; +import org.rev317.min.accessors.Client; +import org.rev317.min.api.wrappers.Player; + +import java.util.*; + +/** + * @author Everel, JKetelaar + */ +public class Players { + + private static final Comparator NEAREST_SORTER = new Comparator() { + + @Override + public int compare(Player p1, Player p2) { + return p1.distanceTo() - p2.distanceTo(); + } + + }; + + private static final Filter ALL_FILTER = new Filter() { + + @Override + public boolean accept(Player p) { + return true; + } + + }; + private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); + + /** + * Gets all players except local player + * + * @param filter + * + * @return all players + */ + public static final Player[] getPlayers(final Filter filter) { + final Client client = Loader.getClient(); + ArrayList playerList = new ArrayList(); + final org.rev317.min.accessors.Player[] accPlayers = client.getPlayers(); + for (int i = 0; i < accPlayers.length; i++) { + if (accPlayers[i] == null) { + continue; + } + final Player player = new Player(accPlayers[i], i); + if (filter.accept(player)) { + playerList.add(player); + } + } + return playerList.toArray(new Player[playerList.size()]); + } + + /** + * Gets all players except local player + * + * @return all players + */ + public static final Player[] getPlayers() { + return getPlayers(ALL_FILTER); + } + + /** + * Returns array with the first index to be the nearest player + * + * @param filter + * + * @return nearest players + */ + public static final Player[] getNearest(final Filter filter) { + final Player[] players = getPlayers(filter); + Arrays.sort(players, NEAREST_SORTER); + return players; + } + + /** + * Returns array with the first index to be the nearest player + * + * @return nearest players + */ + public static final Player[] getNearest() { + return getNearest(ALL_FILTER); + } + + /** + * Gets local player + * + * @return local player + */ + public static Player getMyPlayer() { + return new Player(Loader.getClient().getMyPlayer(), -1); + } + + public enum Option{ + FIRST(settings.get("menu_character_first_interaction")), + + SECOND(settings.get("menu_character_second_interaction")), + + THIRD(settings.get("menu_character_third_interaction")), + + FOURTH(settings.get("menu_character_fourth_interaction")), + + FIFTH(settings.get("menu_character_fifth_interaction")), + + FOLLOW(settings.get("menu_character_follow")), + + TRADE(settings.get("menu_character_trade")), + + ATTACK(settings.get("menu_character_attack")), + CHALLENGE(settings.get("menu_character_attack")), + + EXAMINE(settings.get("menu_character_examine")); + + int actionId; + + Option(int actionId) { + this.actionId = actionId; + } + + public int getActionId() { + return actionId; + } + } } \ No newline at end of file diff --git a/src/org/rev317/min/api/methods/Prayer.java b/src/main/java/org/rev317/min/api/methods/Prayer.java similarity index 100% rename from src/org/rev317/min/api/methods/Prayer.java rename to src/main/java/org/rev317/min/api/methods/Prayer.java diff --git a/src/org/rev317/min/api/methods/SceneObjects.java b/src/main/java/org/rev317/min/api/methods/SceneObjects.java similarity index 97% rename from src/org/rev317/min/api/methods/SceneObjects.java rename to src/main/java/org/rev317/min/api/methods/SceneObjects.java index a16ef67..e2b5cb8 100644 --- a/src/org/rev317/min/api/methods/SceneObjects.java +++ b/src/main/java/org/rev317/min/api/methods/SceneObjects.java @@ -1,271 +1,271 @@ -package org.rev317.min.api.methods; - -import org.parabot.core.Context; -import org.parabot.environment.api.utils.Filter; -import org.rev317.min.Loader; -import org.rev317.min.accessors.Ground; -import org.rev317.min.accessors.SceneObjectTile; -import org.rev317.min.api.wrappers.SceneObject; - -import java.util.*; - -/** - * @author Everel, JKetelaar - */ -public class SceneObjects { - - private static final Comparator NEAREST_SORTER = new Comparator() { - - @Override - public int compare(SceneObject n1, SceneObject n2) { - return n1.distanceTo() - n2.distanceTo(); - } - - }; - - private static final Filter ALL_FILTER = new Filter() { - - @Override - public boolean accept(SceneObject object) { - return true; - } - - }; - private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); - - /** - * Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall - * decorations, ground decorations' - * - * @return scene objects - */ - public static final SceneObject[] getSceneObjects(Filter filter) { - ArrayList sceneObjects = new ArrayList(); - for (int x = 0; x < 104; x++) { - for (int y = 0; y < 104; y++) { - final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true); - if (sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) { - sceneObjects.add(sceneObjectAtTile); - } - - } - } - return sceneObjects.toArray(new SceneObject[sceneObjects.size()]); - } - - /** - * Gets the most important scene objects in game which can be interacted with - * - * @return scene objects - */ - public static final SceneObject[] getSceneObjects() { - return getSceneObjects(ALL_FILTER); - } - - /** - * Returns array of sceneobjects with the first index to be the nearest - * - * @param filter - * - * @return sceneobjects - */ - public static final SceneObject[] getNearest(Filter filter) { - final SceneObject[] objects = getSceneObjects(filter); - Arrays.sort(objects, NEAREST_SORTER); - return objects; - } - - /** - * Returns array of sceneobjects with the first index to be the nearest - * - * @return sceneobjects - */ - public static final SceneObject[] getNearest() { - return getNearest(ALL_FILTER); - } - - /** - * Returns nearest objects with given id - * - * @param ids - * - * @return sceneobjects - */ - public static final SceneObject[] getNearest(final int... ids) { - return getNearest(new Filter() { - - @Override - public boolean accept(SceneObject object) { - for (final int id : ids) { - if (id == object.getId()) { - return true; - } - } - return false; - } - - }); - } - - public static final SceneObject getClosest(final int... ids) { - SceneObject[] nearestObjects = getNearest(new Filter() { - - @Override - public boolean accept(SceneObject object) { - for (final int id : ids) { - if (id == object.getId()) { - 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) { - 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; - } - - /** - * Gets every loaded scene object in game - * - * @return every loaded scene object in game - */ - public static final SceneObject[] getAllSceneObjects() { - ArrayList sceneObjects = new ArrayList(); - for (int x = 0; x < 104; x++) { - for (int y = 0; y < 104; y++) { - final Collection sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true); - if (sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) { - sceneObjects.addAll(sceneObjectsAtTile); - } - } - } - return sceneObjects.toArray(new SceneObject[sceneObjects.size()]); - } - - /** - * Gets all sceneobjects at a tile - * - * @param x - * @param y - * @param useCached - * - * @return array of sceneobjects, or null if there aren't any - */ - public static final Collection getSceneObjectsAtTile(int x, int y, boolean useCached) { - Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y]; - ArrayList sceneObjects = null; - if (sceneTile != null) { - final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects(); - if (interactiveObjects != null) { - for (final SceneObjectTile interactiveObject : interactiveObjects) { - if (interactiveObject != null) { - if (sceneObjects == null) { - sceneObjects = new ArrayList<>(); - } - sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE)); - } - } - } - SceneObjectTile sceneObjectTile = sceneTile.getWallObject(); - if (sceneObjectTile != null) { - if (sceneObjects == null) { - sceneObjects = new ArrayList<>(); - } - sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL)); - } - - sceneObjectTile = sceneTile.getWallDecoration(); - if (sceneObjectTile != null) { - if (sceneObjects == null) { - sceneObjects = new ArrayList<>(); - } - sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION)); - } - - sceneObjectTile = sceneTile.getGroundDecoration(); - if (sceneObjectTile != null) { - if (sceneObjects == null) { - sceneObjects = new ArrayList<>(); - } - sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION)); - } - - sceneObjectTile = sceneTile.getGroundItem(); - if (sceneObjectTile != null) { - if (sceneObjects == null) { - sceneObjects = new ArrayList<>(); - } - 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")), - CHOP_DOWN(settings.get("menu_scene_object_first_interaction")), - CRAFT_RUNE(settings.get("menu_scene_object_first_interaction")), - PRAY_AT(settings.get("menu_scene_object_first_interaction")), - OPEN(settings.get("menu_scene_object_first_interaction")), - DEPOSIT(settings.get("menu_scene_object_first_interaction")), - USE(settings.get("menu_scene_object_first_interaction")), - SEARCH(settings.get("menu_scene_object_first_interaction")), - CLOSE(settings.get("menu_scene_object_first_interaction")), - CROSS(settings.get("menu_scene_object_first_interaction")), - MINE(settings.get("menu_scene_object_first_interaction")), - SMELT(settings.get("menu_scene_object_first_interaction")), - - SECOND(settings.get("menu_scene_object_second_interaction")), - TELEPORT(settings.get("menu_scene_object_second_interaction")), - STEAL_FROM(settings.get("menu_scene_object_second_interaction")), - PRAY(settings.get("menu_scene_object_second_interaction")), - USE_QUICKLY(settings.get("menu_scene_object_second_interaction")), - INSPECT(settings.get("menu_scene_object_second_interaction")), - - THIRD(settings.get("menu_scene_object_third_interaction")), - - FOURTH(settings.get("menu_scene_object_fourth_interaction")), - GUIDE(settings.get("menu_scene_object_fourth_interaction")), - - FIFTH(settings.get("menu_scene_object_fifth_interaction")), - - EXAMINE(settings.get("menu_scene_object_examine")); - - int actionId; - - Option(int actionId) { - this.actionId = actionId; - } - - public int getActionId() { - return actionId; - } - } - -} - +package org.rev317.min.api.methods; + +import org.parabot.core.Context; +import org.parabot.environment.api.utils.Filter; +import org.rev317.min.Loader; +import org.rev317.min.accessors.Ground; +import org.rev317.min.accessors.SceneObjectTile; +import org.rev317.min.api.wrappers.SceneObject; + +import java.util.*; + +/** + * @author Everel, JKetelaar + */ +public class SceneObjects { + + private static final Comparator NEAREST_SORTER = new Comparator() { + + @Override + public int compare(SceneObject n1, SceneObject n2) { + return n1.distanceTo() - n2.distanceTo(); + } + + }; + + private static final Filter ALL_FILTER = new Filter() { + + @Override + public boolean accept(SceneObject object) { + return true; + } + + }; + private static HashMap settings = Context.getInstance().getServerProviderInfo().getSettings(); + + /** + * Gets the most important scene objects in game which can be interacted with, filters out: 'walls, wall + * decorations, ground decorations' + * + * @return scene objects + */ + public static final SceneObject[] getSceneObjects(Filter filter) { + ArrayList sceneObjects = new ArrayList(); + for (int x = 0; x < 104; x++) { + for (int y = 0; y < 104; y++) { + final SceneObject sceneObjectAtTile = getSceneObjectAtTile(x, y, true); + if (sceneObjectAtTile != null && filter.accept(sceneObjectAtTile)) { + sceneObjects.add(sceneObjectAtTile); + } + + } + } + return sceneObjects.toArray(new SceneObject[sceneObjects.size()]); + } + + /** + * Gets the most important scene objects in game which can be interacted with + * + * @return scene objects + */ + public static final SceneObject[] getSceneObjects() { + return getSceneObjects(ALL_FILTER); + } + + /** + * Returns array of sceneobjects with the first index to be the nearest + * + * @param filter + * + * @return sceneobjects + */ + public static final SceneObject[] getNearest(Filter filter) { + final SceneObject[] objects = getSceneObjects(filter); + Arrays.sort(objects, NEAREST_SORTER); + return objects; + } + + /** + * Returns array of sceneobjects with the first index to be the nearest + * + * @return sceneobjects + */ + public static final SceneObject[] getNearest() { + return getNearest(ALL_FILTER); + } + + /** + * Returns nearest objects with given id + * + * @param ids + * + * @return sceneobjects + */ + public static final SceneObject[] getNearest(final int... ids) { + return getNearest(new Filter() { + + @Override + public boolean accept(SceneObject object) { + for (final int id : ids) { + if (id == object.getId()) { + return true; + } + } + return false; + } + + }); + } + + public static final SceneObject getClosest(final int... ids) { + SceneObject[] nearestObjects = getNearest(new Filter() { + + @Override + public boolean accept(SceneObject object) { + for (final int id : ids) { + if (id == object.getId()) { + 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) { + 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; + } + + /** + * Gets every loaded scene object in game + * + * @return every loaded scene object in game + */ + public static final SceneObject[] getAllSceneObjects() { + ArrayList sceneObjects = new ArrayList(); + for (int x = 0; x < 104; x++) { + for (int y = 0; y < 104; y++) { + final Collection sceneObjectsAtTile = getSceneObjectsAtTile(x, y, true); + if (sceneObjectsAtTile != null && !sceneObjectsAtTile.isEmpty()) { + sceneObjects.addAll(sceneObjectsAtTile); + } + } + } + return sceneObjects.toArray(new SceneObject[sceneObjects.size()]); + } + + /** + * Gets all sceneobjects at a tile + * + * @param x + * @param y + * @param useCached + * + * @return array of sceneobjects, or null if there aren't any + */ + public static final Collection getSceneObjectsAtTile(int x, int y, boolean useCached) { + Ground sceneTile = Loader.getClient().getScene().getGroundArray()[Game.getPlane()][x][y]; + ArrayList sceneObjects = null; + if (sceneTile != null) { + final SceneObjectTile[] interactiveObjects = sceneTile.getInteractiveObjects(); + if (interactiveObjects != null) { + for (final SceneObjectTile interactiveObject : interactiveObjects) { + if (interactiveObject != null) { + if (sceneObjects == null) { + sceneObjects = new ArrayList<>(); + } + sceneObjects.add(new SceneObject(interactiveObject, SceneObject.TYPE_INTERACTIVE)); + } + } + } + SceneObjectTile sceneObjectTile = sceneTile.getWallObject(); + if (sceneObjectTile != null) { + if (sceneObjects == null) { + sceneObjects = new ArrayList<>(); + } + sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALL)); + } + + sceneObjectTile = sceneTile.getWallDecoration(); + if (sceneObjectTile != null) { + if (sceneObjects == null) { + sceneObjects = new ArrayList<>(); + } + sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_WALLDECORATION)); + } + + sceneObjectTile = sceneTile.getGroundDecoration(); + if (sceneObjectTile != null) { + if (sceneObjects == null) { + sceneObjects = new ArrayList<>(); + } + sceneObjects.add(new SceneObject(sceneObjectTile, SceneObject.TYPE_GROUNDDECORATION)); + } + + sceneObjectTile = sceneTile.getGroundItem(); + if (sceneObjectTile != null) { + if (sceneObjects == null) { + sceneObjects = new ArrayList<>(); + } + 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")), + CHOP_DOWN(settings.get("menu_scene_object_first_interaction")), + CRAFT_RUNE(settings.get("menu_scene_object_first_interaction")), + PRAY_AT(settings.get("menu_scene_object_first_interaction")), + OPEN(settings.get("menu_scene_object_first_interaction")), + DEPOSIT(settings.get("menu_scene_object_first_interaction")), + USE(settings.get("menu_scene_object_first_interaction")), + SEARCH(settings.get("menu_scene_object_first_interaction")), + CLOSE(settings.get("menu_scene_object_first_interaction")), + CROSS(settings.get("menu_scene_object_first_interaction")), + MINE(settings.get("menu_scene_object_first_interaction")), + SMELT(settings.get("menu_scene_object_first_interaction")), + + SECOND(settings.get("menu_scene_object_second_interaction")), + TELEPORT(settings.get("menu_scene_object_second_interaction")), + STEAL_FROM(settings.get("menu_scene_object_second_interaction")), + PRAY(settings.get("menu_scene_object_second_interaction")), + USE_QUICKLY(settings.get("menu_scene_object_second_interaction")), + INSPECT(settings.get("menu_scene_object_second_interaction")), + + THIRD(settings.get("menu_scene_object_third_interaction")), + + FOURTH(settings.get("menu_scene_object_fourth_interaction")), + GUIDE(settings.get("menu_scene_object_fourth_interaction")), + + FIFTH(settings.get("menu_scene_object_fifth_interaction")), + + EXAMINE(settings.get("menu_scene_object_examine")); + + int actionId; + + Option(int actionId) { + this.actionId = actionId; + } + + public int getActionId() { + return actionId; + } + } + +} + diff --git a/src/org/rev317/min/api/methods/Skill.java b/src/main/java/org/rev317/min/api/methods/Skill.java similarity index 96% rename from src/org/rev317/min/api/methods/Skill.java rename to src/main/java/org/rev317/min/api/methods/Skill.java index ca3d894..9381036 100644 --- a/src/org/rev317/min/api/methods/Skill.java +++ b/src/main/java/org/rev317/min/api/methods/Skill.java @@ -1,183 +1,183 @@ -package org.rev317.min.api.methods; - -import org.rev317.min.Loader; - -/** - * @author Dane, JKetelaar - */ -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; - - private static final int[] EXPERIENCE = {0, 0, 83, 174, 276, 388, 512, - 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, - 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, - 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, - 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, - 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, - 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, - 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, - 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, - 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, - 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, - 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, - 13034431, 14391160, 15889109, 17542976, 19368992, 21385073, - 23611006, 26068632, 28782069, 31777943, 35085654, 38737661, - 42769801, 47221641, 52136869, 57563718, 63555443, 70170840, - 77474828, 85539082, 94442737, 104273167}; - - /** - * Returns the experience of the provided skill. - * - * @param index the skill index. - * - * @return the experience. - */ - public static final int getCurrentExperience(int index) { - return Loader.getClient().getCurrentExp()[index]; - } - - /** - * Returns the real level of the provided skill. - * - * @param index the skill index. - * - * @return the real skill level. - */ - public static final int getRealLevel(int index) { - return getLevelByExperience(getCurrentExperience(index)); - } - - /** - * Returns the current level of the provided skill. (Will return de-buffed/buffed levels) - * - * @param index the skill index. - * - * @return the current skill level. Done by Bears - */ - public static final int getCurrentLevel(int index) { - return Loader.getClient().getCurrentStats()[index]; - } - - /** - * Returns the exact experience at the provided level. - * - * @param level the level. - * - * @return the experience at the provided level. - */ - public static final int getExperienceByLevel(int level) { - if (level > 99 || level < 1) { - return 0; - } - return EXPERIENCE[level]; - } - - /** - * Returns the exact level with the provided experience. - * - * @param experience the experience. - * - * @return the level at the provided experience. - */ - public static final int getLevelByExperience(int experience) { - for (int i = EXPERIENCE.length - 1; i > 0; i--) { - if (experience > EXPERIENCE[i]) { - return i; - } - } - return 1; - } - - /** - * Returns the remaining experience for the provided skill to level up. - * - * @param index the skill index. - * - * @return the remaining experience. - */ - public static final int getRemainingExperience(int index) { - int level = getLevelByExperience(getCurrentExperience(index)); - if (level >= 99 || level < 1) { - return 0; - } - return EXPERIENCE[(level + 1)] - getCurrentExperience(index); - } - - /** - * Returns the percentage to the next level for the provided skill. - * - * @param index the skill index. - * - * @return the remaining percentage. - */ - public static final int getPercentToNextLevel(int index) { - int currentLevel = getLevelByExperience(getCurrentExperience(index)); - int nextLevel = currentLevel + 1; - if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1 - || nextLevel < 1) { - return 0; - } - return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel])); - } - - /** - * @Deprecated use Skill.ordinal() instead Returns the skill's index. - */ - public int getIndex() { - return ordinal(); - } - - /** - * Returns the name of the skill. - */ - public final String getName() { - return Character.toUpperCase(name().charAt(0)) - + name().toLowerCase().substring(1); - } - - /** - * Returns the current experience. - */ - public final int getExperience() { - return Skill.getCurrentExperience(this.getIndex()); - } - - /** - * Returns the real level. - */ - public final int getRealLevel() { - return Skill.getRealLevel(this.getIndex()); - } - - /** - * Returns the current level. (For example, if you've been de-buffed by a spell, or drank a beer that buffs the - * stat; it will return the buffed level.) Done by Bears - */ - public final int getLevel() { - return Skill.getCurrentLevel(this.getIndex()); - } - - /** - * Returns the remaining experience until the next level. - */ - public final int getRemaining() { - return Skill.getRemainingExperience(this.getIndex()); - } - - /** - * Returns the percentage until the next level. - */ - public final int getPercentage() { - return Skill.getPercentToNextLevel(this.getIndex()); - } - - /** - * Returns '[Name, Level / RealLevel]' - */ - @Override - public final String toString() { - return "Skill: [" + this.getName() + ": " + this.getLevel() + " / " - + this.getRealLevel() + "]"; - } -} +package org.rev317.min.api.methods; + +import org.rev317.min.Loader; + +/** + * @author Dane, JKetelaar + */ +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; + + private static final int[] EXPERIENCE = {0, 0, 83, 174, 276, 388, 512, + 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, + 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, + 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, + 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, + 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, + 166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804, + 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, + 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581, + 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, + 3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, + 6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606, + 13034431, 14391160, 15889109, 17542976, 19368992, 21385073, + 23611006, 26068632, 28782069, 31777943, 35085654, 38737661, + 42769801, 47221641, 52136869, 57563718, 63555443, 70170840, + 77474828, 85539082, 94442737, 104273167}; + + /** + * Returns the experience of the provided skill. + * + * @param index the skill index. + * + * @return the experience. + */ + public static final int getCurrentExperience(int index) { + return Loader.getClient().getCurrentExp()[index]; + } + + /** + * Returns the real level of the provided skill. + * + * @param index the skill index. + * + * @return the real skill level. + */ + public static final int getRealLevel(int index) { + return getLevelByExperience(getCurrentExperience(index)); + } + + /** + * Returns the current level of the provided skill. (Will return de-buffed/buffed levels) + * + * @param index the skill index. + * + * @return the current skill level. Done by Bears + */ + public static final int getCurrentLevel(int index) { + return Loader.getClient().getCurrentStats()[index]; + } + + /** + * Returns the exact experience at the provided level. + * + * @param level the level. + * + * @return the experience at the provided level. + */ + public static final int getExperienceByLevel(int level) { + if (level > 99 || level < 1) { + return 0; + } + return EXPERIENCE[level]; + } + + /** + * Returns the exact level with the provided experience. + * + * @param experience the experience. + * + * @return the level at the provided experience. + */ + public static final int getLevelByExperience(int experience) { + for (int i = EXPERIENCE.length - 1; i > 0; i--) { + if (experience > EXPERIENCE[i]) { + return i; + } + } + return 1; + } + + /** + * Returns the remaining experience for the provided skill to level up. + * + * @param index the skill index. + * + * @return the remaining experience. + */ + public static final int getRemainingExperience(int index) { + int level = getLevelByExperience(getCurrentExperience(index)); + if (level >= 99 || level < 1) { + return 0; + } + return EXPERIENCE[(level + 1)] - getCurrentExperience(index); + } + + /** + * Returns the percentage to the next level for the provided skill. + * + * @param index the skill index. + * + * @return the remaining percentage. + */ + public static final int getPercentToNextLevel(int index) { + int currentLevel = getLevelByExperience(getCurrentExperience(index)); + int nextLevel = currentLevel + 1; + if (currentLevel == 99 || nextLevel > 99 || currentLevel < 1 + || nextLevel < 1) { + return 0; + } + return (int) (100f * ((float) getCurrentExperience(index) / (float) EXPERIENCE[nextLevel])); + } + + /** + * @Deprecated use Skill.ordinal() instead Returns the skill's index. + */ + public int getIndex() { + return ordinal(); + } + + /** + * Returns the name of the skill. + */ + public final String getName() { + return Character.toUpperCase(name().charAt(0)) + + name().toLowerCase().substring(1); + } + + /** + * Returns the current experience. + */ + public final int getExperience() { + return Skill.getCurrentExperience(this.getIndex()); + } + + /** + * Returns the real level. + */ + public final int getRealLevel() { + return Skill.getRealLevel(this.getIndex()); + } + + /** + * Returns the current level. (For example, if you've been de-buffed by a spell, or drank a beer that buffs the + * stat; it will return the buffed level.) Done by Bears + */ + public final int getLevel() { + return Skill.getCurrentLevel(this.getIndex()); + } + + /** + * Returns the remaining experience until the next level. + */ + public final int getRemaining() { + return Skill.getRemainingExperience(this.getIndex()); + } + + /** + * Returns the percentage until the next level. + */ + public final int getPercentage() { + return Skill.getPercentToNextLevel(this.getIndex()); + } + + /** + * Returns '[Name, Level / RealLevel]' + */ + @Override + public final String toString() { + return "Skill: [" + this.getName() + ": " + this.getLevel() + " / " + + this.getRealLevel() + "]"; + } +} diff --git a/src/org/rev317/min/api/methods/Trading.java b/src/main/java/org/rev317/min/api/methods/Trading.java similarity index 100% rename from src/org/rev317/min/api/methods/Trading.java rename to src/main/java/org/rev317/min/api/methods/Trading.java diff --git a/src/org/rev317/min/api/methods/Walking.java b/src/main/java/org/rev317/min/api/methods/Walking.java similarity index 96% rename from src/org/rev317/min/api/methods/Walking.java rename to src/main/java/org/rev317/min/api/methods/Walking.java index 5acbcca..bbce3b8 100644 --- a/src/org/rev317/min/api/methods/Walking.java +++ b/src/main/java/org/rev317/min/api/methods/Walking.java @@ -1,62 +1,62 @@ -package org.rev317.min.api.methods; - -import org.rev317.min.Loader; -import org.rev317.min.api.wrappers.Tile; -import org.rev317.min.api.wrappers.TilePath; - -/** - * @author Everel - */ -public class Walking { - - /** - * Walks from tile to tile - * - * @param from Tile to Walk From. - * @param to Tile to Walk To. - */ - public static void walkTo(Tile from, Tile to) { - Loader.getClient().walkTo(0, 0, 0, 0, from.getRegionY(), 0, 0, to.getRegionY(), from.getRegionX(), true, to.getRegionX()); - } - - /** - * Walks from the Player's Location to tile. - * - * @param to Destination Tile. - */ - public static void walkTo(Tile to) { - Loader.getClient().walkTo(0, 0, 0, 0, Players.getMyPlayer().getLocation().getRegionY(), 0, 0, to.getRegionY(), Players.getMyPlayer().getLocation().getRegionX(), true, to.getRegionX()); - } - - /** - * @param tilePath - * @return true if destination reached, otherwise false - */ - public static boolean walkDown(TilePath tilePath) { - if (tilePath.hasReached()) { - return true; - } - tilePath.traverse(); - return false; - } - - /** - * Gets nearest reachable tile on minimap to given tile - * - * @param tile - * @return nearest reachable tile on minimap - */ - public static Tile getNearestTileTo(Tile tile) { - Tile loc = Players.getMyPlayer().getLocation(); - for (int i = 0; i < 1000; ++i) { - if (tile.distanceTo() < 16 && tile.isWalkable()) { - return tile; - } - tile = new Tile((loc.getX() + tile.getX()) / 2, - (loc.getY() + tile.getY()) / 2); - } - return null; - } - -} - +package org.rev317.min.api.methods; + +import org.rev317.min.Loader; +import org.rev317.min.api.wrappers.Tile; +import org.rev317.min.api.wrappers.TilePath; + +/** + * @author Everel + */ +public class Walking { + + /** + * Walks from tile to tile + * + * @param from Tile to Walk From. + * @param to Tile to Walk To. + */ + public static void walkTo(Tile from, Tile to) { + Loader.getClient().walkTo(0, 0, 0, 0, from.getRegionY(), 0, 0, to.getRegionY(), from.getRegionX(), true, to.getRegionX()); + } + + /** + * Walks from the Player's Location to tile. + * + * @param to Destination Tile. + */ + public static void walkTo(Tile to) { + Loader.getClient().walkTo(0, 0, 0, 0, Players.getMyPlayer().getLocation().getRegionY(), 0, 0, to.getRegionY(), Players.getMyPlayer().getLocation().getRegionX(), true, to.getRegionX()); + } + + /** + * @param tilePath + * @return true if destination reached, otherwise false + */ + public static boolean walkDown(TilePath tilePath) { + if (tilePath.hasReached()) { + return true; + } + tilePath.traverse(); + return false; + } + + /** + * Gets nearest reachable tile on minimap to given tile + * + * @param tile + * @return nearest reachable tile on minimap + */ + public static Tile getNearestTileTo(Tile tile) { + Tile loc = Players.getMyPlayer().getLocation(); + for (int i = 0; i < 1000; ++i) { + if (tile.distanceTo() < 16 && tile.isWalkable()) { + return tile; + } + tile = new Tile((loc.getX() + tile.getX()) / 2, + (loc.getY() + tile.getY()) / 2); + } + return null; + } + +} + diff --git a/src/org/rev317/min/api/wrappers/Area.java b/src/main/java/org/rev317/min/api/wrappers/Area.java similarity index 100% rename from src/org/rev317/min/api/wrappers/Area.java rename to src/main/java/org/rev317/min/api/wrappers/Area.java diff --git a/src/org/rev317/min/api/wrappers/Character.java b/src/main/java/org/rev317/min/api/wrappers/Character.java similarity index 95% rename from src/org/rev317/min/api/wrappers/Character.java rename to src/main/java/org/rev317/min/api/wrappers/Character.java index 4f09516..f4aaf11 100644 --- a/src/org/rev317/min/api/wrappers/Character.java +++ b/src/main/java/org/rev317/min/api/wrappers/Character.java @@ -1,190 +1,190 @@ -package org.rev317.min.api.wrappers; - -import org.parabot.core.reflect.RefClass; -import org.rev317.min.Loader; -import org.rev317.min.api.interfaces.Locatable; -import org.rev317.min.api.methods.Calculations; -import org.rev317.min.api.methods.Game; -import org.rev317.min.api.methods.Menu; -import org.rev317.min.api.methods.Players; - -/** - * @author Everel - */ -public class Character implements Locatable { - - private org.rev317.min.accessors.Character accessor; - private int index; - - public Character(org.rev317.min.accessors.Character accessor, int index) { - this.accessor = accessor; - this.index = index; - } - - /** - * Gets local region x - * - * @return x - */ - public int getX() { - return accessor.getX() >> 7; - } - - /** - * Gets local region y - * - * @return y - */ - public int getY() { - return accessor.getY() >> 7; - } - - /** - * Index of the character array - * - * @return index - */ - public int getIndex() { - return this.index; - } - - /** - * Animation of this character - * - * @return animation - */ - public int getAnimation() { - return accessor.getAnimation(); - } - - /** - * Location of this character - * - * @return location - */ - public Tile getLocation() { - return new Tile(Game.getBaseX() + getX(), Game.getBaseY() + getY()); - } - - /** - * Distance to this character - * - * @return distance - */ - public int distanceTo() { - return (int) Calculations.distanceTo(getLocation()); - } - - /** - * Gets current health - * - * @return health - */ - public final int getHealth() { - return this.accessor.getCurrentHealth(); - } - - /** - * Gets maximum health of this character - * - * @return max health - */ - public final int getMaxHealth() { - return this.accessor.getMaxHealth(); - } - - /** - * Fetches loop cycle status - * - * @return loop cycle status - */ - public final int getLoopCycleStatus() { - return this.accessor.getLoopCycleStatus(); - } - - /** - * Determines if entity is in combat - * - * @return true if entity is in combat - */ - public boolean isInCombat() { - return accessor.getLoopCycleStatus() > Loader.getClient() - .getLoopCycle(); - } - - /** - * Interacts with this character - * - * @deprecated - * - * @param i - */ - public void interact(int i) { - Menu.interact(this, i); - } - - /** - * Returns the character this character is interacting with - * - * @return interacting character - */ - public final Character getInteractingCharacter() { - int index = this.accessor.getInteractingEntity(); - if (index != -1 && index < 32768) { - return new Npc(Loader.getClient().getNpcs()[index], index); - } else if (index >= 32768) { - index -= 32768; - try { - if (Loader.getClient().getPlayers()[index] == null) { - return Players.getMyPlayer(); - } - return new Player(Loader.getClient().getPlayers()[index], index); - } catch (Throwable t) { - return Players.getMyPlayer(); - } - } - return null; - } - - /** - * Gets the accessor class - * - * @return RefClass of accessor - */ - public RefClass getRefClass() { - return new RefClass(this.accessor); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((accessor == null) ? 0 : accessor.hashCode()); - result = prime * result + index; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Character other = (Character) obj; - if (accessor == null) { - if (other.accessor != null) - return false; - } else if (!accessor.equals(other.accessor)) - return false; - if (index != other.index) - return false; - return true; - } - - public org.rev317.min.accessors.Character getAccessor() { - return accessor; - } -} +package org.rev317.min.api.wrappers; + +import org.parabot.core.reflect.RefClass; +import org.rev317.min.Loader; +import org.rev317.min.api.interfaces.Locatable; +import org.rev317.min.api.methods.Calculations; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Menu; +import org.rev317.min.api.methods.Players; + +/** + * @author Everel + */ +public class Character implements Locatable { + + private org.rev317.min.accessors.Character accessor; + private int index; + + public Character(org.rev317.min.accessors.Character accessor, int index) { + this.accessor = accessor; + this.index = index; + } + + /** + * Gets local region x + * + * @return x + */ + public int getX() { + return accessor.getX() >> 7; + } + + /** + * Gets local region y + * + * @return y + */ + public int getY() { + return accessor.getY() >> 7; + } + + /** + * Index of the character array + * + * @return index + */ + public int getIndex() { + return this.index; + } + + /** + * Animation of this character + * + * @return animation + */ + public int getAnimation() { + return accessor.getAnimation(); + } + + /** + * Location of this character + * + * @return location + */ + public Tile getLocation() { + return new Tile(Game.getBaseX() + getX(), Game.getBaseY() + getY()); + } + + /** + * Distance to this character + * + * @return distance + */ + public int distanceTo() { + return (int) Calculations.distanceTo(getLocation()); + } + + /** + * Gets current health + * + * @return health + */ + public final int getHealth() { + return this.accessor.getCurrentHealth(); + } + + /** + * Gets maximum health of this character + * + * @return max health + */ + public final int getMaxHealth() { + return this.accessor.getMaxHealth(); + } + + /** + * Fetches loop cycle status + * + * @return loop cycle status + */ + public final int getLoopCycleStatus() { + return this.accessor.getLoopCycleStatus(); + } + + /** + * Determines if entity is in combat + * + * @return true if entity is in combat + */ + public boolean isInCombat() { + return accessor.getLoopCycleStatus() > Loader.getClient() + .getLoopCycle(); + } + + /** + * Interacts with this character + * + * @deprecated + * + * @param i + */ + public void interact(int i) { + Menu.interact(this, i); + } + + /** + * Returns the character this character is interacting with + * + * @return interacting character + */ + public final Character getInteractingCharacter() { + int index = this.accessor.getInteractingEntity(); + if (index != -1 && index < 32768) { + return new Npc(Loader.getClient().getNpcs()[index], index); + } else if (index >= 32768) { + index -= 32768; + try { + if (Loader.getClient().getPlayers()[index] == null) { + return Players.getMyPlayer(); + } + return new Player(Loader.getClient().getPlayers()[index], index); + } catch (Throwable t) { + return Players.getMyPlayer(); + } + } + return null; + } + + /** + * Gets the accessor class + * + * @return RefClass of accessor + */ + public RefClass getRefClass() { + return new RefClass(this.accessor); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((accessor == null) ? 0 : accessor.hashCode()); + result = prime * result + index; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Character other = (Character) obj; + if (accessor == null) { + if (other.accessor != null) + return false; + } else if (!accessor.equals(other.accessor)) + return false; + if (index != other.index) + return false; + return true; + } + + public org.rev317.min.accessors.Character getAccessor() { + return accessor; + } +} diff --git a/src/org/rev317/min/api/wrappers/GroundItem.java b/src/main/java/org/rev317/min/api/wrappers/GroundItem.java similarity index 94% rename from src/org/rev317/min/api/wrappers/GroundItem.java rename to src/main/java/org/rev317/min/api/wrappers/GroundItem.java index 69768af..e4a568e 100644 --- a/src/org/rev317/min/api/wrappers/GroundItem.java +++ b/src/main/java/org/rev317/min/api/wrappers/GroundItem.java @@ -1,102 +1,102 @@ -package org.rev317.min.api.wrappers; - -import org.parabot.core.reflect.RefClass; -import org.rev317.min.api.interfaces.Locatable; -import org.rev317.min.api.methods.*; - -/** - * @author Everel - */ -public class GroundItem implements Locatable { - private org.rev317.min.accessors.Item accessor; - private int x; - private int y; - - public GroundItem(org.rev317.min.accessors.Item accessor, int x, int y) { - this.accessor = accessor; - this.x = x; - this.y = y; - } - - /** - * Gets location of this ground item - * - * @return location - */ - public Tile getLocation() { - return new Tile(Game.getBaseX() + x, Game.getBaseY() + y); - } - - /** - * Gets region X - * - * @return x - */ - public int getX() { - return x; - } - - /** - * Gets region Y - * - * @return y - */ - public int getY() { - return y; - } - - /** - * Interacts with this ground item - * - * @param option - */ - public void interact(GroundItems.Option option) { - Menu.interact(this, option); - } - - /** - * Interacts with this ground item - * - * @deprecated - * - * @param actionIndex - */ - public void interact(int actionIndex) { - Menu.interact(this, actionIndex); - } - - /** - * Takes this item from the ground - */ - public void take() { - Menu.take(this); - } - - /** - * Gets distance between you and this ground item - * - * @return distance - */ - public int distanceTo() { - return (int) Calculations.distanceTo(getLocation()); - } - - /** - * Get's ID of this item - * - * @return ID - */ - public int getId() { - return accessor.getId(); - } - - /** - * Gets the accessor class - * - * @return RefClass of accessor - */ - public RefClass getRefClass() { - return new RefClass(this.accessor); - } - -} +package org.rev317.min.api.wrappers; + +import org.parabot.core.reflect.RefClass; +import org.rev317.min.api.interfaces.Locatable; +import org.rev317.min.api.methods.*; + +/** + * @author Everel + */ +public class GroundItem implements Locatable { + private org.rev317.min.accessors.Item accessor; + private int x; + private int y; + + public GroundItem(org.rev317.min.accessors.Item accessor, int x, int y) { + this.accessor = accessor; + this.x = x; + this.y = y; + } + + /** + * Gets location of this ground item + * + * @return location + */ + public Tile getLocation() { + return new Tile(Game.getBaseX() + x, Game.getBaseY() + y); + } + + /** + * Gets region X + * + * @return x + */ + public int getX() { + return x; + } + + /** + * Gets region Y + * + * @return y + */ + public int getY() { + return y; + } + + /** + * Interacts with this ground item + * + * @param option + */ + public void interact(GroundItems.Option option) { + Menu.interact(this, option); + } + + /** + * Interacts with this ground item + * + * @deprecated + * + * @param actionIndex + */ + public void interact(int actionIndex) { + Menu.interact(this, actionIndex); + } + + /** + * Takes this item from the ground + */ + public void take() { + Menu.take(this); + } + + /** + * Gets distance between you and this ground item + * + * @return distance + */ + public int distanceTo() { + return (int) Calculations.distanceTo(getLocation()); + } + + /** + * Get's ID of this item + * + * @return ID + */ + public int getId() { + return accessor.getId(); + } + + /** + * Gets the accessor class + * + * @return RefClass of accessor + */ + public RefClass getRefClass() { + return new RefClass(this.accessor); + } + +} diff --git a/src/org/rev317/min/api/wrappers/Item.java b/src/main/java/org/rev317/min/api/wrappers/Item.java similarity index 94% rename from src/org/rev317/min/api/wrappers/Item.java rename to src/main/java/org/rev317/min/api/wrappers/Item.java index a7d14ae..dbdb868 100644 --- a/src/org/rev317/min/api/wrappers/Item.java +++ b/src/main/java/org/rev317/min/api/wrappers/Item.java @@ -1,102 +1,102 @@ -package org.rev317.min.api.wrappers; - -import org.rev317.min.api.methods.Items; -import org.rev317.min.api.methods.Menu; - -/** - * @author Everel - */ -public class Item { - private int id, stackSize; - private int slot; - - public Item(int id, int stackSize, int slot) { - this.id = id; - this.stackSize = stackSize; - this.slot = slot; - } - - /** - * Get id of this item - * - * @return id - */ - public int getId() { - return id; - } - - /** - * Gets quantity of this item - * - * @return stack size - */ - public int getStackSize() { - return stackSize; - } - - /** - * Item slot - * - * @return slot - */ - public int getSlot() { - return slot; - } - - /** - * Drops this item - */ - public void drop() { - Menu.drop(this); - } - - /** - * Interacts with this item - * - * @param option - */ - public void interact(Items.Option option) { - Menu.interact(this, option); - } - - /** - * - * @param option - * @param interfaceParentId - */ - public void transform(Items.Option option, int interfaceParentId) { - Menu.transformItem(this, option, interfaceParentId); - } - - /** - * Interacts with this item - * - * @deprecated - * - * @param i - */ - public void interact(int i) { - Menu.interact(this, i); - } - - /** - * Interacts with this item - * - * @deprecated - * - * @param s - */ - public void interact(String s){ - Menu.interact(this, s); - } - - /** - * @deprecated - * - * @param actionIndex - * @param interfaceParentId - */ - public void transform(int actionIndex, int interfaceParentId) { - Menu.transformItem(this, actionIndex, interfaceParentId); - } -} +package org.rev317.min.api.wrappers; + +import org.rev317.min.api.methods.Items; +import org.rev317.min.api.methods.Menu; + +/** + * @author Everel + */ +public class Item { + private int id, stackSize; + private int slot; + + public Item(int id, int stackSize, int slot) { + this.id = id; + this.stackSize = stackSize; + this.slot = slot; + } + + /** + * Get id of this item + * + * @return id + */ + public int getId() { + return id; + } + + /** + * Gets quantity of this item + * + * @return stack size + */ + public int getStackSize() { + return stackSize; + } + + /** + * Item slot + * + * @return slot + */ + public int getSlot() { + return slot; + } + + /** + * Drops this item + */ + public void drop() { + Menu.drop(this); + } + + /** + * Interacts with this item + * + * @param option + */ + public void interact(Items.Option option) { + Menu.interact(this, option); + } + + /** + * + * @param option + * @param interfaceParentId + */ + public void transform(Items.Option option, int interfaceParentId) { + Menu.transformItem(this, option, interfaceParentId); + } + + /** + * Interacts with this item + * + * @deprecated + * + * @param i + */ + public void interact(int i) { + Menu.interact(this, i); + } + + /** + * Interacts with this item + * + * @deprecated + * + * @param s + */ + public void interact(String s){ + Menu.interact(this, s); + } + + /** + * @deprecated + * + * @param actionIndex + * @param interfaceParentId + */ + public void transform(int actionIndex, int interfaceParentId) { + Menu.transformItem(this, actionIndex, interfaceParentId); + } +} diff --git a/src/org/rev317/min/api/wrappers/Npc.java b/src/main/java/org/rev317/min/api/wrappers/Npc.java similarity index 95% rename from src/org/rev317/min/api/wrappers/Npc.java rename to src/main/java/org/rev317/min/api/wrappers/Npc.java index 8efa479..f267692 100644 --- a/src/org/rev317/min/api/wrappers/Npc.java +++ b/src/main/java/org/rev317/min/api/wrappers/Npc.java @@ -1,46 +1,46 @@ -package org.rev317.min.api.wrappers; - -import org.parabot.core.reflect.RefClass; -import org.rev317.min.api.methods.Menu; -import org.rev317.min.api.methods.Npcs; - -/** - * @author Everel - */ -public final class Npc extends Character { - private org.rev317.min.accessors.Npc accessor; - - public Npc(org.rev317.min.accessors.Npc accessor, int index) { - super(accessor, index); - this.accessor = accessor; - } - - - /** - * Gets the definition of this npc - * - * @return npc definitions - */ - public final NpcDef getDef() { - return new NpcDef(this.accessor.getDef()); - } - - /** - * Gets the accessor class - * - * @return RefClass of accessor - */ - public RefClass getRefClass() { - return new RefClass(this.accessor); - } - - /** - * Interacts with this character - * - * @param option - */ - public void interact(Npcs.Option option) { - Menu.interact(this, option); - } - -} +package org.rev317.min.api.wrappers; + +import org.parabot.core.reflect.RefClass; +import org.rev317.min.api.methods.Menu; +import org.rev317.min.api.methods.Npcs; + +/** + * @author Everel + */ +public final class Npc extends Character { + private org.rev317.min.accessors.Npc accessor; + + public Npc(org.rev317.min.accessors.Npc accessor, int index) { + super(accessor, index); + this.accessor = accessor; + } + + + /** + * Gets the definition of this npc + * + * @return npc definitions + */ + public final NpcDef getDef() { + return new NpcDef(this.accessor.getDef()); + } + + /** + * Gets the accessor class + * + * @return RefClass of accessor + */ + public RefClass getRefClass() { + return new RefClass(this.accessor); + } + + /** + * Interacts with this character + * + * @param option + */ + public void interact(Npcs.Option option) { + Menu.interact(this, option); + } + +} diff --git a/src/org/rev317/min/api/wrappers/NpcDef.java b/src/main/java/org/rev317/min/api/wrappers/NpcDef.java similarity index 94% rename from src/org/rev317/min/api/wrappers/NpcDef.java rename to src/main/java/org/rev317/min/api/wrappers/NpcDef.java index 80efff9..f16935f 100644 --- a/src/org/rev317/min/api/wrappers/NpcDef.java +++ b/src/main/java/org/rev317/min/api/wrappers/NpcDef.java @@ -1,34 +1,34 @@ -package org.rev317.min.api.wrappers; - -import org.parabot.core.reflect.RefClass; - -/** - * @author Everel - */ -public class NpcDef { - private org.rev317.min.accessors.NpcDef accessor; - - public NpcDef(org.rev317.min.accessors.NpcDef accessor) { - this.accessor = accessor; - } - - /** - * Gets id of this item - * - * @return id of this item - */ - public int getId() { - return accessor.getId(); - } - - /** - * Gets the accessor class - * - * @return RefClass of accessor - */ - public RefClass getRefClass() { - return new RefClass(this.accessor); - } - -} - +package org.rev317.min.api.wrappers; + +import org.parabot.core.reflect.RefClass; + +/** + * @author Everel + */ +public class NpcDef { + private org.rev317.min.accessors.NpcDef accessor; + + public NpcDef(org.rev317.min.accessors.NpcDef accessor) { + this.accessor = accessor; + } + + /** + * Gets id of this item + * + * @return id of this item + */ + public int getId() { + return accessor.getId(); + } + + /** + * Gets the accessor class + * + * @return RefClass of accessor + */ + public RefClass getRefClass() { + return new RefClass(this.accessor); + } + +} + diff --git a/src/org/rev317/min/api/wrappers/Player.java b/src/main/java/org/rev317/min/api/wrappers/Player.java similarity index 95% rename from src/org/rev317/min/api/wrappers/Player.java rename to src/main/java/org/rev317/min/api/wrappers/Player.java index cbcda56..b43f245 100644 --- a/src/org/rev317/min/api/wrappers/Player.java +++ b/src/main/java/org/rev317/min/api/wrappers/Player.java @@ -1,27 +1,27 @@ -package org.rev317.min.api.wrappers; - -import org.rev317.min.api.methods.Menu; -import org.rev317.min.api.methods.Players; - -/** - * @author Everel - */ -public class Player extends Character { - - public Player(org.rev317.min.accessors.Player accessor, int index) { - super(accessor, index); - } - - public String getName(){ - return getAccessor().getName(); - } - - /** - * Interacts with this character - * - * @param option - */ - public void interact(Players.Option option) { - Menu.interact(this, option); - } -} +package org.rev317.min.api.wrappers; + +import org.rev317.min.api.methods.Menu; +import org.rev317.min.api.methods.Players; + +/** + * @author Everel + */ +public class Player extends Character { + + public Player(org.rev317.min.accessors.Player accessor, int index) { + super(accessor, index); + } + + public String getName(){ + return getAccessor().getName(); + } + + /** + * Interacts with this character + * + * @param option + */ + public void interact(Players.Option option) { + Menu.interact(this, option); + } +} diff --git a/src/org/rev317/min/api/wrappers/SceneObject.java b/src/main/java/org/rev317/min/api/wrappers/SceneObject.java similarity index 95% rename from src/org/rev317/min/api/wrappers/SceneObject.java rename to src/main/java/org/rev317/min/api/wrappers/SceneObject.java index f42b063..ecb4b02 100644 --- a/src/org/rev317/min/api/wrappers/SceneObject.java +++ b/src/main/java/org/rev317/min/api/wrappers/SceneObject.java @@ -1,126 +1,126 @@ -package org.rev317.min.api.wrappers; - -import org.parabot.core.reflect.RefClass; -import org.rev317.min.accessors.SceneObjectTile; -import org.rev317.min.api.interfaces.Locatable; -import org.rev317.min.api.methods.Calculations; -import org.rev317.min.api.methods.Game; -import org.rev317.min.api.methods.Menu; -import org.rev317.min.api.methods.SceneObjects; - -/** - * @author Everel - */ -public class SceneObject implements Locatable { - public static final int TYPE_WALL = 0; // object1 - public static final int TYPE_WALLDECORATION = 1; // object2 - public static final int TYPE_GROUNDDECORATION = 2; // object3 - public static final int TYPE_GROUNDITEM = 3; // object4 - public static final int TYPE_INTERACTIVE = 4; // object5 - - public SceneObjectTile accessor; - private int type; - - public SceneObject(SceneObjectTile accessor, int type) { - this.accessor = accessor; - this.type = type; - } - - /** - * Gets this object's hash - * - * @return hash - */ - public final int getHash() { - return accessor.getHash(); - } - - /** - * Gets location of this tile - * - * @return location - */ - public final Tile getLocation() { - return new Tile(Game.getBaseX() + getLocalRegionX(), Game.getBaseY() + getLocalRegionY()); - } - - /** - * Gets region X - * - * @return region X - */ - public final int getLocalRegionX() { - return accessor.getHash() & 0x7f; - } - - /** - * Gets region Y - * - * @return region Y - */ - public final int getLocalRegionY() { - return accessor.getHash() >> 7 & 0x7f; - } - - /** - * Gets this object's id - * - * @return object id - */ - public final int getId() { - return accessor.getHash() >> 14 & 0x7FFF; - } - - /** - * Gets this object's type - * - * @return type of object - */ - public final int getType() { - return type; - } - - /** - * Calculates distance to this object - * - * @return distance - */ - public final int distanceTo() { - return (int) Calculations.distanceTo(getLocation()); - } - - /** - * Interacts with this object - * - * @param option - */ - public void interact(SceneObjects.Option option) { - Menu.interact(this, option); - } - - /** - * Interacts with this object - * - * @deprecated - * - * @param actionIndex - */ - public void interact(int actionIndex) { - Menu.interact(this, actionIndex); - } - - /** - * Gets the accessor class - * - * @return RefClass of accessor - */ - public RefClass getRefClass() { - return new RefClass(this.accessor); - } - - @Override - public String toString() { - return String.format("[ID: %d, X: %d, Y: %d]", getId(), getLocalRegionX(), getLocalRegionY()); - } - -} +package org.rev317.min.api.wrappers; + +import org.parabot.core.reflect.RefClass; +import org.rev317.min.accessors.SceneObjectTile; +import org.rev317.min.api.interfaces.Locatable; +import org.rev317.min.api.methods.Calculations; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Menu; +import org.rev317.min.api.methods.SceneObjects; + +/** + * @author Everel + */ +public class SceneObject implements Locatable { + public static final int TYPE_WALL = 0; // object1 + public static final int TYPE_WALLDECORATION = 1; // object2 + public static final int TYPE_GROUNDDECORATION = 2; // object3 + public static final int TYPE_GROUNDITEM = 3; // object4 + public static final int TYPE_INTERACTIVE = 4; // object5 + + public SceneObjectTile accessor; + private int type; + + public SceneObject(SceneObjectTile accessor, int type) { + this.accessor = accessor; + this.type = type; + } + + /** + * Gets this object's hash + * + * @return hash + */ + public final int getHash() { + return accessor.getHash(); + } + + /** + * Gets location of this tile + * + * @return location + */ + public final Tile getLocation() { + return new Tile(Game.getBaseX() + getLocalRegionX(), Game.getBaseY() + getLocalRegionY()); + } + + /** + * Gets region X + * + * @return region X + */ + public final int getLocalRegionX() { + return accessor.getHash() & 0x7f; + } + + /** + * Gets region Y + * + * @return region Y + */ + public final int getLocalRegionY() { + return accessor.getHash() >> 7 & 0x7f; + } + + /** + * Gets this object's id + * + * @return object id + */ + public final int getId() { + return accessor.getHash() >> 14 & 0x7FFF; + } + + /** + * Gets this object's type + * + * @return type of object + */ + public final int getType() { + return type; + } + + /** + * Calculates distance to this object + * + * @return distance + */ + public final int distanceTo() { + return (int) Calculations.distanceTo(getLocation()); + } + + /** + * Interacts with this object + * + * @param option + */ + public void interact(SceneObjects.Option option) { + Menu.interact(this, option); + } + + /** + * Interacts with this object + * + * @deprecated + * + * @param actionIndex + */ + public void interact(int actionIndex) { + Menu.interact(this, actionIndex); + } + + /** + * Gets the accessor class + * + * @return RefClass of accessor + */ + public RefClass getRefClass() { + return new RefClass(this.accessor); + } + + @Override + public String toString() { + return String.format("[ID: %d, X: %d, Y: %d]", getId(), getLocalRegionX(), getLocalRegionY()); + } + +} diff --git a/src/org/rev317/min/api/wrappers/Tile.java b/src/main/java/org/rev317/min/api/wrappers/Tile.java similarity index 95% rename from src/org/rev317/min/api/wrappers/Tile.java rename to src/main/java/org/rev317/min/api/wrappers/Tile.java index d6d5bc3..cb28680 100644 --- a/src/org/rev317/min/api/wrappers/Tile.java +++ b/src/main/java/org/rev317/min/api/wrappers/Tile.java @@ -1,176 +1,176 @@ -package org.rev317.min.api.wrappers; - -import org.rev317.min.api.interfaces.Locatable; -import org.rev317.min.api.interfaces.TileFlags; -import org.rev317.min.api.methods.Calculations; -import org.rev317.min.api.methods.Game; -import org.rev317.min.api.methods.Players; -import org.rev317.min.api.methods.Walking; - -/** - * Class which holds a world location - * - * @author Everel - */ -public final class Tile implements TileFlags, Locatable { - private int x; - private int y; - private int z; - - public Tile(int x, int y) { - this.x = x; - this.y = y; - } - - public Tile(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - /** - * Gets x - * - * @return x - */ - public final int getX() { - return x; - } - - /** - * Gets y - * - * @return y - */ - public final int getY() { - return y; - } - - /** - * Gets region x - * - * @return region x - */ - public final int getRegionX() { - return x - Game.getBaseX(); - } - - /** - * Gets region y - * - * @return region y - */ - public final int getRegionY() { - return y - Game.getBaseY(); - } - - /** - * Gets z/plane - * - * @return plane - */ - public final int getPlane() { - return z; - } - - - /** - * {@inheritDoc} - */ - @Override - public final int distanceTo() { - return (int) Calculations.distanceTo(this); - } - - /** - * Determines if this tile is on minimap - * - * @return whether this tile is on minimap - */ - public final boolean isOnMinimap() { - return distanceTo() < 16; - } - - @Override - public String toString() { - return "Tile: [" + getX() + ", " + getY() + "]"; - } - - @Override - public boolean equals(Object obj) { - if (obj == null || obj.getClass() != this.getClass()) { - return false; - } - if (obj == this) { - return true; - } - - final Tile t = (Tile) obj; - return t.getX() == this.getX() && t.getY() == this.getY() - && t.getPlane() == this.getPlane(); - } - - @Override - public int hashCode() { - int hash = 7; - hash = 31 * hash + this.x; - hash = 31 * hash + this.y; - hash = 31 * hash + this.z; - return hash; - } - - /** - * Walks to this tile - */ - public void walkTo() { - Walking.walkTo(Players.getMyPlayer().getLocation(), this); - } - - /** - * Determines if this tile is walkable - * - * @return true if this tile is walkable, otherwise false - */ - public boolean isWalkable() { - return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & 256) == 0; - } - - /** - * Determines if this tile is reachable - * - * @param isObject whether this tile is an object tile - * - * @return true if this tile is reachable, otherwise false - */ - public boolean isReachable(boolean isObject) { - Tile current = Players.getMyPlayer().getLocation(); - return Calculations.dijkstraDist(current.getRegionX(), current.getRegionY(), getRegionX(), getRegionY(), isObjectTile()) > -1; - } - - /** - * Determines if this tile is reachable - * - * @return true if this tile is reachable, otherwise false - */ - public boolean isReachable() { - return isReachable(isObjectTile()); - } - - /** - * Determines if this tile is an object tile - * - * @return true if this tile is an object tile, otherwise false - */ - public boolean isObjectTile() { - return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & OBJECT_TILE) != 0; - } - - /** - * {@inheritDoc} - */ - @Override - public Tile getLocation() { - return this; - } - -} +package org.rev317.min.api.wrappers; + +import org.rev317.min.api.interfaces.Locatable; +import org.rev317.min.api.interfaces.TileFlags; +import org.rev317.min.api.methods.Calculations; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.methods.Walking; + +/** + * Class which holds a world location + * + * @author Everel + */ +public final class Tile implements TileFlags, Locatable { + private int x; + private int y; + private int z; + + public Tile(int x, int y) { + this.x = x; + this.y = y; + } + + public Tile(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Gets x + * + * @return x + */ + public final int getX() { + return x; + } + + /** + * Gets y + * + * @return y + */ + public final int getY() { + return y; + } + + /** + * Gets region x + * + * @return region x + */ + public final int getRegionX() { + return x - Game.getBaseX(); + } + + /** + * Gets region y + * + * @return region y + */ + public final int getRegionY() { + return y - Game.getBaseY(); + } + + /** + * Gets z/plane + * + * @return plane + */ + public final int getPlane() { + return z; + } + + + /** + * {@inheritDoc} + */ + @Override + public final int distanceTo() { + return (int) Calculations.distanceTo(this); + } + + /** + * Determines if this tile is on minimap + * + * @return whether this tile is on minimap + */ + public final boolean isOnMinimap() { + return distanceTo() < 16; + } + + @Override + public String toString() { + return "Tile: [" + getX() + ", " + getY() + "]"; + } + + @Override + public boolean equals(Object obj) { + if (obj == null || obj.getClass() != this.getClass()) { + return false; + } + if (obj == this) { + return true; + } + + final Tile t = (Tile) obj; + return t.getX() == this.getX() && t.getY() == this.getY() + && t.getPlane() == this.getPlane(); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 31 * hash + this.x; + hash = 31 * hash + this.y; + hash = 31 * hash + this.z; + return hash; + } + + /** + * Walks to this tile + */ + public void walkTo() { + Walking.walkTo(Players.getMyPlayer().getLocation(), this); + } + + /** + * Determines if this tile is walkable + * + * @return true if this tile is walkable, otherwise false + */ + public boolean isWalkable() { + return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & 256) == 0; + } + + /** + * Determines if this tile is reachable + * + * @param isObject whether this tile is an object tile + * + * @return true if this tile is reachable, otherwise false + */ + public boolean isReachable(boolean isObject) { + Tile current = Players.getMyPlayer().getLocation(); + return Calculations.dijkstraDist(current.getRegionX(), current.getRegionY(), getRegionX(), getRegionY(), isObjectTile()) > -1; + } + + /** + * Determines if this tile is reachable + * + * @return true if this tile is reachable, otherwise false + */ + public boolean isReachable() { + return isReachable(isObjectTile()); + } + + /** + * Determines if this tile is an object tile + * + * @return true if this tile is an object tile, otherwise false + */ + public boolean isObjectTile() { + return (Game.getCollisionFlags()[getRegionX()][getRegionY()] & OBJECT_TILE) != 0; + } + + /** + * {@inheritDoc} + */ + @Override + public Tile getLocation() { + return this; + } + +} diff --git a/src/org/rev317/min/api/wrappers/TilePath.java b/src/main/java/org/rev317/min/api/wrappers/TilePath.java similarity index 95% rename from src/org/rev317/min/api/wrappers/TilePath.java rename to src/main/java/org/rev317/min/api/wrappers/TilePath.java index c2b4819..52e5cce 100644 --- a/src/org/rev317/min/api/wrappers/TilePath.java +++ b/src/main/java/org/rev317/min/api/wrappers/TilePath.java @@ -1,80 +1,80 @@ -package org.rev317.min.api.wrappers; - -/** - * @author Everel - */ -public class TilePath { - - private Tile[] tiles; - - public TilePath(Tile[] tiles) { - this.tiles = tiles; - } - - /** - * Gets this path's tiles - * - * @return path tiles - */ - public final Tile[] getTiles() { - return tiles; - } - - /** - * Gets next tile to walk to - * - * @return tile - */ - public final Tile getNextTile() { - Tile next = null; - for (int x = 0; x < tiles.length; x++) { - if (tiles[x].isOnMinimap()) { - next = tiles[x]; - } - } - return next; - } - - /** - * Determines if this path can be walked down - * - * @return true if path is valid - */ - public final boolean isValid() { - return getNextTile() != null; - } - - /** - * Determines if player has reached end of path - * - * @return true if player has reached end of path - */ - public final boolean hasReached() { - return tiles[tiles.length - 1].distanceTo() < 5; - } - - /** - * Walks down the path - */ - public final void traverse() { - final Tile next = getNextTile(); - if (next == null) { - return; - } - next.walkTo(); - } - - /** - * Reverses the current path - * - * @return The reversed path - */ - public final TilePath reverse() { - Tile[] newTiles = new Tile[tiles.length]; - for (int i = 0; i < tiles.length; i++) - newTiles[i] = tiles[tiles.length - i - 1]; - return new TilePath(newTiles); - } - -} - +package org.rev317.min.api.wrappers; + +/** + * @author Everel + */ +public class TilePath { + + private Tile[] tiles; + + public TilePath(Tile[] tiles) { + this.tiles = tiles; + } + + /** + * Gets this path's tiles + * + * @return path tiles + */ + public final Tile[] getTiles() { + return tiles; + } + + /** + * Gets next tile to walk to + * + * @return tile + */ + public final Tile getNextTile() { + Tile next = null; + for (int x = 0; x < tiles.length; x++) { + if (tiles[x].isOnMinimap()) { + next = tiles[x]; + } + } + return next; + } + + /** + * Determines if this path can be walked down + * + * @return true if path is valid + */ + public final boolean isValid() { + return getNextTile() != null; + } + + /** + * Determines if player has reached end of path + * + * @return true if player has reached end of path + */ + public final boolean hasReached() { + return tiles[tiles.length - 1].distanceTo() < 5; + } + + /** + * Walks down the path + */ + public final void traverse() { + final Tile next = getNextTile(); + if (next == null) { + return; + } + next.walkTo(); + } + + /** + * Reverses the current path + * + * @return The reversed path + */ + public final TilePath reverse() { + Tile[] newTiles = new Tile[tiles.length]; + for (int i = 0; i < tiles.length; i++) + newTiles[i] = tiles[tiles.length - i - 1]; + return new TilePath(newTiles); + } + +} + diff --git a/src/org/rev317/min/callback/MenuAction.java b/src/main/java/org/rev317/min/callback/MenuAction.java similarity index 97% rename from src/org/rev317/min/callback/MenuAction.java rename to src/main/java/org/rev317/min/callback/MenuAction.java index ea7ba1d..e596d62 100644 --- a/src/org/rev317/min/callback/MenuAction.java +++ b/src/main/java/org/rev317/min/callback/MenuAction.java @@ -1,36 +1,36 @@ -package org.rev317.min.callback; - -import org.rev317.min.Loader; -import org.rev317.min.accessors.Client; -import org.rev317.min.api.events.GameActionEvent; -import org.rev317.min.api.methods.Game; -import org.rev317.min.debug.DActions; -import org.rev317.min.script.ScriptEngine; - -/** - * @author Everel - * @author Matt123337 - */ -public class MenuAction { - - public static void intercept(int index) { - Client client = Loader.getClient(); - int action1 = client.getMenuAction1()[index]; - int action2 = client.getMenuAction2()[index]; - int action3 = client.getMenuAction3()[index]; - int action4 = 0; - int actionId = client.getMenuActionId()[index]; - if (DActions.debugActions()) { - if (Game.hasAction4()) { - action4 = client.getMenuAction4()[index]; - System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId)); - } else { - System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId)); - } - } - - final GameActionEvent actionEvent = new GameActionEvent(actionId, action1, action2, action3, action4, index); - ScriptEngine.getInstance().dispatch(actionEvent); - } - -} +package org.rev317.min.callback; + +import org.rev317.min.Loader; +import org.rev317.min.accessors.Client; +import org.rev317.min.api.events.GameActionEvent; +import org.rev317.min.api.methods.Game; +import org.rev317.min.debug.DActions; +import org.rev317.min.script.ScriptEngine; + +/** + * @author Everel + * @author Matt123337 + */ +public class MenuAction { + + public static void intercept(int index) { + Client client = Loader.getClient(); + int action1 = client.getMenuAction1()[index]; + int action2 = client.getMenuAction2()[index]; + int action3 = client.getMenuAction3()[index]; + int action4 = 0; + int actionId = client.getMenuActionId()[index]; + if (DActions.debugActions()) { + if (Game.hasAction4()) { + action4 = client.getMenuAction4()[index]; + System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", index, action1, action2, action3, action4, actionId)); + } else { + System.out.println(String.format("[index: %d, action1: %d, action2: %d, action3: %d, id: %d]", index, action1, action2, action3, actionId)); + } + } + + final GameActionEvent actionEvent = new GameActionEvent(actionId, action1, action2, action3, action4, index); + ScriptEngine.getInstance().dispatch(actionEvent); + } + +} diff --git a/src/org/rev317/min/callback/MessageCallback.java b/src/main/java/org/rev317/min/callback/MessageCallback.java similarity index 96% rename from src/org/rev317/min/callback/MessageCallback.java rename to src/main/java/org/rev317/min/callback/MessageCallback.java index fc1b826..946c7b4 100644 --- a/src/org/rev317/min/callback/MessageCallback.java +++ b/src/main/java/org/rev317/min/callback/MessageCallback.java @@ -1,14 +1,14 @@ -package org.rev317.min.callback; - -import org.rev317.min.api.events.MessageEvent; -import org.rev317.min.script.ScriptEngine; - - -public class MessageCallback { - - public static final void messageListenerHook(int type, String name, String message) { - final MessageEvent messageEvent = new MessageEvent(type, name, message); - ScriptEngine.getInstance().dispatch(messageEvent); - } - -} +package org.rev317.min.callback; + +import org.rev317.min.api.events.MessageEvent; +import org.rev317.min.script.ScriptEngine; + + +public class MessageCallback { + + public static final void messageListenerHook(int type, String name, String message) { + final MessageEvent messageEvent = new MessageEvent(type, name, message); + ScriptEngine.getInstance().dispatch(messageEvent); + } + +} diff --git a/src/org/rev317/min/debug/DActions.java b/src/main/java/org/rev317/min/debug/DActions.java similarity index 94% rename from src/org/rev317/min/debug/DActions.java rename to src/main/java/org/rev317/min/debug/DActions.java index d9644d6..acd7794 100644 --- a/src/org/rev317/min/debug/DActions.java +++ b/src/main/java/org/rev317/min/debug/DActions.java @@ -1,28 +1,28 @@ -package org.rev317.min.debug; - -import org.parabot.core.paint.AbstractDebugger; - -import java.awt.*; - -public class DActions extends AbstractDebugger { - private static boolean enabled; - - public static boolean debugActions() { - return enabled; - } - - @Override - public void paint(Graphics g) { - } - - @Override - public boolean isEnabled() { - return false; - } - - @Override - public void toggle() { - enabled = !enabled; - } - -} +package org.rev317.min.debug; + +import org.parabot.core.paint.AbstractDebugger; + +import java.awt.*; + +public class DActions extends AbstractDebugger { + private static boolean enabled; + + public static boolean debugActions() { + return enabled; + } + + @Override + public void paint(Graphics g) { + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public void toggle() { + enabled = !enabled; + } + +} diff --git a/src/org/rev317/min/debug/DAnimation.java b/src/main/java/org/rev317/min/debug/DAnimation.java similarity index 95% rename from src/org/rev317/min/debug/DAnimation.java rename to src/main/java/org/rev317/min/debug/DAnimation.java index 0e3408b..555b261 100644 --- a/src/org/rev317/min/debug/DAnimation.java +++ b/src/main/java/org/rev317/min/debug/DAnimation.java @@ -1,27 +1,27 @@ -package org.rev317.min.debug; - -import org.parabot.core.Context; -import org.parabot.core.paint.AbstractDebugger; -import org.rev317.min.api.methods.Players; - -import java.awt.*; - -public class DAnimation extends AbstractDebugger { - private boolean enabled; - - @Override - public void paint(Graphics g) { - Context.getInstance().getPaintDebugger().addLine("Animation: " + Players.getMyPlayer().getAnimation()); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void toggle() { - enabled = !enabled; - } - -} +package org.rev317.min.debug; + +import org.parabot.core.Context; +import org.parabot.core.paint.AbstractDebugger; +import org.rev317.min.api.methods.Players; + +import java.awt.*; + +public class DAnimation extends AbstractDebugger { + private boolean enabled; + + @Override + public void paint(Graphics g) { + Context.getInstance().getPaintDebugger().addLine("Animation: " + Players.getMyPlayer().getAnimation()); + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public void toggle() { + enabled = !enabled; + } + +} diff --git a/src/org/rev317/min/debug/DBank.java b/src/main/java/org/rev317/min/debug/DBank.java similarity index 100% rename from src/org/rev317/min/debug/DBank.java rename to src/main/java/org/rev317/min/debug/DBank.java diff --git a/src/org/rev317/min/debug/DCollisionFlags.java b/src/main/java/org/rev317/min/debug/DCollisionFlags.java similarity index 97% rename from src/org/rev317/min/debug/DCollisionFlags.java rename to src/main/java/org/rev317/min/debug/DCollisionFlags.java index 9280350..48db0fe 100644 --- a/src/org/rev317/min/debug/DCollisionFlags.java +++ b/src/main/java/org/rev317/min/debug/DCollisionFlags.java @@ -1,39 +1,39 @@ -package org.rev317.min.debug; - -import org.parabot.core.Context; -import org.parabot.core.paint.AbstractDebugger; -import org.parabot.core.paint.PaintDebugger; -import org.rev317.min.api.methods.Game; -import org.rev317.min.api.methods.Players; -import org.rev317.min.api.wrappers.Tile; - -import java.awt.*; - -public class DCollisionFlags extends AbstractDebugger { - private boolean enabled; - - @Override - public void paint(Graphics g) { - PaintDebugger p = Context.getInstance().getPaintDebugger(); - Tile location = Players.getMyPlayer().getLocation(); - Tile north = 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 east = new Tile(location.getX() + 1, location.getY()); - int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()]; - 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("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]"); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void toggle() { - enabled = !enabled; - } - -} +package org.rev317.min.debug; + +import org.parabot.core.Context; +import org.parabot.core.paint.AbstractDebugger; +import org.parabot.core.paint.PaintDebugger; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.wrappers.Tile; + +import java.awt.*; + +public class DCollisionFlags extends AbstractDebugger { + private boolean enabled; + + @Override + public void paint(Graphics g) { + PaintDebugger p = Context.getInstance().getPaintDebugger(); + Tile location = Players.getMyPlayer().getLocation(); + Tile north = 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 east = new Tile(location.getX() + 1, location.getY()); + int flag = Game.getCollisionFlags()[location.getRegionX()][location.getRegionY()]; + 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("Walkable: [ cur: " + location.isWalkable() + ", north: " + north.isWalkable() + ", south: " + south.isWalkable() + ", east: " + east.isWalkable() + ", west: " + west.isWalkable() + " ]"); + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public void toggle() { + enabled = !enabled; + } + +} diff --git a/src/org/rev317/min/debug/DGroundItems.java b/src/main/java/org/rev317/min/debug/DGroundItems.java similarity index 95% rename from src/org/rev317/min/debug/DGroundItems.java rename to src/main/java/org/rev317/min/debug/DGroundItems.java index 588c62d..3095bf9 100644 --- a/src/org/rev317/min/debug/DGroundItems.java +++ b/src/main/java/org/rev317/min/debug/DGroundItems.java @@ -1,32 +1,32 @@ -package org.rev317.min.debug; - -import org.parabot.core.paint.AbstractDebugger; -import org.rev317.min.api.methods.GroundItems; -import org.rev317.min.api.wrappers.GroundItem; - -import java.awt.*; - -public class DGroundItems extends AbstractDebugger { - - @Override - public void paint(Graphics g) { - - } - - @Override - public boolean isEnabled() { - return false; - } - - @Override - public void toggle() { - GroundItem[] items = GroundItems.getNearest(); - if (items == null || items.length == 0) { - return; - } - for (GroundItem item : items) { - System.out.println("ID: " + item.getId() + " Location: " + item.getLocation()); - } - } - -} +package org.rev317.min.debug; + +import org.parabot.core.paint.AbstractDebugger; +import org.rev317.min.api.methods.GroundItems; +import org.rev317.min.api.wrappers.GroundItem; + +import java.awt.*; + +public class DGroundItems extends AbstractDebugger { + + @Override + public void paint(Graphics g) { + + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public void toggle() { + GroundItem[] items = GroundItems.getNearest(); + if (items == null || items.length == 0) { + return; + } + for (GroundItem item : items) { + System.out.println("ID: " + item.getId() + " Location: " + item.getLocation()); + } + } + +} diff --git a/src/org/rev317/min/debug/DInterfaces.java b/src/main/java/org/rev317/min/debug/DInterfaces.java similarity index 95% rename from src/org/rev317/min/debug/DInterfaces.java rename to src/main/java/org/rev317/min/debug/DInterfaces.java index db08f23..045f297 100644 --- a/src/org/rev317/min/debug/DInterfaces.java +++ b/src/main/java/org/rev317/min/debug/DInterfaces.java @@ -1,30 +1,30 @@ -package org.rev317.min.debug; - -import org.parabot.core.Context; -import org.parabot.core.paint.AbstractDebugger; -import org.parabot.core.paint.PaintDebugger; -import org.rev317.min.api.methods.Game; - -import java.awt.*; - -public class DInterfaces extends AbstractDebugger { - private boolean enabled; - - @Override - public void paint(Graphics g) { - PaintDebugger p = Context.getInstance().getPaintDebugger(); - p.addLine("Open interface: " + Game.getOpenInterfaceId()); - p.addLine("Open back dialog: " + Game.getOpenBackDialogId()); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void toggle() { - enabled = !enabled; - } - -} +package org.rev317.min.debug; + +import org.parabot.core.Context; +import org.parabot.core.paint.AbstractDebugger; +import org.parabot.core.paint.PaintDebugger; +import org.rev317.min.api.methods.Game; + +import java.awt.*; + +public class DInterfaces extends AbstractDebugger { + private boolean enabled; + + @Override + public void paint(Graphics g) { + PaintDebugger p = Context.getInstance().getPaintDebugger(); + p.addLine("Open interface: " + Game.getOpenInterfaceId()); + p.addLine("Open back dialog: " + Game.getOpenBackDialogId()); + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public void toggle() { + enabled = !enabled; + } + +} diff --git a/src/org/rev317/min/debug/DInventory.java b/src/main/java/org/rev317/min/debug/DInventory.java similarity index 100% rename from src/org/rev317/min/debug/DInventory.java rename to src/main/java/org/rev317/min/debug/DInventory.java diff --git a/src/org/rev317/min/debug/DMap.java b/src/main/java/org/rev317/min/debug/DMap.java similarity index 95% rename from src/org/rev317/min/debug/DMap.java rename to src/main/java/org/rev317/min/debug/DMap.java index 03f7a4c..bd51d3b 100644 --- a/src/org/rev317/min/debug/DMap.java +++ b/src/main/java/org/rev317/min/debug/DMap.java @@ -1,31 +1,31 @@ -package org.rev317.min.debug; - -import org.parabot.core.Context; -import org.parabot.core.paint.AbstractDebugger; -import org.parabot.core.paint.PaintDebugger; -import org.rev317.min.api.methods.Game; -import org.rev317.min.api.methods.Players; - -import java.awt.*; - -public class DMap extends AbstractDebugger { - private boolean enabled; - - @Override - public void paint(Graphics g) { - PaintDebugger p = Context.getInstance().getPaintDebugger(); - p.addLine("Location: " + Players.getMyPlayer().getLocation()); - p.addLine("Plane: " + Game.getPlane()); - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public void toggle() { - enabled = !enabled; - } - -} +package org.rev317.min.debug; + +import org.parabot.core.Context; +import org.parabot.core.paint.AbstractDebugger; +import org.parabot.core.paint.PaintDebugger; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Players; + +import java.awt.*; + +public class DMap extends AbstractDebugger { + private boolean enabled; + + @Override + public void paint(Graphics g) { + PaintDebugger p = Context.getInstance().getPaintDebugger(); + p.addLine("Location: " + Players.getMyPlayer().getLocation()); + p.addLine("Plane: " + Game.getPlane()); + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public void toggle() { + enabled = !enabled; + } + +} diff --git a/src/org/rev317/min/debug/DMessages.java b/src/main/java/org/rev317/min/debug/DMessages.java similarity index 100% rename from src/org/rev317/min/debug/DMessages.java rename to src/main/java/org/rev317/min/debug/DMessages.java diff --git a/src/org/rev317/min/debug/DMouse.java b/src/main/java/org/rev317/min/debug/DMouse.java similarity index 100% rename from src/org/rev317/min/debug/DMouse.java rename to src/main/java/org/rev317/min/debug/DMouse.java diff --git a/src/org/rev317/min/debug/DNpcs.java b/src/main/java/org/rev317/min/debug/DNpcs.java similarity index 95% rename from src/org/rev317/min/debug/DNpcs.java rename to src/main/java/org/rev317/min/debug/DNpcs.java index 4a3408e..802d979 100644 --- a/src/org/rev317/min/debug/DNpcs.java +++ b/src/main/java/org/rev317/min/debug/DNpcs.java @@ -1,29 +1,29 @@ -package org.rev317.min.debug; - -import org.parabot.core.paint.AbstractDebugger; -import org.rev317.min.api.methods.Npcs; -import org.rev317.min.api.wrappers.Npc; - -import java.awt.*; - -public class DNpcs extends AbstractDebugger { - - @Override - public void paint(Graphics g) { - - } - - @Override - public boolean isEnabled() { - return false; - } - - @Override - public void toggle() { - for (Npc n : Npcs.getNearest()) { - System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString()); - } - - } - -} +package org.rev317.min.debug; + +import org.parabot.core.paint.AbstractDebugger; +import org.rev317.min.api.methods.Npcs; +import org.rev317.min.api.wrappers.Npc; + +import java.awt.*; + +public class DNpcs extends AbstractDebugger { + + @Override + public void paint(Graphics g) { + + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public void toggle() { + for (Npc n : Npcs.getNearest()) { + System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString()); + } + + } + +} diff --git a/src/org/rev317/min/debug/DPlayers.java b/src/main/java/org/rev317/min/debug/DPlayers.java similarity index 100% rename from src/org/rev317/min/debug/DPlayers.java rename to src/main/java/org/rev317/min/debug/DPlayers.java diff --git a/src/org/rev317/min/debug/DSceneObjects.java b/src/main/java/org/rev317/min/debug/DSceneObjects.java similarity index 96% rename from src/org/rev317/min/debug/DSceneObjects.java rename to src/main/java/org/rev317/min/debug/DSceneObjects.java index 30b9973..d56163e 100644 --- a/src/org/rev317/min/debug/DSceneObjects.java +++ b/src/main/java/org/rev317/min/debug/DSceneObjects.java @@ -1,35 +1,35 @@ -package org.rev317.min.debug; - -import org.parabot.core.paint.AbstractDebugger; -import org.rev317.min.api.methods.SceneObjects; -import org.rev317.min.api.wrappers.SceneObject; - -import java.awt.*; - -public class DSceneObjects extends AbstractDebugger { - - @Override - public void paint(Graphics g) { - } - - @Override - public boolean isEnabled() { - return false; - } - - @Override - public void toggle() { - SceneObject[] objects = SceneObjects.getNearest(); - if (objects == null || objects.length == 0) - return; - - for (int i = objects.length - 1; i >= 0; i--) { - System.out.println( - " ID: " + objects[i].getId() + - " UID: " + objects[i].getHash() + - " Location: " + objects[i].getLocation() + - " Distance: " + objects[i].distanceTo()); - } - } - -} +package org.rev317.min.debug; + +import org.parabot.core.paint.AbstractDebugger; +import org.rev317.min.api.methods.SceneObjects; +import org.rev317.min.api.wrappers.SceneObject; + +import java.awt.*; + +public class DSceneObjects extends AbstractDebugger { + + @Override + public void paint(Graphics g) { + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public void toggle() { + SceneObject[] objects = SceneObjects.getNearest(); + if (objects == null || objects.length == 0) + return; + + for (int i = objects.length - 1; i >= 0; i--) { + System.out.println( + " ID: " + objects[i].getId() + + " UID: " + objects[i].getHash() + + " Location: " + objects[i].getLocation() + + " Distance: " + objects[i].distanceTo()); + } + } + +} diff --git a/src/org/rev317/min/script/ScriptEngine.java b/src/main/java/org/rev317/min/script/ScriptEngine.java similarity index 96% rename from src/org/rev317/min/script/ScriptEngine.java rename to src/main/java/org/rev317/min/script/ScriptEngine.java index 4eb48cd..5090cb7 100644 --- a/src/org/rev317/min/script/ScriptEngine.java +++ b/src/main/java/org/rev317/min/script/ScriptEngine.java @@ -1,181 +1,181 @@ -package org.rev317.min.script; - -import org.parabot.core.Context; -import org.parabot.environment.api.interfaces.Paintable; -import org.parabot.environment.scripts.Script; -import org.rev317.min.api.events.GameActionEvent; -import org.rev317.min.api.events.MessageEvent; -import org.rev317.min.api.events.listeners.GameActionListener; -import org.rev317.min.api.events.listeners.MessageListener; - -import java.awt.*; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.ArrayList; -import java.util.HashMap; - -/** - * @author Everel - * @author matt123337 - */ -public class ScriptEngine { - private static HashMap instances = new HashMap(); - private ArrayList mouseListeners; - private ArrayList mouseMotionListeners; - private ArrayList messageListeners; - private ArrayList actionListeners; - - private Script script = null; - - private ScriptEngine() { - this.mouseListeners = new ArrayList(); - this.mouseMotionListeners = new ArrayList(); - this.messageListeners = new ArrayList(); - this.actionListeners = new ArrayList(); - instances.put(Context.getInstance(), this); - } - - public static ScriptEngine getInstance() { - final ScriptEngine engine = instances.get(Context.getInstance()); - if (engine != null) { - return engine; - } - return new ScriptEngine(); - } - - public void addActionListener(GameActionListener a) { - actionListeners.add(a); - } - - public void removeActionListener(GameActionListener a) { - actionListeners.remove(a); - } - - public void clearActionListeners() { - actionListeners.clear(); - } - - public void addMouseListener(MouseListener mouseListener) { - mouseListeners.add(mouseListener); - } - - public void removeMouseListener(MouseListener mouseListener) { - mouseListeners.remove(mouseListener); - } - - public void clearMouseListeners() { - mouseListeners.clear(); - } - - public void addMouseMotionListener(MouseMotionListener mouseMotionListener) { - mouseMotionListeners.add(mouseMotionListener); - } - - public void removeMouseMotionListener(MouseMotionListener mouseMotionListener) { - mouseMotionListeners.remove(mouseMotionListener); - } - - public void clearMouseMotionListeners() { - mouseMotionListeners.clear(); - } - - public void addMessageListener(MessageListener messageListener) { - messageListeners.add(messageListener); - } - - public void removeMessageListener(MessageListener messageListener) { - messageListeners.remove(messageListener); - } - - public void clearMessageListeners() { - messageListeners.clear(); - } - - public void setScript(final Script script) { - this.script = script; - } - - public void unload() { - clearMouseListeners(); - clearMouseMotionListeners(); - clearMessageListeners(); - if (script instanceof Paintable) { - Context.getInstance().removePaintable((Paintable) script); - } - this.script = null; - } - - public void init() { - if (script == null) { - throw new RuntimeException("Script is null"); - } - if (script instanceof MouseListener) { - addMouseListener((MouseListener) script); - } - if (script instanceof MouseMotionListener) { - addMouseMotionListener((MouseMotionListener) script); - } - if (script instanceof MessageListener) { - addMessageListener((MessageListener) script); - } - if (script instanceof Paintable) { - Context.getInstance().addPaintable((Paintable) script); - } - if (script instanceof GameActionListener) { - addActionListener((GameActionListener) script); - } - } - - public void dispatch(AWTEvent event) { - if (this.script == null) { - return; - } - if (!(event instanceof MouseEvent)) { - return; - } - final MouseEvent e = (MouseEvent) event; - for (final MouseListener m : mouseListeners) { - switch (e.getID()) { - case MouseEvent.MOUSE_CLICKED: - m.mouseClicked(e); - break; - case MouseEvent.MOUSE_ENTERED: - m.mouseEntered(e); - break; - case MouseEvent.MOUSE_EXITED: - m.mouseExited(e); - break; - case MouseEvent.MOUSE_PRESSED: - m.mousePressed(e); - break; - case MouseEvent.MOUSE_RELEASED: - m.mouseReleased(e); - } - } - for (final MouseMotionListener m : mouseMotionListeners) { - switch (e.getID()) { - case MouseEvent.MOUSE_MOVED: - m.mouseMoved(e); - break; - case MouseEvent.MOUSE_DRAGGED: - m.mouseDragged(e); - break; - } - } - } - - public void dispatch(MessageEvent event) { - for (final MessageListener messageListener : messageListeners) { - messageListener.messageReceived(event); - } - } - - public void dispatch(GameActionEvent event) { - for (final GameActionListener a : actionListeners) { - a.onGameAction(event); - } - } - -} - +package org.rev317.min.script; + +import org.parabot.core.Context; +import org.parabot.environment.api.interfaces.Paintable; +import org.parabot.environment.scripts.Script; +import org.rev317.min.api.events.GameActionEvent; +import org.rev317.min.api.events.MessageEvent; +import org.rev317.min.api.events.listeners.GameActionListener; +import org.rev317.min.api.events.listeners.MessageListener; + +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @author Everel + * @author matt123337 + */ +public class ScriptEngine { + private static HashMap instances = new HashMap(); + private ArrayList mouseListeners; + private ArrayList mouseMotionListeners; + private ArrayList messageListeners; + private ArrayList actionListeners; + + private Script script = null; + + private ScriptEngine() { + this.mouseListeners = new ArrayList(); + this.mouseMotionListeners = new ArrayList(); + this.messageListeners = new ArrayList(); + this.actionListeners = new ArrayList(); + instances.put(Context.getInstance(), this); + } + + public static ScriptEngine getInstance() { + final ScriptEngine engine = instances.get(Context.getInstance()); + if (engine != null) { + return engine; + } + return new ScriptEngine(); + } + + public void addActionListener(GameActionListener a) { + actionListeners.add(a); + } + + public void removeActionListener(GameActionListener a) { + actionListeners.remove(a); + } + + public void clearActionListeners() { + actionListeners.clear(); + } + + public void addMouseListener(MouseListener mouseListener) { + mouseListeners.add(mouseListener); + } + + public void removeMouseListener(MouseListener mouseListener) { + mouseListeners.remove(mouseListener); + } + + public void clearMouseListeners() { + mouseListeners.clear(); + } + + public void addMouseMotionListener(MouseMotionListener mouseMotionListener) { + mouseMotionListeners.add(mouseMotionListener); + } + + public void removeMouseMotionListener(MouseMotionListener mouseMotionListener) { + mouseMotionListeners.remove(mouseMotionListener); + } + + public void clearMouseMotionListeners() { + mouseMotionListeners.clear(); + } + + public void addMessageListener(MessageListener messageListener) { + messageListeners.add(messageListener); + } + + public void removeMessageListener(MessageListener messageListener) { + messageListeners.remove(messageListener); + } + + public void clearMessageListeners() { + messageListeners.clear(); + } + + public void setScript(final Script script) { + this.script = script; + } + + public void unload() { + clearMouseListeners(); + clearMouseMotionListeners(); + clearMessageListeners(); + if (script instanceof Paintable) { + Context.getInstance().removePaintable((Paintable) script); + } + this.script = null; + } + + public void init() { + if (script == null) { + throw new RuntimeException("Script is null"); + } + if (script instanceof MouseListener) { + addMouseListener((MouseListener) script); + } + if (script instanceof MouseMotionListener) { + addMouseMotionListener((MouseMotionListener) script); + } + if (script instanceof MessageListener) { + addMessageListener((MessageListener) script); + } + if (script instanceof Paintable) { + Context.getInstance().addPaintable((Paintable) script); + } + if (script instanceof GameActionListener) { + addActionListener((GameActionListener) script); + } + } + + public void dispatch(AWTEvent event) { + if (this.script == null) { + return; + } + if (!(event instanceof MouseEvent)) { + return; + } + final MouseEvent e = (MouseEvent) event; + for (final MouseListener m : mouseListeners) { + switch (e.getID()) { + case MouseEvent.MOUSE_CLICKED: + m.mouseClicked(e); + break; + case MouseEvent.MOUSE_ENTERED: + m.mouseEntered(e); + break; + case MouseEvent.MOUSE_EXITED: + m.mouseExited(e); + break; + case MouseEvent.MOUSE_PRESSED: + m.mousePressed(e); + break; + case MouseEvent.MOUSE_RELEASED: + m.mouseReleased(e); + } + } + for (final MouseMotionListener m : mouseMotionListeners) { + switch (e.getID()) { + case MouseEvent.MOUSE_MOVED: + m.mouseMoved(e); + break; + case MouseEvent.MOUSE_DRAGGED: + m.mouseDragged(e); + break; + } + } + } + + public void dispatch(MessageEvent event) { + for (final MessageListener messageListener : messageListeners) { + messageListener.messageReceived(event); + } + } + + public void dispatch(GameActionEvent event) { + for (final GameActionListener a : actionListeners) { + a.onGameAction(event); + } + } + +} + diff --git a/src/org/rev317/min/ui/BotMenu.java b/src/main/java/org/rev317/min/ui/BotMenu.java similarity index 97% rename from src/org/rev317/min/ui/BotMenu.java rename to src/main/java/org/rev317/min/ui/BotMenu.java index a36c534..b541dcf 100644 --- a/src/org/rev317/min/ui/BotMenu.java +++ b/src/main/java/org/rev317/min/ui/BotMenu.java @@ -1,77 +1,77 @@ -package org.rev317.min.ui; - -import org.parabot.core.Context; -import org.parabot.core.paint.PaintDebugger; -import org.rev317.min.debug.*; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** - * @author JKetelaar, Everel - */ -public class BotMenu implements ActionListener { - - public BotMenu(JMenuBar bar) { - PaintDebugger debugger = Context.getInstance().getPaintDebugger(); - - JMenu debug = new JMenu("Debug"); - - JMenuItem actions = newItem("Actions"); - JMenuItem animation = newItem("Animation"); - JMenuItem bank = newItem("Bank"); - JMenuItem flags = newItem("Collision flags"); - JMenuItem items = newItem("GroundItems"); - JMenuItem interfaces = newItem("Interfaces"); - JMenuItem inventory = newItem("Inventory"); - JMenuItem map = newItem("Map"); - JMenuItem messages = newItem("Messages"); - JMenuItem mouse = newItem("Mouse"); - JMenuItem npcs = newItem("Npcs"); - JMenuItem objects = newItem("Objects"); - JMenuItem players = newItem("Players"); - - debugger.addDebugger("Actions", new DActions()); - debugger.addDebugger("Animation", new DAnimation()); - debugger.addDebugger("Bank", new DBank()); - debugger.addDebugger("Collision flags", new DCollisionFlags()); - debugger.addDebugger("GroundItems", new DGroundItems()); - debugger.addDebugger("Interfaces", new DInterfaces()); - debugger.addDebugger("Inventory", new DInventory()); - debugger.addDebugger("Map", new DMap()); - debugger.addDebugger("Messages", new DMessages()); - debugger.addDebugger("Mouse", new DMouse()); - debugger.addDebugger("Npcs", new DNpcs()); - debugger.addDebugger("Objects", new DSceneObjects()); - debugger.addDebugger("Players", new DPlayers()); - - debug.add(actions); - debug.add(animation); - debug.add(bank); - debug.add(flags); - debug.add(items); - debug.add(interfaces); - debug.add(inventory); - debug.add(map); - debug.add(messages); - debug.add(mouse); - debug.add(npcs); - debug.add(objects); - debug.add(players); - - bar.add(debug); - } - - private JMenuItem newItem(String name) { - JMenuItem item = new JCheckBoxMenuItem(name); - item.addActionListener(this); - return item; - } - - @Override - public void actionPerformed(ActionEvent e) { - Context.getInstance().getPaintDebugger().toggle(e.getActionCommand()); - } - -} +package org.rev317.min.ui; + +import org.parabot.core.Context; +import org.parabot.core.paint.PaintDebugger; +import org.rev317.min.debug.*; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author JKetelaar, Everel + */ +public class BotMenu implements ActionListener { + + public BotMenu(JMenuBar bar) { + PaintDebugger debugger = Context.getInstance().getPaintDebugger(); + + JMenu debug = new JMenu("Debug"); + + JMenuItem actions = newItem("Actions"); + JMenuItem animation = newItem("Animation"); + JMenuItem bank = newItem("Bank"); + JMenuItem flags = newItem("Collision flags"); + JMenuItem items = newItem("GroundItems"); + JMenuItem interfaces = newItem("Interfaces"); + JMenuItem inventory = newItem("Inventory"); + JMenuItem map = newItem("Map"); + JMenuItem messages = newItem("Messages"); + JMenuItem mouse = newItem("Mouse"); + JMenuItem npcs = newItem("Npcs"); + JMenuItem objects = newItem("Objects"); + JMenuItem players = newItem("Players"); + + debugger.addDebugger("Actions", new DActions()); + debugger.addDebugger("Animation", new DAnimation()); + debugger.addDebugger("Bank", new DBank()); + debugger.addDebugger("Collision flags", new DCollisionFlags()); + debugger.addDebugger("GroundItems", new DGroundItems()); + debugger.addDebugger("Interfaces", new DInterfaces()); + debugger.addDebugger("Inventory", new DInventory()); + debugger.addDebugger("Map", new DMap()); + debugger.addDebugger("Messages", new DMessages()); + debugger.addDebugger("Mouse", new DMouse()); + debugger.addDebugger("Npcs", new DNpcs()); + debugger.addDebugger("Objects", new DSceneObjects()); + debugger.addDebugger("Players", new DPlayers()); + + debug.add(actions); + debug.add(animation); + debug.add(bank); + debug.add(flags); + debug.add(items); + debug.add(interfaces); + debug.add(inventory); + debug.add(map); + debug.add(messages); + debug.add(mouse); + debug.add(npcs); + debug.add(objects); + debug.add(players); + + bar.add(debug); + } + + private JMenuItem newItem(String name) { + JMenuItem item = new JCheckBoxMenuItem(name); + item.addActionListener(this); + return item; + } + + @Override + public void actionPerformed(ActionEvent e) { + Context.getInstance().getPaintDebugger().toggle(e.getActionCommand()); + } + +} diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..49fcee8 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Sun Sep 13 22:54:43 CEST 2015 +version=1.0 +groupId=org.parabot +artifactId=317-API-Minified