Advertisement
Zavada

Untitled

Jan 14th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.84 KB | None | 0 0
  1. package com.vencillio.rs2.content;
  2.  
  3. import java.text.NumberFormat;
  4. import java.util.HashMap;
  5.  
  6. import com.vencillio.core.task.Task;
  7. import com.vencillio.core.task.TaskQueue;
  8. import com.vencillio.core.task.impl.TaskIdentifier;
  9. import com.vencillio.core.util.Utility;
  10. import com.vencillio.rs2.content.dialogue.DialogueManager;
  11. import com.vencillio.rs2.content.dialogue.Emotion;
  12. import com.vencillio.rs2.content.dialogue.OptionDialogue;
  13. import com.vencillio.rs2.content.membership.CreditPurchase;
  14. import com.vencillio.rs2.content.minigames.clanwars.ClanWarsConstants;
  15. import com.vencillio.rs2.content.minigames.weapongame.WeaponGameConstants;
  16. import com.vencillio.rs2.content.skill.magic.MagicSkill.TeleportTypes;
  17. import com.vencillio.rs2.entity.Animation;
  18. import com.vencillio.rs2.entity.Location;
  19. import com.vencillio.rs2.entity.mob.Mob;
  20. import com.vencillio.rs2.entity.mob.impl.Zulrah;
  21. import com.vencillio.rs2.entity.player.Player;
  22. import com.vencillio.rs2.entity.player.PlayerConstants;
  23. import com.vencillio.rs2.entity.player.net.out.impl.SendMessage;
  24. import com.vencillio.rs2.entity.player.net.out.impl.SendString;
  25.  
  26. /**
  27. * Handles teleporting around with interface
  28. * @author Daniel
  29. *
  30. */
  31. public class TeleportHandler {
  32.  
  33. /**
  34. * Teleportation data
  35. * @author Daniel
  36. *
  37. */
  38. /**
  39. public enum TeleportationData {
  40.  
  41.  
  42.  
  43. ROCK_CRABS(238123, 0, "None", "None", 0, new Location(2674, 3710, 0), false, false),
  44. HILL_GIANTS(238124, 0, "None", "None", 0, new Location(3117, 9856, 0), false, false),
  45. AL_KAHID(238125, 0, "None", "None", 0, new Location(3293, 3182, 0), false, false),
  46. COWS(238126, 0, "None", "None", 0, new Location(3257, 3263, 0), false, false),
  47. YAKS(238127, 0, "None", "None", 0, new Location(2321, 3804, 0), false, false),
  48. BRIMHAVEN_DUNG(238128, 1000, "None", "None", 0, new Location(2710, 9466, 0), false, false),
  49. TAVERLY_DUNG(238129, 1500, "None", "None", 0, new Location(2884, 9798, 0), false, false),
  50. SLAYER_TOWER(238130, 2000, "None", "None", 0, new Location(3428, 3538, 0), false, false),
  51. LAVA_DRAGONS(238131, 2750, "40+ Wild!", "None", 0, new Location(3202, 3860, 0), false, false),
  52. MITHRIL_DRAGONS(238132, 3000, "None", "None", 0, new Location(1747, 5324, 0), false, false),
  53.  
  54.  
  55. WILD_RESOURCE(242099, 3000, "54 Wild!", "None", 0, new Location(3184, 3947, 0), false, false),
  56. THIEVING(242100, 3000, "None", "None", 0, new Location(3047, 4976, 1), false, false),
  57. CRAFTING(242101, 2000, "None", "None", 0, new Location(2747, 3444, 0), false, false),
  58. AGILITY(242102, 5000, "None", "None", 0, new Location(2480, 3437, 0), false, true),
  59. MINING(242103, 3000, "None", "None", 0, new Location(3044, 9785, 0), false, false),
  60. SMITHING(242104, 2000, "None", "None", 0, new Location(3186, 3425, 0), false, false),
  61. FISHING(242105, 4000, "None", "None", 0, new Location(2840, 3437, 0), false, false),
  62. WOODCUTTING(242106, 3000, "None", "None", 0, new Location(2722, 3473, 0), false, false),
  63. FARMING(242107, 3000, "None", "None", 0, new Location(2806, 3463, 0), false, true),
  64.  
  65.  
  66. EDGEVILLE(246075, 0, "None", "None", 0, new Location(3087, 3515, 0), false, false),
  67. VARROCK(246076, 0, "None", "None", 0, new Location(3244, 3512, 0), false, false),
  68. EAST_DRAGONS(246077, 0, "None", "None", 0, new Location(3333, 3666, 0), false, false),
  69. CASTLE(246078, 0, "None", "None", 0, new Location(3002, 3626, 0), false, false),
  70. MAGE_BANK(246079, 0, "None", "None", 0, new Location(2540, 4717, 0), false, false),
  71.  
  72.  
  73. KING_BLACK_DRAGON(250051, 2500, "High combat", "40+ Wild", 276, new Location(2997, 3849, 0), false, false),
  74. SEA_TROLL_QUEEN(250052, 2500, "High combat", "Multi", 170, new Location(2336, 3692, 0), false, false),
  75. BARRELCHEST(250053, 4500, "High combat", "Instanced", 190, new Location(3806, 2844, 0), true, true),
  76. CORPOREAL_BEAST(250054, 6000, "High combat", "Team Based", 785, new Location(2948, 4385, 2), false, false),
  77. DAGGANNOTH_KINGS(250055, 6000, "High combat", "", 303, new Location(1909, 4367, 0), false, false),
  78. GOD_WARS(250056, 8000, "High combat", "Team Based", 0, new Location(2882, 5308, 2), false, false),
  79. ZULRAH(250057, 10000, "High combat", "Hard", 725, new Location(2268, 3070, 0), true, true),
  80. KRAKEN(250058, 7500, "High combat", "", 291, new Location(3696, 5807, 0), true, true),
  81. GIANT_MOLE(250059, 1500, "High combat", "", 230, new Location(1760, 5163, 0), false, false),
  82. CHAOS_ELEMENTAL(250060, 3500, "High combat", "50+ Wild", 305, new Location(3284, 3913, 0), false, false),
  83. CALLISTO(250061, 5750, "High combat", "40+ Wild", 470, new Location(3283, 3853, 0), false, false),
  84. SCORPIA(250062, 8750, "High combat", "50+ Wild", 225, new Location(3233, 3943, 0), false, false),
  85. VETION(250063, 8000, "High combat", "30+ Wild", 454, new Location(3210, 3780, 0), false, false),
  86. //VENENATIS(250064, 6250, "High combat", "40+ Wild", new Location(3283, 3853, 0), false, false),
  87. CHAOS_FANATIC(250065, 3750, "High combat", "40+ Wild", 202, new Location(2981, 3837, 0), false, false),
  88. CRAZY_ARCHAEOLOGIST(250066, 4500, "High combat", "20+ Wild", 204, new Location(2975, 3715, 0), false, false),
  89.  
  90.  
  91.  
  92. BARROWS(254027, 0, "None", "None", 0, new Location(3565, 3315, 0), false, false),
  93. WARRIORS_GUILD(254028, 0, "None", "None", 0, new Location(2869, 3544, 0), false, false),
  94. DUEL_ARENA(254029, 0, "None", "None", 0, new Location(3365, 3265, 0), false, false),
  95. PEST_CONTROL(254030, 0, "None", "None", 0, new Location(2662, 2655, 0), false, false),
  96. FIGHT_CAVES(254031, 0, "None", "None", 0, new Location(2439, 5171, 0), false, false),
  97. WEAPON_GAME(254032, 0, "None", "None", 0, WeaponGameConstants.LOBBY_COODINATES, false, false),
  98. CLAN_WARS(254033, 0, "None", "None", 0, ClanWarsConstants.CLAN_WARS_ARENA, false, true),
  99.  
  100.  
  101. MEMBERSHIP(240111, 0, "Members only", "None", 0, PlayerConstants.MEMEBER_AREA, false, true),
  102. STAFFZONE(240112, 0, "Staff only", "None", 0, PlayerConstants.STAFF_AREA, false, true);
  103.  
  104.  
  105.  
  106. private int button;
  107. private int cost;
  108. private String requirement;
  109. private String other;
  110. private int level;
  111. private Location position;
  112. private boolean instanced;
  113. private boolean specialCase;
  114.  
  115. private TeleportationData(int button, int cost, String requirement, String other, int level, Location position, boolean instanced, boolean specialCase) {
  116. this.button = button;
  117. this.cost = cost;
  118. this.requirement = requirement;
  119. this.other = other;
  120. this.level = level;
  121. this.position = position;
  122. this.instanced = instanced;
  123. this.specialCase = specialCase;
  124. }
  125.  
  126. public int getButton() {
  127. return button;
  128. }
  129.  
  130. public int getCost() {
  131. return cost;
  132. }
  133.  
  134. public String getRequirement() {
  135. return requirement;
  136. }
  137.  
  138. public String getOther() {
  139. return other;
  140. }
  141.  
  142. public int getLevel() {
  143. return level;
  144. }
  145.  
  146. public Location getPosition() {
  147. return position;
  148. }
  149.  
  150. public boolean isInstanced() {
  151. return instanced;
  152. }
  153.  
  154. public boolean getSpecialCase() {
  155. return specialCase;
  156. }
  157.  
  158. public static HashMap<Integer, TeleportationData> teleportation = new HashMap<Integer, TeleportationData>();
  159.  
  160. static {
  161. for (final TeleportationData teleportation : TeleportationData.values()) {
  162. TeleportationData.teleportation.put(teleportation.button, teleportation);
  163. }
  164. }
  165. }
  166.  
  167. /**
  168. * Handles player teleporting
  169. * @param player
  170.  
  171. public static void teleport(Player player) {
  172. int buttonId = player.getTeleportTo();
  173.  
  174. TeleportationData teleportation = TeleportationData.teleportation.get(buttonId);
  175.  
  176. if (teleportation == null) {
  177. return;
  178. }
  179.  
  180. if (teleportation.getSpecialCase()) {
  181. if (!specialCase(player, teleportation.getButton())) {
  182. return;
  183. }
  184. }
  185.  
  186. if (!player.isCreditUnlocked(CreditPurchase.FREE_TELEPORTS)) {
  187. if (teleportation.getCost() != 0) {
  188. return;
  189. }
  190. player.send(new SendMessage(teleportation.getCost() == 0 ? "You paid @red@nothing</col> and were teleported!" : "You have paid @red@" + Utility.format(teleportation.getCost()) + "</col> coins and were teleported!"));
  191. } else {
  192. player.send(new SendMessage("@red@You have been teleported for free."));
  193. }
  194.  
  195.  
  196. int height = teleportation.isInstanced() ? player.getIndex() << 2 : teleportation.getPosition().getZ();
  197.  
  198. player.getMagic().teleport(teleportation.getPosition().getX(), teleportation.getPosition().getY(), height, TeleportTypes.SPELL_BOOK);
  199.  
  200. player.setTeleportTo(0);
  201. }
  202.  
  203. /**
  204. * Handles special case teleporting
  205. * @param player
  206. * @param buttonId
  207.  
  208. public static boolean specialCase(Player player, int buttonId) {
  209. switch(buttonId) {
  210.  
  211. case 254033://Clan Wars
  212. player.send(new SendMessage("@dre@Walk west to enter the FFA arena."));
  213. return true;
  214.  
  215. case 250053://Barrelchest
  216. TaskQueue.queue(new Task(player, 4, false, Task.StackType.STACK, Task.BreakType.NEVER, TaskIdentifier.CURRENT_ACTION) {
  217. @Override
  218. public void execute() {
  219. new Mob(player, 6342, true, false, false, new Location(3815, 2844, player.getIndex() << 2));
  220. stop();
  221. }
  222. @Override
  223. public void onStop() {
  224. }
  225. });
  226. return true;
  227.  
  228. case 242107://Farming
  229. player.start(new OptionDialogue("Catherby", p -> {
  230. p.teleport(new Location(2805, 3464, 0));
  231. p.send(new SendMessage("<col=482CB8>You have teleported to the Catherby farming area."));
  232. }, "Ardougne", p -> {
  233. p.teleport(new Location(2662, 3375, 0));
  234. p.send(new SendMessage("<col=482CB8>You have teleported to the Ardougne farming area."));
  235. }, "Falador", p -> {
  236. p.teleport(new Location(3056, 3310, 0));
  237. p.send(new SendMessage("<col=482CB8>You have teleported to the Falador farming area."));
  238. }, "Phasmatys", p -> {
  239. p.teleport(new Location(3600, 3524, 0));
  240. p.send(new SendMessage("<col=482CB8>You have teleported to the Phasmatys farming area."));
  241. }));
  242. return false;
  243.  
  244. case 242102://Agility
  245. player.start(new OptionDialogue("Gnome agility course", p -> {
  246. p.teleport(new Location(2480, 3437, 0));
  247. p.send(new SendMessage("<col=482CB8>You have teleported to the Gnome agility course."));
  248. }, "Barbarian agility course", p -> {
  249. p.teleport(new Location(2546, 3551, 0));
  250. p.send(new SendMessage("<col=482CB8>You have teleported to the Barbarian agility course."));
  251. }, "Wilderness agility course (50+ wild)", p -> {
  252. p.teleport(new Location(2998, 3915, 0));
  253. p.send(new SendMessage("<col=482CB8>You have teleported to the Wilderness agility course."));
  254. }, "Rooftop courses", p -> {
  255. player.start(new OptionDialogue("Seer's course", p2 -> {
  256. p.teleport(new Location(2729, 3488, 0));
  257. p.send(new SendMessage("<col=482CB8>You have teleported to the Seer's Village rooftop agility course."));
  258. }, "Ardougne course", p2 -> {
  259. p.teleport(new Location(2674, 3297, 0));
  260. p.send(new SendMessage("<col=482CB8>You have teleported to the Ardougne rooftop agility course."));
  261. }));
  262. }));
  263. return false;
  264.  
  265. case 250058://Kraken
  266. TaskQueue.queue(new Task(5) {
  267. @Override
  268. public void execute() {
  269. int[][] DATA = { { 493, 3691, 5810 }, { 493, 3691, 5814 }, { 493, 3700, 5810 }, { 493, 3700, 5814 }, { 496, 3694, 5811 } };
  270. for (int i = 0; i < DATA.length; i++) {
  271. Mob mob = new Mob(player, DATA[i][0], false, false, false, new Location(DATA[i][1], DATA[i][2], player.getZ()));
  272. mob.setCanAttack(false);
  273. player.face(mob);
  274. }
  275. stop();
  276. }
  277.  
  278. @Override
  279. public void onStop() {
  280. player.whirlpoolsHit = 0;
  281. player.send(new SendMessage("Welcome to Kraken's cave."));
  282. }
  283. });
  284. return true;
  285.  
  286. case 250057://Zulrah
  287. TaskQueue.queue(new Task(5) {
  288. @Override
  289. public void execute() {
  290. Zulrah mob = new Zulrah(player, new Location(2266, 3073, player.getIndex() << 2));
  291. mob.face(player);
  292. mob.getUpdateFlags().sendAnimation(new Animation(5071));
  293. player.face(mob);
  294. player.send(new SendMessage("Welcome to Zulrah's shrine."));
  295. DialogueManager.sendStatement(player, "Welcome to Zulrah's shrine.");
  296. stop();
  297. }
  298.  
  299. @Override
  300. public void onStop() {
  301. }
  302. });
  303. return true;
  304.  
  305. case 240111://Membership
  306. if (PlayerConstants.isPlayer(player)) {
  307. DialogueManager.sendNpcChat(player, 5523, Emotion.DEFAULT, "You need to be a <img=4>@red@member </col>to do this!");
  308. return false;
  309. }
  310. return true;
  311.  
  312. case 240112://Staffzone
  313. if (!PlayerConstants.isStaff(player)) {
  314. DialogueManager.sendStatement(player, "You are not privileged enough to do this!");
  315. return false;
  316. }
  317. return true;
  318. }
  319. return false;
  320.  
  321. }
  322.  
  323. /**
  324. * Handles selecting teleport
  325. * @param player
  326. * @param buttonId
  327. * @return
  328.  
  329. public static boolean selection(Player player, int buttonId) {
  330. TeleportationData teleportation = TeleportationData.teleportation.get(buttonId);
  331.  
  332. if (teleportation == null) {
  333. return false;
  334. }
  335.  
  336. player.setTeleportTo(buttonId);
  337. player.send(new SendString("Level: @red@0", 64039));
  338. switch (player.getInterfaceManager().getMain()) {
  339. case 61000:// Training
  340. player.send(new SendString("Selected: @red@" + Utility.formatPlayerName(teleportation.name().replaceAll("_", " ").toLowerCase()), 61031));
  341. player.send(new SendString("Cost: @red@" + format(teleportation.getCost()), 61032));
  342. player.send(new SendString("Requirement: @red@" + teleportation.getRequirement(), 61033));
  343. player.send(new SendString("Other: @red@" + teleportation.getOther(), 61034));
  344. break;
  345. case 62000:// Skilling
  346. player.send(new SendString("Selected: @red@" + Utility.formatPlayerName(teleportation.name().replaceAll("_", " ").toLowerCase()), 62031));
  347. player.send(new SendString("Cost: @red@" + format(teleportation.getCost()), 62032));
  348. player.send(new SendString("Requirement: @red@" + teleportation.getRequirement(), 62033));
  349. player.send(new SendString("Other: @red@" + teleportation.getOther(), 62034));
  350. break;
  351. case 63000:// Player Vs Player
  352. player.send(new SendString("Selected: @red@" + Utility.formatPlayerName(teleportation.name().replaceAll("_", " ").toLowerCase()), 63031));
  353. player.send(new SendString("Cost: @red@" + format(teleportation.getCost()), 63032));
  354. player.send(new SendString("Requirement: @red@" + teleportation.getRequirement(), 63033));
  355. player.send(new SendString("Other: @red@" + teleportation.getOther(), 63034));
  356. break;
  357. case 64000:// Player Vs Monster
  358. player.send(new SendString("Selected: @red@" + Utility.formatPlayerName(teleportation.name().replaceAll("_", " ").toLowerCase()), 64031));
  359. player.send(new SendString("Cost: @red@" + format(teleportation.getCost()), 64032));
  360. player.send(new SendString("Requirement: @red@" + teleportation.getRequirement(), 64033));
  361. player.send(new SendString("Other: @red@" + teleportation.getOther(), 64034));
  362. player.send(new SendString("Level: @red@" + teleportation.getLevel(), 64039));
  363. break;
  364. case 65000:// Minigame
  365. player.send(new SendString("Selected: @red@" + Utility.formatPlayerName(teleportation.name().replaceAll("_", " ").toLowerCase()), 65031));
  366. player.send(new SendString("Cost: @red@" + format(teleportation.getCost()), 65032));
  367. player.send(new SendString("Requirement: @red@" + teleportation.getRequirement(), 65033));
  368. player.send(new SendString("Other: @red@" + teleportation.getOther(), 65034));
  369. break;
  370. case 61500:// Other
  371. player.send(new SendString("Selected: @red@" + Utility.formatPlayerName(teleportation.name().replaceAll("_", " ").toLowerCase()), 61531));
  372. player.send(new SendString("Cost: @red@" + format(teleportation.getCost()), 61532));
  373. player.send(new SendString("Requirement: @red@" + teleportation.getRequirement(), 61533));
  374. player.send(new SendString("Other: @red@" + teleportation.getOther(), 61534));
  375. break;
  376. }
  377. return true;
  378. }
  379.  
  380. public static String format(long num) {
  381. if (num == 0) {
  382. return "Free";
  383. }
  384. return NumberFormat.getInstance().format(num);
  385. }
  386. */
  387. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement