armark1ng

Untitled

Sep 22nd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.66 KB | None | 0 0
  1. public void acceptInvite() {
  2. Player invitedBy = (Player) player.getTemporaryAttributtes().remove(Key.DUNGEON_INVITED_BY);
  3. if (invitedBy == null)
  4. return;
  5. DungeonPartyManager party = invitedBy.getDungManager().getParty();
  6. if (invitedBy.getDungManager().invitingPlayer != player || party == null || !party.isLeader(invitedBy)) {
  7. player.closeInterfaces();
  8. player.getPackets().sendGameMessage("You can't do that right now.");
  9. return;
  10. }
  11. if (party.getTeam().size() >= 5) {
  12. player.closeInterfaces();
  13. player.getPackets().sendGameMessage("The party is full.");
  14. return;
  15. }
  16. if (party.getComplexity() > maxComplexity) {
  17. player.closeInterfaces();
  18. player.getPackets().sendGameMessage("You can't do this complexity.");
  19. return;
  20. }
  21. if (party.getFloor() > maxFloor) {
  22. player.closeInterfaces();
  23. player.getPackets().sendGameMessage("You can't do this floor.");
  24. return;
  25. }
  26. invitedBy.getDungManager().resetInvitation();
  27. invitedBy.getDungManager().getParty().setDificulty(0);
  28. invitedBy.getDungManager().getParty().add(player);
  29. player.stopAll();
  30. invitedBy.stopAll();
  31. }
  32.  
  33. public void invite(String name) {
  34. player.stopAll();
  35. if (party == null) {
  36. final Player p2 = World.getPlayerByDisplayName(name);
  37. if (p2 == null) {
  38. player.getPackets().sendGameMessage("Unable to find " + name);
  39. return;
  40. }
  41. DungeonPartyManager party = p2.getDungManager().getParty();
  42. if (p2.getDungManager().invitingPlayer != player || player.getPlane() != 0 || party == null
  43. || !party.isLeader(p2)) {
  44. player.getPackets().sendGameMessage("You can't do that right now.");
  45. return;
  46. }
  47. player.getTemporaryAttributtes().put(Key.DUNGEON_INVITED_BY, p2);
  48. player.getInterfaceManager().sendInterface(949);
  49. for (int i = 0; i < 5; i++) {
  50. Player teamMate = i >= party.getTeam().size() ? null : party.getTeam().get(i);
  51. player.getPackets().sendGlobalString(284 + i, teamMate == null ? "" : teamMate.getDisplayName());
  52. player.getPackets().sendCSVarInteger(1153 + i,
  53. teamMate == null ? -1 : teamMate.getSkills().getCombatLevelWithSummoning());
  54. player.getPackets().sendCSVarInteger(1158 + i,
  55. teamMate == null ? -1 : teamMate.getSkills().getLevelForXp(Skills.DUNGEONEERING));
  56. player.getPackets().sendCSVarInteger(1163 + i,
  57. teamMate == null ? -1 : teamMate.getSkills().getHighestSkillLevel());
  58. player.getPackets().sendCSVarInteger(1168 + i,
  59. teamMate == null ? -1 : teamMate.getSkills().getTotalLevel());
  60. }
  61. player.getPackets().sendCSVarInteger(1173, party.getFloor());
  62. player.getPackets().sendCSVarInteger(1174, party.getComplexity());
  63. player.setCloseInterfacesEvent(new Runnable() {
  64.  
  65. @Override
  66. public void run() {
  67. p2.getDungManager().expireInvitation();
  68. player.getTemporaryAttributtes().remove(Key.DUNGEON_INVITED_BY);
  69. }
  70.  
  71. });
  72. } else {
  73. if (!party.isLeader(player) || party.getDungeon() != null) {
  74. player.getPackets().sendGameMessage("You can't do that right now.");
  75. return;
  76. }
  77. if (party.getSize() >= 5) {
  78. player.getPackets().sendGameMessage("Your party is full.");
  79. return;
  80. }
  81. Player p2 = World.getPlayerByDisplayName(name);
  82. if (p2 == null) {
  83. player.getPackets().sendGameMessage("That player is offline, or has privacy mode enabled.");
  84. return;
  85. }
  86. if (!(p2.getControlerManager().getControler() instanceof Kalaboss)) {
  87. player.getPackets().sendGameMessage("You can only invite a player in or around Daemonheim.");
  88. return;
  89. }
  90. if (p2.getDungManager().party != null) {
  91. player.getPackets().sendGameMessage(p2.getDisplayName() + " is already in a party.");
  92. return;
  93. }
  94. if (p2.getInterfaceManager().containsScreenInter() || p2.isCantTrade() || p2.isLocked()) {
  95. player.getPackets().sendGameMessage("The other player is busy.");
  96. return;
  97. }
  98. expireInvitation();
  99. invitingPlayer = p2;
  100. player.getPackets().sendGameMessage("Sending party invitation to " + p2.getDisplayName() + "...");
  101. p2.getPackets().sendDungeonneringRequestMessage(player);
  102. }
  103.  
  104. }
  105.  
  106. public void openResetProgress() {
  107. player.stopAll();
  108. player.getDialogueManager().startDialogue("PrestigeReset");
  109. }
  110.  
  111. public void switchGuideMode() {
  112. if (party == null) {
  113. player.getPackets().sendGameMessage("You must be in a party to do that.");
  114. return;
  115. }
  116. if (party.getDungeon() != null) {
  117. player.getPackets().sendGameMessage("You cannot change the guide mode once the dungeon has started.");
  118. return;
  119. }
  120. if (!party.isLeader(this.player)) {
  121. this.player.getPackets().sendGameMessage("Only your party's leader can switch guide mode!");
  122. return;
  123. }
  124. player.stopAll();
  125. party.setGuideMode(!party.getGuideMode());
  126. if (party.getGuideMode())
  127. player.getPackets().sendGameMessage(
  128. "Guide mode enabled. Your map will show you the critical path, but you will receive an xp penalty.");
  129. else
  130. player.getPackets().sendGameMessage("Guide mode disabled. Your map will no longer show the critical path.");
  131. for (Player p2 : party.getTeam())
  132. p2.getDungManager().refreshPartyGuideModeComponent();
  133. }
  134.  
  135. public void changeFloor() {
  136. if (party == null) {
  137. player.getPackets().sendGameMessage("You must be in a party to do that.");
  138. return;
  139. }
  140. if (party.getDungeon() != null) {
  141. player.getPackets().sendGameMessage("You cannot change these settings while in a dungeon.");
  142. return;
  143. }
  144. if (!party.isLeader(this.player)) {
  145. this.player.getPackets().sendGameMessage("Only your party's leader can change floor!");
  146. return;
  147. }
  148. player.stopAll();
  149. player.getInterfaceManager().sendInterface(947);
  150. for (int i = 0; i < party.getMaxFloor(); i++)
  151. player.getPackets().sendHideIComponent(947, 48 + i, false);
  152. for (int index = party.getTeam().size() - 1; index >= 0; index--) {
  153. Player teamMate = party.getTeam().get(index);
  154. for (int floor = 1; floor < teamMate.getDungManager().getMaxFloor(); floor++) {
  155. player.getPackets().sendHideIComponent(947, 120 + floor + (4 - index) * 122, false);
  156. if (teamMate.getDungManager().currentProgress[floor - 1])
  157. player.getPackets().sendHideIComponent(947, 180 + floor + (4 - index) * 122, false);
  158. }
  159. }
  160. player.setCloseInterfacesEvent(new Runnable() {
  161. @Override
  162. public void run() {
  163. player.getTemporaryAttributtes().remove(Key.DUNG_FLOOR);
  164. }
  165. });
  166. }
  167.  
  168. public void selectFloor(int floor) {
  169. if (party == null) {
  170. player.getPackets().sendGameMessage("You must be in a party to do that.");
  171. return;
  172. }
  173. /*
  174. * cant happen, cuz u cant click anyway but oh well
  175. */
  176. if (party.getMaxFloor() < party.getMaxFloor()) {
  177. player.getPackets().sendGameMessage("A member in your party can't do this floor.");
  178. return;
  179. }
  180. player.getPackets().sendIComponentText(947, 765, "" + floor);
  181. player.getTemporaryAttributtes().put(Key.DUNG_FLOOR, floor);
  182. }
  183.  
  184. public void confirmFloor() {
  185. Integer selectedFloor = (Integer) player.getTemporaryAttributtes().remove(Key.DUNG_FLOOR);
  186. player.stopAll();
  187. if (party == null) {
  188. player.getPackets().sendGameMessage("You must be in a party to do that.");
  189. return;
  190. }
  191. if (selectedFloor == null)
  192. selectedFloor = party.getMaxFloor();
  193. if (party.getMaxFloor() < party.getMaxFloor()) {
  194. player.getPackets().sendGameMessage("A member in your party can't do this floor.");
  195. return;
  196. }
  197. if (party.getDungeon() != null) {
  198. player.getPackets().sendGameMessage("You cannot change these settings while in a dungeon.");
  199. return;
  200. }
  201. if (!party.isLeader(player)) {
  202. player.getPackets().sendGameMessage("Only your party's leader can change floor!");
  203. return;
  204. }
  205. party.setFloor(selectedFloor);
  206. }
  207.  
  208. public void changeComplexity() {
  209. if (party == null) {
  210. player.getPackets().sendGameMessage("You must be in a party to do that.");
  211. return;
  212. }
  213. if (party.getDungeon() != null) {
  214. player.getPackets().sendGameMessage("You cannot change these settings while in a dungeon.");
  215. return;
  216. }
  217. if (!party.isLeader(player)) {
  218. player.getPackets().sendGameMessage("Only your party's leader can change complexity!");
  219. return;
  220. }
  221. player.stopAll();
  222. player.getInterfaceManager().sendInterface(938);
  223. selectComplexity(party.getMaxComplexity());
  224. player.setCloseInterfacesEvent(new Runnable() {
  225. @Override
  226. public void run() {
  227. player.getTemporaryAttributtes().remove(Key.DUNG_COMPLEXITY);
  228. }
  229. });
  230. }
  231.  
  232. public void selectComplexity(int complexity) {
  233. if (party == null) {
  234. player.getPackets().sendGameMessage("You must be in a party to do that.");
  235. return;
  236. }
  237. if (party.getMaxComplexity() < complexity) {
  238. player.getPackets().sendGameMessage("A member in your party can't do this complexity.");
  239. return;
  240. }
  241. Integer selectedComplexity = (Integer) player.getTemporaryAttributtes().remove(Key.DUNG_COMPLEXITY);
  242. if (selectedComplexity != null)
  243. markComplexity(selectedComplexity, false);
  244. markComplexity(complexity, true);
  245. hideSkills(complexity);
  246. int penalty = complexity == 6 ? 0 : ((6 - complexity) * 5 + 25);
  247. player.getPackets().sendIComponentText(938, 42, "" + complexity);
  248. player.getPackets().sendIComponentText(938, 119, penalty + "% XP Penalty");
  249. player.getTemporaryAttributtes().put(Key.DUNG_COMPLEXITY, complexity);
  250. }
  251.  
  252. public void confirmComplexity() {
  253. Integer selectedComplexity = (Integer) player.getTemporaryAttributtes().remove(Key.DUNG_COMPLEXITY);
  254. player.stopAll();
  255. if (selectedComplexity == null)
  256. return;
  257. if (party == null) {
  258. player.getPackets().sendGameMessage("You must be in a party to do that.");
  259. return;
  260. }
  261. if (party.getMaxComplexity() < selectedComplexity) {
  262. player.getPackets().sendGameMessage("A member in your party can't do this complexity.");
  263. return;
  264. }
  265. if (party.getDungeon() != null) {
  266. player.getPackets().sendGameMessage("You cannot change these settings while in a dungeon.");
  267. return;
  268. }
  269. if (!party.isLeader(player)) {
  270. player.getPackets().sendGameMessage("Only your party's leader can change complexity!");
  271. return;
  272. }
  273. party.setComplexity(selectedComplexity);
  274. }
  275.  
  276. private void markComplexity(int complexity, boolean mark) {
  277. player.getPackets().sendHideIComponent(938, 57 + ((complexity - 1) * 5), !mark);
  278. }
  279.  
  280. private static final String[] COMPLEXITY_SKILLS = { "Combat", "Cooking", "Firemaking", "Woodcutting", "Fishing",
  281. "Creating Weapons", "Mining", "Runecrafting", "Farming Textiles", "Hunting", "Creating Armour",
  282. "Farming Seeds", "Herblore", "Thieving", "Summoning", "Construction" };
  283.  
  284. private void hideSkills(int complexity) {
  285. int count = 0;
  286. if (complexity >= 1)
  287. count += 1;
  288. if (complexity >= 2)
  289. count += 3;
  290. if (complexity >= 3)
  291. count += 3;
  292. if (complexity >= 4)
  293. count += 3;
  294. if (complexity >= 5)
  295. count += 3;
  296. if (complexity >= 6)
  297. count += 3;
  298. for (int i = 0; i < COMPLEXITY_SKILLS.length; i++) {
  299. player.getPackets().sendIComponentText(938, 88 + i * 2,
  300. (i >= count ? "<col=383838>" : "") + COMPLEXITY_SKILLS[i]);
  301. }
  302. }
Advertisement
Add Comment
Please, Sign In to add comment