diff --git a/.travis.yml b/.travis.yml index 264baa0..49a8e29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ notifications: env: global: - - PROVIDER_VERSION=2.0.2 + - PROVIDER_VERSION=2.0.3 cache: directories: diff --git a/pom.xml b/pom.xml index 1cfb6c5..e5dc00a 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.parabot.servers 317-api-minified-runewild - 2.0.2 + 2.0.3 Parabot 317-API-Minified RuneWild diff --git a/src/main/java/org/rev317/min/Loader.java b/src/main/java/org/rev317/min/Loader.java index 529d3dc..f15659b 100755 --- a/src/main/java/org/rev317/min/Loader.java +++ b/src/main/java/org/rev317/min/Loader.java @@ -13,6 +13,7 @@ import org.parabot.environment.servers.ServerProvider; import org.parabot.environment.servers.Type; import org.rev317.min.accessors.Client; +import org.rev317.min.randoms.UUIDSpoofer; import org.rev317.min.script.ScriptEngine; import org.rev317.min.ui.BotMenu; @@ -105,5 +106,6 @@ public void unloadScript(Script script) { @Override public void init() { + ScriptEngine.getInstance().addLoginListener(new UUIDSpoofer()); } -} \ No newline at end of file +} diff --git a/src/main/java/org/rev317/min/accessors/Client.java b/src/main/java/org/rev317/min/accessors/Client.java index 8ab225b..afba4ea 100755 --- a/src/main/java/org/rev317/min/accessors/Client.java +++ b/src/main/java/org/rev317/min/accessors/Client.java @@ -37,6 +37,8 @@ public interface Client { int[] getMenuActionId(); + long[] getMenuHash(); + int[] getMenuAction1(); int[] getMenuAction2(); @@ -57,7 +59,7 @@ public interface Client { void dropClient(); - void login(String username, String password, boolean reconnecting); + void login(boolean reconnecting, String emailAddress, String username, String password); int[] getCurrentStats(); diff --git a/src/main/java/org/rev317/min/accessors/SceneObjectTile.java b/src/main/java/org/rev317/min/accessors/SceneObjectTile.java new file mode 100644 index 0000000..4d118be --- /dev/null +++ b/src/main/java/org/rev317/min/accessors/SceneObjectTile.java @@ -0,0 +1,6 @@ +package org.rev317.min.accessors; + +public interface SceneObjectTile { + + long getHash(); +} diff --git a/src/main/java/org/rev317/min/api/events/LoginEvent.java b/src/main/java/org/rev317/min/api/events/LoginEvent.java new file mode 100644 index 0000000..dd4e66f --- /dev/null +++ b/src/main/java/org/rev317/min/api/events/LoginEvent.java @@ -0,0 +1,25 @@ +package org.rev317.min.api.events; + +public final class LoginEvent { + private final String username; + private final String password; + private final boolean flag; + + public LoginEvent(String username, String password, boolean flag) { + this.username = username; + this.password = password; + this.flag = flag; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + public boolean isFlag() { + return flag; + } +} diff --git a/src/main/java/org/rev317/min/api/events/listeners/LoginListener.java b/src/main/java/org/rev317/min/api/events/listeners/LoginListener.java new file mode 100644 index 0000000..c883f05 --- /dev/null +++ b/src/main/java/org/rev317/min/api/events/listeners/LoginListener.java @@ -0,0 +1,8 @@ +package org.rev317.min.api.events.listeners; + +import org.rev317.min.api.events.LoginEvent; + +public interface LoginListener { + + void loginReceived(LoginEvent event); +} diff --git a/src/main/java/org/rev317/min/api/methods/Equipment.java b/src/main/java/org/rev317/min/api/methods/Equipment.java new file mode 100644 index 0000000..1783fa4 --- /dev/null +++ b/src/main/java/org/rev317/min/api/methods/Equipment.java @@ -0,0 +1,139 @@ +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; +import org.rev317.min.api.wrappers.Item; + +/** + * @author Piet Jetse Heeringa + */ + +public class Equipment { + + /** + * Equips an Item based on the ID of that item. + * + * @param id Item ID to Equip. + */ + public static void equip(final int id) { + Item item = Inventory.getItem(id); + if (item != null) { + item.interact(Items.Option.WEAR); + Time.sleep(new SleepCondition() { + @Override + public boolean isValid() { + return isWearing(id); + } + }, 3000); + } + } + + /** + * Unequips an Item based on the ID of that item. + * + * @param id Item ID to Unequip. + */ + public static void unequip(int id) { + for (Slot slot : Slot.values()) { + if (slot.id() == id) { + unequip(slot); + } + } + } + + /** + * Unequips the item from the given Slot. + * + * @param slot Slot to Unequip the item from. + */ + public static void unequip(final Slot slot) { + Menu.sendAction(632, slot.id() - 1, slot.slot, 1688, 3); + Time.sleep(new SleepCondition() { + @Override + public boolean isValid() { + return slot.id() == 0; + } + }, 3000); + } + + /** + * Check if the Player is Wearing an Item based on the ID. + * + * @param id ID of the item to check for. + * + * @return True if the Player is wearing the Item. + */ + public static boolean isWearing(int id) { + for (Slot slot : Slot.values()) { + if (slot.id() == id) { + return true; + } + } + + return false; + } + + /** + * Get's the item ID in slot. + * + * @param slot Slot to get the item ID from. + * + * @return Item ID from given slot. + */ + public static int getItemId(Slot slot) { + return slot.id(); + } + + /** + * Check's if there is an item in the given slot. + * + * @param slot Slot to check for Item. + * + * @return True if there is an Item in the given slot. + */ + public static boolean hasItem(Slot slot) { + return getItemId(slot) != 0; + } + + /** + * Check's if the given slot is empty. + * + * @param slot Slot to check for Item. + * + * @return True if the given slot is empty. + */ + public static boolean isEmpty(Slot slot) { + return getItemId(slot) == 0; + } + + public enum Slot { + HEAD(0), + CAPE(1), + AMMULET(2), + WEAPON(3), + BODY(4), + SHIELD(5), + LEGS(7), + GLOVES(9), + BOOTS(10), + RING(12), + AMMO(13); + + private final int INTERFACE_ID = 1688; + private int slot; + + Slot(int slot) { + this.slot = slot; + } + + /** + * Get's the ID of the item in slot. + * + * @return ID of the item in slot. + */ + public int id() { + return Loader.getClient().getInterfaceCache()[INTERFACE_ID].getItems()[slot]; + } + } +} diff --git a/src/main/java/org/rev317/min/api/methods/Game.java b/src/main/java/org/rev317/min/api/methods/Game.java new file mode 100644 index 0000000..43e5f37 --- /dev/null +++ b/src/main/java/org/rev317/min/api/methods/Game.java @@ -0,0 +1,196 @@ +package org.rev317.min.api.methods; + +import org.parabot.api.misc.TextUtils; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.SleepCondition; +import org.rev317.min.Loader; + +/** + * @author Everel, JKetelaar, EmmaStone + */ +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 + * + * @deprecated Use {@link Interfaces #getOpenInterfaceId()} instead + */ + @Deprecated + public static int getOpenInterfaceId() { + return Loader.getClient().getOpenInterfaceId(); + } + + /** + * Get open back dialog id + * + * @return back dialog id + * + * @deprecated Use {@link Interfaces #getBackDialogId()} instead + */ + @Deprecated + 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(); + } + + /** + * Gets the friends list long values + * + * @return long values of friends list + */ + public static long[] getFriendsListAsLong() { + return Loader.getClient().getFriendsListAsLong(); + } + + /** + * 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(); + } + + /** + * Just simply drops the client + */ + public static void dropClient() { + Loader.getClient().dropClient(); + } + + /** + * 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 confirmedDropClient() { + Loader.getClient().dropClient(); + Time.sleep(new SleepCondition() { + @Override + public boolean isValid() { + return !isLoggedIn(); + } + }, 2500); + + return !isLoggedIn(); + } + + /** + * Login to a server + * + * @param username String email + * @param password String + * @param reconnecting True if it's a retry, false if not + */ + public static void login(String username, String password, boolean reconnecting) { + Loader.getClient().login(reconnecting, username, username, password); + } + + /** + * Login to a server + * + * @param username String + * @param password String + */ + public static void login(String username, String password) { + login(username, password, false); + } + + /** + * Adds friend + * + * @param username String + */ + public static void addFriend(String username) { + Loader.getClient().addFriend(TextUtils.longForName(TextUtils.fixName(username))); + } + + /** + * Deletes friend + * + * @param username String + */ + public static void deleteFriend(String username) { + Loader.getClient().deleteFriend(TextUtils.longForName(TextUtils.fixName(username))); + } +} diff --git a/src/main/java/org/rev317/min/api/methods/Menu.java b/src/main/java/org/rev317/min/api/methods/Menu.java index 4756893..69f9271 100755 --- a/src/main/java/org/rev317/min/api/methods/Menu.java +++ b/src/main/java/org/rev317/min/api/methods/Menu.java @@ -1,5 +1,8 @@ package org.rev317.min.api.methods; +import org.parabot.core.Context; +import org.parabot.core.reflect.RefClass; +import org.parabot.core.ui.Logger; import org.rev317.min.Loader; import org.rev317.min.accessors.Client; import org.rev317.min.api.wrappers.Character; @@ -301,30 +304,38 @@ public static void sendAction(int action, int cmd1, int cmd2, int cmd3) { * @param index */ public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int index) { - sendAction(action, cmd1, cmd2, cmd3, 0, index); + sendAction(action, cmd1, cmd2, cmd3, 0L, index); } /** - * Sends an action to the client * * @param action * @param cmd1 * @param cmd2 * @param cmd3 - * @param cmd4 + * @param hash * @param index */ - public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) { + public static void sendAction(int action, int cmd1, int cmd2, int cmd3, long hash, int index) { Client client = Loader.getClient(); - + client.getMenuHash()[index] = hash; client.getMenuAction1()[index] = cmd1; client.getMenuAction2()[index] = cmd2; client.getMenuAction3()[index] = cmd3; - if (Game.hasAction4()) { - client.getMenuAction4()[index] = cmd4; - } client.getMenuActionId()[index] = action; - client.performAction(index); } + /** + * Sends an action to the client + * + * @param action + * @param cmd1 + * @param cmd2 + * @param cmd3 + * @param cmd4 + * @param index + */ + public static void sendAction(int action, int cmd1, int cmd2, int cmd3, int cmd4, int index) { + throw new UnsupportedOperationException("RuneWild cannot use #sendAction with a parameter of [int cmd4]. Use #sendAction with [long Hash] instead."); + } } diff --git a/src/main/java/org/rev317/min/api/wrappers/SceneObject.java b/src/main/java/org/rev317/min/api/wrappers/SceneObject.java new file mode 100644 index 0000000..942e202 --- /dev/null +++ b/src/main/java/org/rev317/min/api/wrappers/SceneObject.java @@ -0,0 +1,128 @@ +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 + * Custom code is #getHashLong and its usages in getLocalRegion X,Y and ID + */ +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 (int) getHashLong(); + } + + public final long getHashLong() { 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 (int) (getHashLong() & 0x7f); + } + + /** + * Gets region Y + * + * @return region Y + */ + public final int getLocalRegionY() { + return (int) (getHashLong() >> 7 & 0x7f); + } + + /** + * Gets this object's id + * + * @return object id + */ + public final int getId() { + return (int) ((getHashLong() >>> 32) & 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 + * + * @param actionIndex + * + * @deprecated + */ + 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/main/java/org/rev317/min/callback/LoginCallback.java b/src/main/java/org/rev317/min/callback/LoginCallback.java new file mode 100644 index 0000000..17c0d5f --- /dev/null +++ b/src/main/java/org/rev317/min/callback/LoginCallback.java @@ -0,0 +1,12 @@ +package org.rev317.min.callback; + +import org.rev317.min.api.events.LoginEvent; +import org.rev317.min.script.ScriptEngine; + +public class LoginCallback { + + public static void onLoginHook(String username, String password, boolean flag) { + final LoginEvent loginEvent = new LoginEvent(username, password, flag); + ScriptEngine.getInstance().dispatch(loginEvent); + } +} diff --git a/src/main/java/org/rev317/min/callback/MenuAction.java b/src/main/java/org/rev317/min/callback/MenuAction.java new file mode 100644 index 0000000..c8804c2 --- /dev/null +++ b/src/main/java/org/rev317/min/callback/MenuAction.java @@ -0,0 +1,66 @@ +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, JKetelaar, Matt123337 + * Custom code is client.getMenuHash()[index] + */ +public class MenuAction { + + private static final String[][] outputs = { + { + "[index: %d, action1: %d, action2: %d, action3: %d, action4: %d, id: %d]", + "[id: %d, action1: %d, action2: %d, action3: %d, action4: %d, index: %d]" + }, + { + "[index: %d, action1: %d, action2: %d, action3: %d, id: %d, hash: %d]", + "[id: %d, action1: %d, action2: %d, action3: %d, index: %d, hash: %d]" + } + }; + private static int currentOutputIndex = 0; + + public static void intercept(int index) { + int outputIndex = 0; + + Client client = Loader.getClient(); + long hashId = client.getMenuHash()[index]; // Unique to RuneWild + 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(outputs[0][outputIndex], index, action1, action2, action3, action4, actionId)); + } else { + System.out.println(String.format(outputs[1][outputIndex], index, action1, action2, action3, actionId, hashId)); + } + } + + final GameActionEvent actionEvent = new GameActionEvent(actionId, action1, action2, action3, action4, index); + ScriptEngine.getInstance().dispatch(actionEvent); + } + + /** + * Sets the current output index + * + * @param currentOutputIndex + */ + public static void setCurrentOutputIndex(int currentOutputIndex) { + if (currentOutputIndex > outputs.length) { + currentOutputIndex = 0; + } + MenuAction.currentOutputIndex = currentOutputIndex; + } + + public static String[][] getOutputs() { + return outputs; + } +} diff --git a/src/main/java/org/rev317/min/randoms/UUIDSpoofer.java b/src/main/java/org/rev317/min/randoms/UUIDSpoofer.java new file mode 100644 index 0000000..c2a6cf5 --- /dev/null +++ b/src/main/java/org/rev317/min/randoms/UUIDSpoofer.java @@ -0,0 +1,47 @@ +package org.rev317.min.randoms; + +import org.parabot.core.Context; +import org.parabot.environment.randoms.Random; +import org.parabot.environment.randoms.RandomType; +import org.rev317.min.api.events.LoginEvent; +import org.rev317.min.api.events.listeners.LoginListener; +import org.parabot.core.reflect.RefClass; + +import java.util.List; + +public class UUIDSpoofer implements LoginListener { + + @Override + public void loginReceived(LoginEvent event) { + /* + * This could probably be done much better, but this is one of my very few + * commits. I read through the ASM docs, but wasn't 100% sure if the refField + * desc would be in the exact same format as ASM. This should fix the login + * issue for RuneWild though. + * + * private boolean loggingIn; + * This is just a flag which needs to be set before sending + * the login frames to the Stream; false means we are logged out and + * can log in. + * + * public String myEmail; + * This is kept separate to the String parameter that's passed to + * the Client's login() function. I'm guessing it's so that their + * remember me login details works. + */ + RefClass clientRef = new RefClass(Context.getInstance().getClass(), Context.getInstance().getClient()); + clientRef.getField("loggingIn").setBoolean(false); + clientRef.getField("myEmail").setString(event.getUsername()); + + List randoms = Context.getInstance().getRandomHandler().getRandoms(); + for (Random random : randoms) { + if (random.getRandomType().equals(RandomType.ON_SERVER_START)) { + if (random.getName().equals("Mac Address Fix") && random.getServer().equals("RuneWild")) { + if (random.activate()) { + random.execute(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/org/rev317/min/script/ScriptEngine.java b/src/main/java/org/rev317/min/script/ScriptEngine.java new file mode 100644 index 0000000..9abfac2 --- /dev/null +++ b/src/main/java/org/rev317/min/script/ScriptEngine.java @@ -0,0 +1,206 @@ +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.LoginEvent; +import org.rev317.min.api.events.MessageEvent; +import org.rev317.min.api.events.listeners.GameActionListener; +import org.rev317.min.api.events.listeners.LoginListener; +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, matt123337 + */ +public class ScriptEngine { + private static HashMap instances = new HashMap<>(); + private ArrayList mouseListeners; + private ArrayList mouseMotionListeners; + private ArrayList messageListeners; + private ArrayList actionListeners; + private ArrayList loginListeners; + + private Script script = null; + + private ScriptEngine() { + this.mouseListeners = new ArrayList<>(); + this.mouseMotionListeners = new ArrayList<>(); + this.messageListeners = new ArrayList<>(); + this.actionListeners = new ArrayList<>(); + this.loginListeners = 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 addLoginListener(LoginListener loginListener) { + loginListeners.add(loginListener); + } + + public void removeLoginListener(LoginListener loginListener) { + loginListeners.remove(loginListener); + } + + public void clearLoginListener() { + loginListeners.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); + } + if (script instanceof LoginListener) { + addLoginListener((LoginListener) 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); + } + } + + public void dispatch(LoginEvent event) { + for (final LoginListener loginListener : loginListeners) { + loginListener.loginReceived(event); + } + } +}