[CLEANUP] Removed duplicated method && unused code

This commit is contained in:
Emmastone
2016-10-16 23:55:41 +01:00
parent 0ae03219a2
commit 0c07067201
4 changed files with 39 additions and 55 deletions
@@ -36,23 +36,6 @@ public class Game {
return Loader.getClient().getOpenInterfaceId(); return Loader.getClient().getOpenInterfaceId();
} }
/**
* Get open back dialog id
*
* @return back dialog id
*/
public static int getOpenBackDialogId() {
return Loader.getClient().getBackDialogId();
}
/**
* Get current input dialog state
* @return input dialog state
*/
public static int getInputDialogState() {
return Loader.getClient().getInputDialogState();
}
/** /**
* Gets loop cycle * Gets loop cycle
* *
@@ -13,31 +13,35 @@ public class Interfaces {
/** /**
* Get's the interfaces loaded in the interface Cache. * Get's the interfaces loaded in the interface Cache.
*
* @return Interfaces in the Interface Cache. * @return Interfaces in the Interface Cache.
*/ */
public static Interface[] getInterfaces(){ public static Interface[] getInterfaces() {
return Loader.getClient().getInterfaceCache(); return Loader.getClient().getInterfaceCache();
} }
/** /**
* Get's the Interface from the Interface Cache using the given ID. * Get's the Interface from the Interface Cache using the given ID.
*
* @param id Interface ID. * @param id Interface ID.
* @return Interface from the cache by the given ID. * @return Interface from the cache by the given ID.
*/ */
public static Interface getInterface(int id){ public static Interface getInterface(int id) {
return getInterfaces()[id]; return getInterfaces()[id];
} }
/** /**
* Opens the Interface by the given ID. * Opens the Interface by the given ID.
*
* @param id ID of the Interface to Open. * @param id ID of the Interface to Open.
*/ */
public static void openInterface(int id){ public static void openInterface(int id) {
Loader.getClient().setInterface(id); Loader.getClient().setInterface(id);
} }
/** /**
* Sets the int by the given Amount * Sets the int by the given Amount
*
* @param amount Amount to set * @param amount Amount to set
*/ */
public static void setAmountOrNameInput(int amount) { public static void setAmountOrNameInput(int amount) {
@@ -46,45 +50,59 @@ public class Interfaces {
/** /**
* Get's the Open Interface ID. * Get's the Open Interface ID.
*
* @return The ID of the Open Interface , will be -1 if all Interfaces are closed. * @return The ID of the Open Interface , will be -1 if all Interfaces are closed.
*/ */
public static int getOpenInterfaceId(){ public static int getOpenInterfaceId() {
return Loader.getClient().getOpenInterfaceId(); return Loader.getClient().getOpenInterfaceId();
} }
/** /**
* Get's the Open Back Dialog ID. * Get's the Open Back Dialog ID.
*
* @return The ID of the Open Back Dialog , will be -1 if all Back Dialogs are closed. * @return The ID of the Open Back Dialog , will be -1 if all Back Dialogs are closed.
*/ */
public static int getBackDialogId(){ public static int getBackDialogId() {
return Loader.getClient().getBackDialogId(); return Loader.getClient().getBackDialogId();
} }
/**
* Get current input dialog state
*
* @return input dialog state
*/
public static int getInputDialogState() {
return Loader.getClient().getInputDialogState();
}
/** /**
* Checks if the Interface or Back Dialog by the given ID is Open. * Checks if the Interface or Back Dialog by the given ID is Open.
*
* @param id ID of the Interface or Back Dialog to check for. * @param id ID of the Interface or Back Dialog to check for.
* @return True is the Interface or Back Dialog is Open else will return false. * @return True is the Interface or Back Dialog is Open else will return false.
*/ */
public static boolean isOpen(int id){ public static boolean isOpen(int id) {
return getOpenInterfaceId() == id || getBackDialogId() == id; return getOpenInterfaceId() == id || getBackDialogId() == id;
} }
/** /**
* Checks if the Interface by the given ID is Open. * Checks if the Interface by the given ID is Open.
* @param id ID of the Interface or Back Dialog to check for depending on the backDialog boolean. *
* @param id ID of the Interface or Back Dialog to check for depending on the backDialog boolean.
* @param backDialog When tru it will check the Bank Dialog ID else it will check for the Interface ID. * @param backDialog When tru it will check the Bank Dialog ID else it will check for the Interface ID.
* @return True is the Interface or Back Dialog is Open else will return false. * @return True is the Interface or Back Dialog is Open else will return false.
*/ */
public static boolean isOpen(int id, boolean backDialog){ public static boolean isOpen(int id, boolean backDialog) {
if(backDialog){ if (backDialog) {
return getBackDialogId() == id; return getBackDialogId() == id;
}else{ } else {
return getOpenInterfaceId() == id; return getOpenInterfaceId() == id;
} }
} }
/** /**
* Clicks an option from the given back dialog * Clicks an option from the given back dialog
*
* @param index Index of the requested option whereas you start at 0 * @param index Index of the requested option whereas you start at 0
*/ */
public static void clickBackDialogOption(int index) { public static void clickBackDialogOption(int index) {
@@ -6,8 +6,6 @@ import org.rev317.min.accessors.Client;
import org.rev317.min.api.wrappers.Character; import org.rev317.min.api.wrappers.Character;
import org.rev317.min.api.wrappers.*; import org.rev317.min.api.wrappers.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
/** /**
@@ -34,10 +32,9 @@ public class Menu {
/** /**
* Interacts with a sceneobject * Interacts with a sceneobject
* *
* @deprecated
*
* @param object * @param object
* @param actionIndex * @param actionIndex
* @deprecated
*/ */
public static void interact(SceneObject object, int actionIndex) { public static void interact(SceneObject object, int actionIndex) {
int actionId = SceneObjects.Option.FIRST.getActionId(); int actionId = SceneObjects.Option.FIRST.getActionId();
@@ -88,10 +85,9 @@ public class Menu {
/** /**
* Interacts with a character * Interacts with a character
* *
* @deprecated
*
* @param character * @param character
* @param actionIndex * @param actionIndex
* @deprecated
*/ */
public static void interact(Character character, int actionIndex) { public static void interact(Character character, int actionIndex) {
int actionId = 20; int actionId = 20;
@@ -131,11 +127,10 @@ public class Menu {
/** /**
* Interacts with an item when it has the following menu Transform-1 Transform-5 Transform-10 etc.. * Interacts with an item when it has the following menu Transform-1 Transform-5 Transform-10 etc..
* *
* @deprecated
*
* @param item * @param item
* @param actionIndex * @param actionIndex
* @param interfaceParentId * @param interfaceParentId
* @deprecated
*/ */
public static void transformItem(Item item, int actionIndex, public static void transformItem(Item item, int actionIndex,
int interfaceParentId) { int interfaceParentId) {
@@ -183,10 +178,9 @@ public class Menu {
/** /**
* Interacts with a ground item * Interacts with a ground item
* *
* @deprecated
*
* @param item * @param item
* @param action * @param action
* @deprecated
*/ */
public static void interact(GroundItem item, int action) { public static void interact(GroundItem item, int action) {
int actionId = GroundItems.Option.FIRST.getActionId(); int actionId = GroundItems.Option.FIRST.getActionId();
@@ -210,16 +204,16 @@ public class Menu {
sendAction(actionId, item.getId(), item.getX(), item.getY()); sendAction(actionId, item.getId(), item.getX(), item.getY());
} }
public static void interact(Item item, Items.Option action){ public static void interact(Item item, Items.Option action) {
sendAction(action.getActionId(), item.getId() - 1, item.getSlot(), 3214); sendAction(action.getActionId(), item.getId() - 1, item.getSlot(), 3214);
} }
/** /**
* @deprecated * @deprecated
*/ */
public static void interact(Item item, int action){ public static void interact(Item item, int action) {
int actionId = 447; int actionId = 447;
switch (action){ switch (action) {
case 0: case 0:
actionId = 447; actionId = 447;
break; break;
@@ -239,9 +233,9 @@ public class Menu {
/** /**
* @deprecated * @deprecated
*/ */
public static void interact(Item item, String action){ public static void interact(Item item, String action) {
int actionId = 447; int actionId = 447;
switch (action.toLowerCase()){ switch (action.toLowerCase()) {
case "use": case "use":
actionId = 447; actionId = 447;
break; break;
@@ -319,20 +313,8 @@ public class Menu {
* @param index * @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, int cmd4, int index) {
Client client = Loader.getClient(); Client client = Loader.getClient();
try {
Method doAction = client.getClass().getDeclaredMethod("doAction", int.class);
doAction.setAccessible(true);
doAction.invoke(client, 0);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
client.getMenuAction1()[index] = cmd1; client.getMenuAction1()[index] = cmd1;
client.getMenuAction2()[index] = cmd2; client.getMenuAction2()[index] = cmd2;
client.getMenuAction3()[index] = cmd3; client.getMenuAction3()[index] = cmd3;
@@ -4,6 +4,7 @@ import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger; import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger; import org.parabot.core.paint.PaintDebugger;
import org.rev317.min.api.methods.Game; import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Interfaces;
import java.awt.*; import java.awt.*;
@@ -14,7 +15,7 @@ public class DInterfaces extends AbstractDebugger {
public void paint(Graphics g) { public void paint(Graphics g) {
PaintDebugger p = Context.getInstance().getPaintDebugger(); PaintDebugger p = Context.getInstance().getPaintDebugger();
p.addLine("Open interface: " + Game.getOpenInterfaceId()); p.addLine("Open interface: " + Game.getOpenInterfaceId());
p.addLine("Open back dialog: " + Game.getOpenBackDialogId()); p.addLine("Open back dialog: " + Interfaces.getBackDialogId());
} }
@Override @Override