armark1ng

Untitled

Jul 21st, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. package com.rs.game.player.actions;
  2.  
  3. import com.rs.cache.loaders.ItemDefinitions;
  4. import com.rs.game.Animation;
  5. import com.rs.game.item.Item;
  6. import com.rs.game.player.Player;
  7.  
  8. public class WaterFilling extends Action {
  9.  
  10. public enum Fill {
  11. VIAL(229, 227), BOWL(1923, 1921), BUCKET(1925, 1929), JUG(1937, 1935), VASE(
  12. 3734, 3735), PLANT_POT(5350, 5354), CLAY(434, 1761), WATERING_CAN_0(
  13. 5331, 5340), WATERING_CAN_1(5333, 5340), WATERING_CAN_2(5334,
  14. 5340), WATERING_CAN_3(5335, 5340), WATERING_CAN_4(5336, 5340), WATERING_CAN_5(
  15. 5337, 5340), WATERING_CAN_6(5338, 5340), WATERING_CAN_7(5339,
  16. 5340), DUNGEONEERING_VIAL(17490, 17492);
  17.  
  18. private int empty, full;
  19.  
  20. private Fill(int empty, int full) {
  21. this.empty = empty;
  22. this.full = full;
  23. }
  24.  
  25. public int getEmpty() {
  26. return empty;
  27. }
  28.  
  29. public int getFull() {
  30. return full;
  31. }
  32.  
  33. }
  34.  
  35. public static Fill getFillByProduce(int produce) {
  36. for (Fill fill : Fill.values()) {
  37. if (fill.full == produce)
  38. return fill;
  39. }
  40. return null;
  41. }
  42.  
  43. public static boolean isFilling(Player player, int empty, boolean isSpot) {
  44. for (Fill fill : Fill.values()) {
  45. if (fill.empty == empty) {
  46. if (isSpot && fill.ordinal() <= 4)
  47. return false;
  48. fill(player, fill);
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54.  
  55. private static void fill(Player player, Fill fill) {
  56. if (player.getInventory().getItems()
  57. .getNumberOf(new Item(fill.empty, 1)) <= 1) // contains
  58. // just
  59. // 1 lets start
  60. player.getActionManager().setAction(new WaterFilling(fill, 1));
  61. else
  62. player.getDialogueManager().startDialogue("WaterFillingD", fill);
  63. }
  64.  
  65. private Fill fill;
  66. private int quantity;
  67.  
  68. public WaterFilling(Fill fill, int quantity) {
  69. this.fill = fill;
  70. this.quantity = quantity;
  71. }
  72.  
  73. public boolean checkAll(Player player) {
  74. if (!player.getInventory().containsOneItem(fill.empty)) {
  75. player.getDialogueManager().startDialogue(
  76. "SimpleMessage",
  77. "You don't have any "
  78. + ItemDefinitions.getItemDefinitions(fill.empty)
  79. .getName().toLowerCase() + " to fill.");
  80. return false;
  81. }
  82. return true;
  83. }
  84.  
  85. @Override
  86. public boolean start(Player player) {
  87. if (checkAll(player)) {
  88. setActionDelay(player, 1);
  89. player.setNextAnimation(new Animation(832));
  90. String name = ItemDefinitions.getItemDefinitions(fill.full)
  91. .getName();
  92. if (name.contains(" ("))
  93. name = name.substring(0, name.indexOf(" ("));
  94. player.getPackets().sendGameMessage("You fill the " + name + ".");
  95. return true;
  96. }
  97. return false;
  98. }
  99.  
  100. @Override
  101. public boolean process(Player player) {
  102. return checkAll(player);
  103. }
  104.  
  105. @Override
  106. public int processWithDelay(Player player) {
  107. player.getInventory().deleteItem(fill.empty, 1);
  108. player.getInventory().addItem(fill.full, 1);
  109. quantity--;
  110. if (quantity <= 0)
  111. return -1;
  112. player.setNextAnimation(new Animation(fill.ordinal() == 5 ? 2272 : 832));
  113. return fill.ordinal() == 5 ? 3 : 0;
  114. }
  115.  
  116. @Override
  117. public void stop(final Player player) {
  118. setActionDelay(player, 3);
  119. }
  120. }
Add Comment
Please, Sign In to add comment