Advertisement
Guest User

Untitled

a guest
May 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. package jketelaar;
  2.  
  3. import org.parabot.environment.scripts.Script;
  4. import org.parabot.environment.scripts.ScriptManifest;
  5. import org.parabot.environment.scripts.framework.LoopTask;
  6.  
  7. import javax.swing.JOptionPane;
  8.  
  9. import org.parabot.core.ui.Logger;
  10. import org.parabot.core.ui.utils.UILog;
  11. import org.parabot.environment.api.utils.Random;
  12. import org.parabot.environment.api.utils.Time;
  13. import org.parabot.environment.scripts.Category;
  14. import org.rev317.min.Loader;
  15. import org.rev317.min.api.methods.Inventory;
  16. import org.rev317.min.api.methods.Menu;
  17. import org.rev317.min.api.wrappers.Item;
  18. import org.rev317.min.input.Keyboard;
  19.  
  20. @ScriptManifest(author = "JKetelaar", category = Category.OTHER, description = "Sells any item in any store. Ensure the shop interface is open and item is in your inventory", name = "JKSeller", servers = {
  21. "Ikov" }, version = 1.0)
  22. public class JKSeller extends Script implements LoopTask {
  23. private int itemId = -1;
  24. private int amount = -1;
  25.  
  26. public int loop() {
  27. Item a = Inventory.getItem(itemId);
  28. if (a == null) {
  29. Logger.addMessage("Could not find item in inventory");
  30. setState(2);
  31. return Random.between(750, 1500);
  32. }
  33. Menu.sendAction(53, (a.getId() - 1), a.getSlot(), 3823, a.getSlot(), 0);
  34. Time.sleep(() -> Loader.getClient().getBackDialogId() > 0, 500);
  35. Time.sleep(500, 750);
  36. Keyboard.getInstance().sendKeys(String.valueOf(amount), false);
  37. Time.sleep(250, 500);
  38. Keyboard.getInstance().clickKey(10);
  39. return Random.between(750, 1500);
  40. }
  41.  
  42. public boolean onExecute() {
  43. if (Loader.getClient().getOpenInterfaceId() <= 0) {
  44. UILog.log("Store not open.", "Store interface is not open. Open the store before starting the script.", 0);
  45. return false;
  46. }
  47. Item[] f = Inventory.getItems();
  48. Object[] arrobject = new String[f.length];
  49. for (int i = 0; i < f.length; i++) {
  50. arrobject[i] = String.valueOf(f[i].getId());
  51. }
  52. String c = (String) JOptionPane.showInputDialog(null, "Choose item available in your inventory", "Choose item",
  53. 3, null, arrobject, arrobject[0]);
  54. try {
  55. itemId = Integer.parseInt(c);
  56. } catch (Exception a) {
  57. UILog.log("Not a Number", "Given ID is invalid", 0);
  58. return false;
  59. }
  60. if (itemId <= 0) {
  61. UILog.log("Invalid number", "Given ID is invalid", 0);
  62. return false;
  63. }
  64. try {
  65. amount = Integer.parseInt(JOptionPane.showInputDialog("How many items would you like to sell per action?"));
  66. } catch (Exception b) {
  67. UILog.log("Not a Number", "Given amount is invalid", 0);
  68. return false;
  69. }
  70. if (amount > 0) {
  71. return super.onExecute();
  72. }
  73. UILog.log("Invalid number", "Given amount is invalid", 0);
  74. return false;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement