Untitled
unknown
java
a year ago
6.2 kB
10
Indexable
@PluginDescriptor(name = "RunEnabler", description = "", enabledByDefault = false, tags = {"ethan"}) public class RunEnabler extends Plugin { @Inject private Client client; private int currentActionIndex = 0; private CustomMenuEntry[] actions; private BotState currentState = BotState.OPEN_BANK; CustomMenuEntry selectJugOfWater = new CustomMenuEntry("Use", "<col=ff9040>Jug of water</col>", MenuAction.WIDGET_TARGET, 0, 0, 9764864, 1937); CustomMenuEntry useJugOnGrapes = new CustomMenuEntry("Use", "<col=ff9040>Jug of water</col><col=ffffff> -> <col=ff9040>Grapes</col>", MenuAction.WIDGET_TARGET_ON_WIDGET, 0, 1, 9764864, 1987); CustomMenuEntry openBank1 = new CustomMenuEntry("Bank", "<col=ffff00>Banker", MenuAction.NPC_THIRD_OPTION, 2908, 0, 0, null); CustomMenuEntry withdrawLogs = new CustomMenuEntry("Withdraw-All", "<col=ff9040>Willow logs</col>", MenuAction.CC_OP_LOW_PRIORITY, 7, 63, 786445, null); CustomMenuEntry closeBank1 = new CustomMenuEntry("Close", "", MenuAction.CC_OP, 1, 11, 786434, null); CustomMenuEntry openBank2 = new CustomMenuEntry("Bank", "Banker", MenuAction.NPC_THIRD_OPTION, 2908, 0, 0, null); CustomMenuEntry depositLogs = new CustomMenuEntry("Deposit-All", "<col=ff9040>Willow logs</col>", MenuAction.CC_OP_LOW_PRIORITY, 8, 0, 983043, null); CustomMenuEntry closeBank2 = new CustomMenuEntry("Close", "", MenuAction.CC_OP, 1,11, 786434, null); CustomMenuEntry clickItem = new CustomMenuEntry("Use","<col=ff9040>Jug of wine</col>", MenuAction.WIDGET_TARGET,0,0,9764864,9764864); @Override protected void startUp() { //actions = new CustomMenuEntry[]{useJugOnGrapes}; currentActionIndex = 0; // Initialize to the first action currentState = BotState.OPEN_BANK; } @Override protected void shutDown() { currentActionIndex = 0; currentState = BotState.OPEN_BANK; actions = new CustomMenuEntry[actions.length]; } @Subscribe private void onClientTick(ClientTick event) { if (client.getGameState() != GameState.LOGGED_IN) return; switch (currentState) { case OPEN_BANK: adjustMenuEntry(actions[0]); break; case WITHDRAW_LOGS: if (isBankOpen()) { adjustMenuEntry(actions[1]); } break; case CLOSE_BANK: if (isBankOpen()) { adjustMenuEntry(actions[2]); } break; case DEPOSIT_LOGS: if (isBankOpen()) { adjustMenuEntry(actions[4]); } break; } } private boolean hasWillowLogs() { ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY); if (inventory != null) { Item[] items = inventory.getItems(); for (Item item : items) { // Check if the item is willow logs if (item.getId() == ItemID.WILLOW_LOGS) { return true; // Willow logs found in inventory } } } return false; // Willow logs not found in inventory } @Subscribe private void onMenuOptionClicked(MenuOptionClicked event) { MenuEntry entry = event.getMenuEntry(); CustomMenuEntry expectedAction = actions[currentActionIndex]; if (event.getMenuOption().equals(expectedAction.menuOption) && event.getMenuTarget().equals(expectedAction.menuTarget)) { currentActionIndex = (currentActionIndex + 1) % actions.length; if (currentActionIndex == 1 && hasWillowLogs()) { currentState = BotState.DEPOSIT_LOGS; } else { switch (currentActionIndex) { case 0: currentState = BotState.OPEN_BANK; break; case 1: currentState = BotState.WITHDRAW_LOGS; break; case 2: currentState = BotState.CLOSE_BANK; break; case 3: currentState = BotState.OPEN_BANK; break; case 4: currentState = BotState.DEPOSIT_LOGS; break; case 5: currentState = BotState.CLOSE_BANK; break; } } } } private void adjustMenuEntry(CustomMenuEntry action) { MenuEntry[] menuEntries = client.getMenuEntries(); if (menuEntries.length > 0) { MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; if (!lastEntry.getOption().equals(action.menuOption) || !lastEntry.getTarget().equals(action.menuTarget)) { lastEntry.setOption(action.menuOption); lastEntry.setTarget(action.menuTarget); lastEntry.setType(action.menuAction); lastEntry.setIdentifier(action.identifier); lastEntry.setParam0(action.param0); lastEntry.setParam1(action.param1); try { // Reference the rl3 class Method ebMethod = lastEntry.getClass().getDeclaredMethod("eb", int.class); ebMethod.setAccessible(true); if (action.getItemID() != null) { // Check if itemId is present ebMethod.invoke(lastEntry, action.getItemID()); } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } } } } private boolean isBankOpen() { return client.getWidget(WidgetInfo.BANK_CONTAINER) != null; }
Editor is loading...