Advertisement
Guest User

Untitled

a guest
Aug 4th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 70.98 KB | None | 0 0
  1. package org.perception.model.players.packets.commands;
  2.  
  3. import static org.perception.util.PlayerPredicates.*;
  4.  
  5. import java.io.BufferedWriter;
  6. import java.io.File;
  7. import java.io.FileWriter;
  8. import java.io.IOException;
  9. import java.util.List;
  10. import java.util.Objects;
  11. import java.util.Optional;
  12. import java.util.function.Predicate;
  13.  
  14. import org.apache.commons.io.FileUtils;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.apache.commons.lang3.text.WordUtils;
  17. import org.perception.Config;
  18. import org.perception.Connection;
  19. import org.perception.Server;
  20. import org.perception.model.content.SkillConstants;
  21. import org.perception.model.content.Kraken.Kraken;
  22. import org.perception.model.content.help.HelpDatabase;
  23. import org.perception.model.content.kill_streaks.Killstreak;
  24. import org.perception.model.content.teleport.Position;
  25. import org.perception.model.content.teleport.TeleportExecutor;
  26. import org.perception.model.content.zulrah.Zulrah;
  27. import org.perception.model.interaction.MultiplayerSession;
  28. import org.perception.model.interaction.MultiplayerSessionFinalizeType;
  29. import org.perception.model.interaction.MultiplayerSessionStage;
  30. import org.perception.model.interaction.MultiplayerSessionType;
  31. import org.perception.model.interaction.duel.DuelSession;
  32. import org.perception.model.items.ItemDefinition;
  33. import org.perception.model.npcs.NPCCacheDefinition;
  34. import org.perception.model.npcs.NPCHandler;
  35. import org.perception.model.npcs.NpcDefinition;
  36. import org.perception.model.npcs.Bosses.Cerberus;
  37. import org.perception.model.players.Boundary;
  38. import org.perception.model.players.Player;
  39. import org.perception.model.players.PlayerHandler;
  40. import org.perception.model.players.Rights;
  41. import org.perception.model.players.combat.Hitmark;
  42. import org.perception.model.players.skills.Skill;
  43. import org.perception.util.Misc;
  44. import org.perception.util.json.ItemDefinitionLoader;
  45.  
  46. import com.google.gson.Gson;
  47. import com.google.gson.reflect.TypeToken;
  48. import com.rspserver.mvh.AuthService;
  49.  
  50. /**
  51. * New command system. Uses predicates / enum to store commands. Much cleaner.
  52. *
  53. * The enum name is the string used to execute the command. After is the predicate that handles the requirement to
  54. * perform the command. Finally, after that is any additional strings that can be used to execute the command.
  55. * @author Advocatus
  56. *
  57. */
  58. public enum Commands {
  59.  
  60. /*
  61. * All
  62. */
  63. AUTH {
  64. @Override
  65. public void execute(Player c, String input) {
  66. String auth = input.replace("Auth ", "");
  67. if(input.length() < 5) {
  68. c.sendMessage("You must enter an auth code to process your vote!");
  69. return;
  70. }
  71. boolean success = AuthService.provider().redeemNow(auth);
  72.  
  73. if (success) {
  74. c.votePoints += 5;
  75. c.getItems().addItemUnderAnyCircumstance(2996, 10);
  76. PlayerHandler.executeGlobalMessage("<img=10></img><col=255>" + Misc.capitalize(c.playerName)
  77. + " </col>has just voted and received <col=CC0000>10 PK Points & 5 Vote Points</col>.");
  78. c.getPA().loadQuests();
  79. }
  80. else {
  81. c.sendMessage("Invalid auth supplied, please try again later.");
  82. }
  83. //}
  84. }
  85. },
  86. CHANGEPASS("changepassword") {
  87. @Override
  88. public void execute(Player c, String input) {
  89. if(input.length() < 3) {
  90. c.sendMessage("Your password must contain atleast 3 characters.");
  91. return;
  92. }
  93. if (input.length() > 20) {
  94. c.sendMessage("Passwords cannot contain more than 20 characters.");
  95. c.sendMessage("The password you tried had " + input.length() + " characters.");
  96. return;
  97. }
  98. if (input.contains("character-rights") || input.contains("[CHARACTER]") || input.contains(".") || input.contains("_")) {
  99. c.sendMessage("Your password contains illegal characters.");
  100. return;
  101. }
  102. //c.playerPass = input;
  103. c.playerPass = Misc.getFilteredInput(input).toLowerCase();
  104. c.sendMessage("Your password is now: @red@" + c.playerPass);
  105. }
  106. },
  107. CHARSOF {
  108. @Override
  109. public void execute(Player c, String input) {
  110. if (Server.getMultiplayerSessionListener().inAnySession(c)) {
  111. return;
  112. }
  113. if (c.inWild() || c.inCamWild()) {
  114. return;
  115. }
  116. c.getPA().showInterface(3559);
  117. }
  118. },
  119. COMMANDS {
  120. @Override
  121. public void execute(Player c, String input) {
  122. if (Server.getMultiplayerSessionListener().inAnySession(c)) {
  123. return;
  124. }
  125. for (int i = 8144; i < 8195; i++) {
  126. c.getPA().sendFrame126("", i);
  127. }
  128. c.getPA().sendFrame126("@dre@DomePS Commands", 8144);
  129. c.getPA().sendFrame126("", 8145);
  130. c.getPA().sendFrame126("@blu@::players@bla@ - Shows players online", 8147);
  131. c.getPA().sendFrame126("@blu@::check@bla@ - Claim your voting reward", 8148);
  132. c.getPA().sendFrame126("@blu@::getid itemname@bla@ - Auth the ID of an item", 8149);
  133. c.getPA().sendFrame126("@blu@::empty@bla@ - Destroy all items in your inventory", 8150);
  134. c.getPA().sendFrame126("@blu@::vote@bla@ - Takes you to the voting page", 8151);
  135. c.getPA().sendFrame126("@blu@::forums@bla@ - Takes you to the forums", 8152);
  136. c.getPA().sendFrame126("@blu@::store@bla@ - Takes you to the store/donation page", 8153);
  137. c.getPA().sendFrame126("@blu@::changepassword newpass@bla@ - Changes your password", 8154);
  138. c.getPA().sendFrame126("@blu@::lock@bla@ - Locks/Unlocks your XP", 8155);
  139. c.getPA().sendFrame126("@blu@::char@bla@ - Teleports you to the Make-over Mage", 8156);
  140. c.getPA().sendFrame126("@blu@::claimpayment@bla@ - Claims your donation", 8157);
  141. c.getPA().sendFrame126("@blu@::rules@bla@ - Brings you to the rules thread", 8158);
  142. c.getPA().sendFrame126("@blu@::highscores@bla@ - Brings you to the highscores", 8159);
  143. c.getPA().sendFrame126("@blu@::mb/::wests/::gdz/::easts@bla@ - Teles you to these hotspots", 8160);
  144. c.getPA().sendFrame126("@blu@::counter@bla@ - Toggles your 474 counter on/off", 8161);
  145. c.getPA().sendFrame126("@blu@::orbs@bla@ - Toggles your 474 orbs on/off", 8162);
  146. //c.getPA().sendFrame126("@blu@::hotkeys@bla@ - Toggles your hotkeys", 8163);
  147. //c.getPA().sendFrame126("@blu@::help@bla@ - Brings up the help request interface", 8164);
  148. c.getPA().sendFrame126("", 8170);
  149. c.getPA().sendFrame126("@dre@Donator's Only", 8171);
  150. c.getPA().sendFrame126("@dre@::yell message@bla@ - Sends a global message", 8172);
  151. c.getPA().sendFrame126("@dre@::dz@bla@ - Teleports you to the donator's zone", 8173);
  152. c.getPA().sendFrame126("@dre@::changetitle newtitle@bla@ - Changes your title for 25M", 8174);
  153. c.getPA().sendFrame126("@dre@::donatortitle@bla@ - Gives you back your donator title for free", 8175);
  154. c.getPA().sendFrame126("@dre@::killtitle@bla@ - Gives you back your kill title for free", 8176);
  155. c.getPA().showInterface(8134);
  156. }
  157. },
  158. DONATE {
  159. @Override
  160. public void execute(Player c, String input) {
  161. c.getPA().sendFrame126("www.rsps-pay.com/store.php?id=4576&tab=4082", 12000);
  162. }
  163. },
  164. DOWNLOAD {
  165. @Override
  166. public void execute(Player c, String input) {
  167. c.getPA().sendFrame126("www.domeps.com", 12000);
  168. }
  169. },
  170. EASTS {
  171. @Override
  172. public void execute(Player c, String input) {
  173. if (Server.getMultiplayerSessionListener().inAnySession(c)) {
  174. return;
  175. }
  176. if (c.inWild() || c.inCamWild()) {
  177. return;
  178. }
  179. TeleportExecutor.teleport(c, new Position(3353, 3684, 0));
  180. }
  181. },
  182. FORUMS {
  183. @Override
  184. public void execute(Player c, String input) {
  185. c.getPA().sendFrame126("www.domeps.com/forums/", 12000);
  186. }
  187. },
  188. GDZ {
  189. @Override
  190. public void execute(Player c, String input) {
  191. if (Server.getMultiplayerSessionListener().inAnySession(c)) {
  192. return;
  193. }
  194. if (c.inWild() || c.inCamWild()) {
  195. return;
  196. }
  197. TeleportExecutor.teleport(c, new Position(3280, 3878, 0));
  198. }
  199. },
  200. HELP {
  201. @Override
  202. public void execute(Player c, String input) {
  203. c.getPA().closeAllWindows();
  204. c.getPA().showInterface(59525);
  205. }
  206. },
  207. HOSTS {
  208. @Override
  209. public void execute(Player c, String input) {
  210. StringBuilder sb = new StringBuilder();
  211. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  212. if (PlayerHandler.players[i] != null) {
  213. Player c2 = PlayerHandler.players[i];
  214. if (c2.getItems().playerHasItem(766)) {
  215. sb.append(c2.playerName + ", ");
  216. }
  217. }
  218. }
  219. if (sb.length() > 0) {
  220. String result = "@blu@Available hosts@bla@: " + sb.substring(0, sb.length() - 2);
  221. String[] wrappedLines = WordUtils.wrap(result, 80).split(System.getProperty("line.separator"));
  222. for (String line : wrappedLines) {
  223. c.sendMessage(line);
  224. }
  225. } else {
  226. c.sendMessage("@blu@No hosts available!");
  227. }
  228. }
  229. },
  230. LOCK {
  231. @Override
  232. public void execute(Player c, String input) {
  233. if (c.expLock == false) {
  234. c.expLock = true;
  235. c.sendMessage("Your XP is now: @red@locked@bla@.");
  236. } else {
  237. c.expLock = false;
  238. c.sendMessage("Your XP is now: @gre@unlocked@bla@.");
  239. }
  240. }
  241. },
  242. MB {
  243. @Override
  244. public void execute(Player c, String input) {
  245. if (Server.getMultiplayerSessionListener().inAnySession(c)) {
  246. return;
  247. }
  248. if (c.inWild() || c.inCamWild()) {
  249. return;
  250. }
  251. TeleportExecutor.teleport(c, new Position(2539, 4716, 0));
  252. }
  253. },
  254. PLAYERS {
  255. @Override
  256. public void execute(Player c, String input) {
  257. if(c.getRights().isOwner()) {
  258. //TODO lol fuse this / fix this up.
  259. c.getPA().showInterface(8134);
  260. c.getPA().sendFrame126("@blu@" + Config.SERVER_NAME + " Players:", 8144);
  261. c.getPA().sendFrame126("@red@Online players:" + PlayerHandler.getPlayerCount() + "", 8145);
  262. int line = 8147;
  263. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  264. if (PlayerHandler.players[i] != null) {
  265. Player d = c.getClient(PlayerHandler.players[i].playerName);
  266. if (d.playerName != null) {
  267. c.getPA().sendFrame126(d.playerName, line);
  268. line++;
  269. } else if (d.playerName == null) {
  270. c.getPA().sendFrame126("@gre@", line);
  271. }
  272. }
  273. }
  274. c.flushOutStream();
  275. return;
  276. }
  277. c.sendMessage("There are currently <col=255>" + PlayerHandler.getPlayerCount() + "</col> players online on <col=255>DomePS.");
  278. }
  279. },
  280. RULES {
  281. @Override
  282. public void execute(Player c, String input) {
  283. c.getPA().sendFrame126("", 12000);
  284. }
  285. },
  286. SKULL {
  287. @Override
  288. public void execute(Player c, String input) {
  289. c.sendMessage("<col=FF0000>Talk to the Emblem Trader in edgeville to receive a skull, or extended skull.</col>");
  290. }
  291. },
  292. VOTE {
  293. @Override
  294. public void execute(Player c, String input) {
  295. c.getPA().sendFrame126("www.motivoters.com/vote/155/", 12000);
  296. }
  297. },
  298. WESTS {
  299. @Override
  300. public void execute(Player c, String input) {
  301. if (Server.getMultiplayerSessionListener().inAnySession(c)) {
  302. return;
  303. }
  304. if (c.inWild() || c.inCamWild()) {
  305. return;
  306. }
  307. TeleportExecutor.teleport(c, new Position(2979, 3597, 0));
  308. }
  309. },
  310. YELL {
  311.  
  312. private final String[] ILLEGAL_ARGUMENTS = { ":tradereq:", "<img", "@cr", "<tran", "#url#", ":duelreq:",
  313. ":chalreq:" };
  314.  
  315. @Override
  316. public void execute(Player c, String input) {
  317. if(c.getRights().isPlayer()) {
  318. c.sendMessage("You need to donate to use this command. ::donate");
  319. return;
  320. }
  321.  
  322. if (c.getRights().isStaff()) {
  323. //TODO check below and merge this shit.
  324. String rank = "";
  325. String message = input;
  326. if (Connection.isMuted(c)) {
  327. c.sendMessage("You are muted and can therefore not yell.");
  328. return;
  329. }
  330. if (System.currentTimeMillis() < c.muteEnd) {
  331. c.sendMessage("You are muted and can therefore not yell.");
  332. return;
  333. }
  334. String playerTitle = c.getTitles().getCurrentTitle();
  335. if (c.getRights().isContributor()) {
  336.  
  337. rank = "[@cr4@@red@ Donator@bla@] " + c.playerName + ": ";
  338. }
  339. if (c.getRights().isSponsor()) {
  340.  
  341. rank = "[@cr5@@blu@ Super Donator@bla@] " + c.playerName + ": ";
  342. }
  343. if (c.getRights().isSupporter()) { //done
  344.  
  345. rank = "[@cr6@@gre@ Extreme Donator@bla@] " + c.playerName + ": ";
  346. }
  347. if (c.getRights().isVIP()) {
  348.  
  349. rank = "[@cr7@<col=FF00CD> Legendary Donator</col>@bla@] " + c.playerName + ": ";
  350. }
  351. if (c.getRights().isSuperVIP()) { //done
  352.  
  353. rank = "[@cr8@@red@ YouTuber@bla@] @bla@" + c.playerName + ": ";
  354. }
  355. if (c.getRights().isRespectedMember()) {
  356.  
  357. rank = "[@cr9@@or2@ Uber Donator@bla@] " + c.playerName + ": ";
  358. }
  359. if (c.getRights().isHelper()) {
  360.  
  361. rank = "[@cr10@@blu@ Support@bla@] " + c.playerName + ": ";
  362. }
  363. /* Staff */
  364. if (c.getRights().isModerator()) {
  365.  
  366. rank = "[@cr1@<col=148200>Moderator</col>@bla@][@blu@" + c.playerName + "@bla@]:@dre@";
  367. }
  368. if (c.getRights().isAdministrator()) {
  369.  
  370. rank = "[@cr2@@yel@Administrator@bla@][@blu@" + Misc.ucFirst(c.playerName) + "@bla@]:@dre@";
  371. }
  372. //if (c.playerName.equalsIgnoreCase("Notepad")) {
  373. // //rank = "<col=5E14A7>Owner</col>" + Misc.ucFirst(c.playerName) + ":<col=0000FF>";
  374. // rank = "[<col=5E14A7>@cr2@Owner]</col>[" + Misc.ucFirst(c.playerName) + "]:<col=0000FF>";
  375. //}
  376. //if (c.playerName.equalsIgnoreCase("Brad")) {
  377. // rank = "[<col=5E14A7>@cr2@Community Manager]</col>[" + Misc.ucFirst(c.playerName) + "]:<col=0000FF>";
  378. //}
  379. message = message.toLowerCase();
  380. for (String argument : ILLEGAL_ARGUMENTS) {
  381. if (message.contains(argument)) {
  382. c.sendMessage("Your message contains an illegal set of characters, you cannot yell this.");
  383. return;
  384. }
  385. }
  386. message = Misc.ucFirst(message);
  387. PlayerHandler.executeGlobalMessage(rank + message);
  388. return;
  389. }
  390. String rank = "";
  391. String message = input;
  392. if (Connection.isMuted(c)) {
  393. c.sendMessage("You are muted and can therefore not yell.");
  394. return;
  395. }
  396. if (System.currentTimeMillis() < c.muteEnd) {
  397. c.sendMessage("You are muted and can therefore not yell.");
  398. return;
  399. }
  400. if (!c.lastYell.elapsed(5000) && c.getRights().isContributor()) {
  401. c.sendMessage("You are a @red@Contributor@bla@ and must wait 5 seconds between each yell.");
  402. return;
  403. }
  404. if (!c.lastYell.elapsed(5000) && c.getRights().isSponsor()) {
  405. c.sendMessage("You are a @blu@Sponsor@bla@ and must wait 5 seconds between each yell.");
  406. return;
  407. }
  408. if (!c.lastYell.elapsed(5000) && c.getRights().isSupporter()) {
  409. c.sendMessage("You are a Supporter and must wait 5 seconds between each yell.");
  410. return;
  411. }
  412. if (!c.lastYell.elapsed(5000) && c.getRights().isVIP()) {
  413. c.sendMessage("You are a <col=FF00CD>VIP</col>@bla@ and must wait 5 seconds between each yell.");
  414. return;
  415. }
  416. if (!c.lastYell.elapsed(5000) && c.getRights().isSuperVIP()) {
  417. c.sendMessage("You are a @yel@Super VIP@bla@ and must wait 5 seconds between each yell.");
  418. return;
  419. }
  420. String playerTitle = c.getTitles().getCurrentTitle();
  421. if (c.getRights().isContributor()) {
  422.  
  423. rank = "[@cr4@@red@ Donator@bla@] " + c.playerName + ": ";
  424. }
  425. if (c.getRights().isSponsor()) {
  426.  
  427. rank = "[@cr5@@blu@ Super Donator@bla@] " + c.playerName + ": ";
  428. }
  429. if (c.getRights().isSupporter()) { //done
  430.  
  431. rank = "[@cr6@@gre@ Extreme Donator@bla@] " + c.playerName + ": ";
  432. }
  433. if (c.getRights().isVIP()) {
  434.  
  435. rank = "[@cr7@<col=FF00CD> Legendary Donator</col>@bla@] " + c.playerName + ": ";
  436. }
  437. if (c.getRights().isSuperVIP()) { //done
  438.  
  439. rank = "[@cr8@@red@ YouTuber@bla@] @bla@" + c.playerName + ": ";
  440. }
  441. if (c.getRights().isRespectedMember()) {
  442.  
  443. rank = "[@cr9@@or2@ Uber Donator@bla@] " + c.playerName + ": ";
  444. }
  445. if (c.getRights().isHelper()) {
  446.  
  447. rank = "[@cr10@@blu@ Support@bla@] " + c.playerName + ": ";
  448. }
  449. /* Staff */
  450. if (c.getRights().isModerator()) {
  451.  
  452. rank = "[@cr1@<col=148200>Moderator</col>@bla@][@blu@" + c.playerName + "@bla@]:@dre@";
  453. }
  454. if (c.getRights().isAdministrator()) {
  455.  
  456. rank = "[@cr2@@yel@Administrator@bla@][@blu@" + Misc.ucFirst(c.playerName) + "@bla@]:@dre@";
  457. }
  458. //if (c.getRights().isOwner() && !c.playerName.equalsIgnoreCase("Notepad")) {
  459. // rank = "[<col=A67711>Owner</col>][" + Misc.ucFirst(c.playerName) + "]:<col=0000FF>";
  460. //}
  461. //if (c.playerName.equalsIgnoreCase("Mod trent")) {
  462. // rank = "[<col=5E14A7>Server BITCH</col>][" + Misc.ucFirst(c.playerName) + "]:<col=0000FF>";
  463. //}
  464. message = message.toLowerCase();
  465. for (String argument : ILLEGAL_ARGUMENTS) {
  466. if (message.contains(argument)) {
  467. c.sendMessage("Your message contains an illegal set of characters, you cannot yell this.");
  468. return;
  469. }
  470. }
  471. c.lastYell.reset();
  472. message = Misc.ucFirst(message);
  473. PlayerHandler.executeGlobalMessage(rank + message);
  474. }
  475. },
  476.  
  477. /*
  478. * Donator
  479. */
  480. DONATORTITLE(donator()) {
  481. @Override
  482. public void execute(Player c, String input) {
  483. c.sendMessage("You will now get your donator title instead. Relog for changes to take effect.");
  484. c.keepTitle = false;
  485. c.killTitle = false;
  486. }
  487. },
  488. DONATORZONE(donator(), "dz") {
  489. @Override
  490. public void execute(Player c, String input) {
  491. if (c.inTrade || c.inDuel || c.inWild()) {
  492. return;
  493. }
  494. TeleportExecutor.teleport(c, new Position(3366, 9640, 0));
  495. }
  496. },
  497. KILLTITLE(donator()) {
  498. @Override
  499. public void execute(Player c, String input) {
  500. c.sendMessage("You will now be using your kill title instead. Relog for changes to take effect.");
  501. c.keepTitle = false;
  502. c.killTitle = true;
  503. }
  504. },
  505.  
  506. /*
  507. * HELPER
  508. */
  509.  
  510. HELPDB(helper()) {
  511. @Override
  512. public void execute(Player c, String input) {
  513. HelpDatabase.getDatabase().openDatabase(c);
  514. }
  515. },
  516.  
  517. /*
  518. * Moderator
  519. */
  520. CHECKINVENTORY(mod()) {
  521. @Override
  522. public void execute(Player c, String input) {
  523. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  524. if (optionalPlayer.isPresent()) {
  525. Player c2 = optionalPlayer.get();
  526. c.getPA().otherInv(c, c2);
  527. c.getDH().sendDialogues(206, 0);
  528. } else {
  529. c.sendMessage(input + " is not online. You can only check the inventory of online players.");
  530. }
  531. }
  532. },
  533. INFO(mod()) {
  534. @Override
  535. public void execute(Player c, String input) {
  536. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  537. if (optionalPlayer.isPresent()) {
  538. Player c2 = optionalPlayer.get();
  539. c.sendMessage("IP of " + c2.playerName + " : " + c2.connectedFrom);
  540. c.sendMessage("Mac Address of " + c2.playerName + " : " + c2.getMacAddress());
  541. } else {
  542. c.sendMessage(input + " is not line. You can request the info of online players.");
  543. }
  544. }
  545. },
  546. KS(mod()) {
  547. @Override
  548. public void execute(Player c, String input) {
  549. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  550. if (optionalPlayer.isPresent()) {
  551. Player c2 = optionalPlayer.get();
  552. c.sendMessage("Hunter killstreak of " + c2.playerName + " : " + c2.getKillstreak().getAmount(Killstreak.Type.HUNTER));
  553. c.sendMessage("Rogue killstreak of " + c2.playerName + " : " + c2.getKillstreak().getAmount(Killstreak.Type.ROGUE));
  554. }
  555. }
  556. },
  557. LOCKACC(mod()) {
  558. @Override
  559. public void execute(Player c, String input) {
  560. try {
  561. String[] args = input.split(" ");
  562. if (args.length != 1) {
  563. c.sendMessage("Invalid arguments specified!");
  564. throw new IllegalArgumentException();
  565. }
  566. String name = args[0];
  567. Connection.lockAccount(name);
  568. Connection.addNameToLocks(name);
  569.  
  570. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(name);
  571. if (optionalPlayer.isPresent()) {
  572. Player c2 = optionalPlayer.get();
  573. if (c2.getRights().isBetween(2, 3)) {
  574. c.sendMessage("You cannot lock this player's account!");
  575. return;
  576. }
  577. if (Server.getMultiplayerSessionListener().inAnySession(c2)) {
  578. MultiplayerSession session = Server.getMultiplayerSessionListener().getMultiplayerSession(c2);
  579. session.finish(MultiplayerSessionFinalizeType.WITHDRAW_ITEMS);
  580. }
  581. c2.disconnected = true;
  582. c.sendMessage(Misc.formatPlayerName(name) + "'s account has been locked.");
  583. }
  584. } catch (Exception e) {
  585. e.printStackTrace();
  586. c.sendMessage("Correct usage: ::lock playername");
  587. }
  588. }
  589. },
  590. MARKETUNMUTE(mod()) {
  591. @Override
  592. public void execute(Player c, String input) {
  593. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  594. if (optionalPlayer.isPresent()) {
  595. Player c2 = optionalPlayer.get();
  596. c2.marketMuteEnd = 0;
  597. c.sendMessage(c2.playerName + " has been unmuted on the market channel.");
  598. c2.sendMessage("@red@You have been unmuted by " + c.playerName + " on the market channel.");
  599. //new PunishmentHandler().punishOnlinePlayer(c2, c, "Market Unmute", "");
  600. }
  601. }
  602. },
  603. MOVE(mod()) {
  604. @Override
  605. public void execute(Player c, String input) {
  606. try {
  607. String[] args = input.split(" ");
  608. int positionOffset = Integer.parseInt(args[1]);
  609. int x = c.absX;
  610. int y = c.absY;
  611. int height = c.heightLevel;
  612. switch (args[0].toLowerCase()) {
  613. case "up":
  614. height += positionOffset;
  615. break;
  616. case "down":
  617. height -= positionOffset;
  618. break;
  619. case "north":
  620. y += positionOffset;
  621. break;
  622. case "east":
  623. x += positionOffset;
  624. break;
  625. case "south":
  626. y -= positionOffset;
  627. break;
  628. case "west":
  629. x -= positionOffset;
  630. break;
  631. }
  632. c.getPA().movePlayer(x, y, height);
  633. } catch (Exception e) {
  634. c.sendMessage("Error. Correct syntax: ::move up/down/north/east/south/west amount");
  635. }
  636. }
  637. },
  638. RANDOM(mod()) {
  639. @Override
  640. public void execute(Player c, String input) {
  641. String[] args = input.split("-");
  642. boolean ignore = false;
  643. if (args.length > 2) {
  644. c.sendMessage("Incorrect syntax; '::random-name'");
  645. return;
  646. }
  647. if (args.length == 2) {
  648. if (args[1].equals("ignore")) {
  649. if (!c.getRights().inherits(Rights.ADMINISTRATOR)) {
  650. c.sendMessage("You cannot force this, you do not inherit Administrative rights.");
  651. return;
  652. }
  653. ignore = true;
  654. } else {
  655. c.sendMessage("The second argument should contain 'ignore', please try again.");
  656. return;
  657. }
  658. }
  659. Optional<Player> online = PlayerHandler.getOptionalPlayer(args[0]);
  660. if (!online.isPresent()) {
  661. c.sendMessage("This player is not online.");
  662. return;
  663. }
  664. Player target = online.get();
  665. if (target.getInterfaceEvent().isActive()) {
  666. c.sendMessage("The event is already active for this player. It should resolve shortly.");
  667. return;
  668. }
  669. if (!target.getInterfaceEvent().isExecutable() && !ignore) {
  670. c.sendMessage("The event is deemed as 'un-executable'. This could be due to a number of reasons.");
  671. c.sendMessage("If you believe the event should ignore this, type ::random-name-ignore to do so.");
  672. c.sendMessage("Only administrative staff have this access.");
  673. return;
  674. }
  675. c.sendMessage("You have executed the random event for this player.");
  676. target.getInterfaceEvent().execute();
  677. }
  678. },
  679. STAFFTITLE(mod()) {
  680. @Override
  681. public void execute(Player c, String input) {
  682. c.sendMessage("You will now get your staff title instead. Relog for changes to take effect.");
  683. c.keepTitle = false;
  684. c.killTitle = false;
  685. }
  686. },
  687. STAFFZONE(mod()) {
  688. @Override
  689. public void execute(Player c, String input) {
  690. TeleportExecutor.teleport(c, new Position(2912, 5475, 0));
  691. }
  692. },
  693. TELETO(mod(), "xteleto") {
  694. @Override
  695. public void execute(Player c, String input) {
  696. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  697. if (optionalPlayer.isPresent()) {
  698. Player c2 = optionalPlayer.get();
  699. c.getPA().movePlayer(c2.getX(), c2.getY(), c2.heightLevel);
  700. } else {
  701. c.sendMessage(input + " is not line. You can only teleport to online players.");
  702. }
  703. }
  704. },
  705. TELETOME(mod()) {
  706. @Override
  707. public void execute(Player c, String input) {
  708. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  709. if (optionalPlayer.isPresent()) {
  710. Player c2 = optionalPlayer.get();
  711. c2.teleportToX = c.absX;
  712. c2.teleportToY = c.absY;
  713. c2.heightLevel = c.heightLevel;
  714. c.sendMessage(Misc.formatPlayerName(c2.playerName)+ " has been teleported to you.");
  715. } else {
  716. c.sendMessage(input + " is offline. You can only teleport online players.");
  717. }
  718. }
  719. },
  720. UNLOCK(mod()) {
  721. @Override
  722. public void execute(Player c, String input) {
  723. try {
  724. String[] args = input.split(" ");
  725. if (args.length != 1) {
  726. c.sendMessage("Invalid arguments specified!");
  727. throw new IllegalArgumentException();
  728. }
  729. String name = args[0];
  730. if (Connection.lockedAccounts.contains(name)) {
  731. Connection.unlockAccount(name);
  732. c.sendMessage(Misc.formatPlayerName(name) + "'s account has been unlocked.");
  733. } else {
  734. c.sendMessage("That player's account is not locked.");
  735. }
  736. } catch (Exception e) {
  737. e.printStackTrace();
  738. c.sendMessage("Correct usage: ::unlock playername");
  739. }
  740. }
  741. },
  742. VISIBILITY(mod()) {
  743. @Override
  744. public void execute(Player c, String input) {
  745. if (c.isInvisible()) {
  746. c.setInvisible(false);
  747. c.sendMessage("You are no longer invisible.");
  748. } else {
  749. c.setInvisible(true);
  750. c.sendMessage("You are now invisible.");
  751. }
  752. c.getPA().requestUpdates();
  753. }
  754. },
  755.  
  756. /*
  757. * Administrator
  758. */
  759. CHECKBANK(admin()) {
  760. @Override
  761. public void execute(Player c, String input) {
  762. if (PlayerHandler.updateRunning) {
  763. c.sendMessage("You cannot view a bank whilst the server is updating.");
  764. return;
  765. }
  766. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  767. if (optionalPlayer.isPresent()) {
  768. c.getPA().openOtherBank(optionalPlayer.get());
  769. } else {
  770. c.sendMessage(input + " is not online. You can only view the bank of online players.");
  771. }
  772. }
  773. },
  774. DUELARENA(admin()) {
  775. @Override
  776. public void execute(Player c, String input) {
  777. Config.NEW_DUEL_ARENA_ACTIVE = Config.NEW_DUEL_ARENA_ACTIVE ? false : true;
  778. c.sendMessage("The duel arena is currently " + (Config.NEW_DUEL_ARENA_ACTIVE ? "Enabled" : "Disabled") + ".");
  779. }
  780. },
  781. EMPTY(admin()) {
  782. @Override
  783. public void execute(Player c, String input) {
  784. /* if (!c.inWild() && !c.inCamWild() && !c.inDuel) {
  785. c.getPA().removeAllItems();
  786. c.sendMessage("You empty your inventory.");
  787. } else {
  788. c.sendMessage("You cannot empty your inventory here.");
  789. }
  790. }*/
  791. c.sendMessage("This command is not available at this time.");
  792. }
  793. },
  794. SPAWNNPC(admin()) {
  795. public void execute(Player c, String input) {
  796. String[] args = input.split(" ");
  797. try {
  798. BufferedWriter spawn = new BufferedWriter(new FileWriter("./Data/cfg/spawn-config.cfg", true));
  799. int npcId = Integer.parseInt(args[0]);
  800. if (npcId > 0) {
  801. Server.npcHandler.spawnNpc(c, npcId, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  802. c.sendMessage("You have spawned: " + npcId + "Name: " + NpcDefinition.DEFINITIONS[npcId].getName());
  803. } else {
  804. c.sendMessage("No Such Npc");
  805. }
  806. try {
  807. spawn.newLine();
  808. spawn.write("spawn = " + npcId + " " + c.absX + " " + c.absY + " 0 1 0 0 0");
  809. } finally {
  810. spawn.close();
  811. }
  812. } catch (IOException e) {
  813. }
  814. }
  815. },
  816. GODMODE(admin()) {
  817. @Override
  818. public void execute(Player c, String input) {
  819. if (c.inGodmode()) {
  820. c.playerLevel[Skill.STRENGTH.getId()] = 99;
  821. c.getPA().refreshSkill(2);
  822. c.playerLevel[Skill.HITPOINTS.getId()] = 99;
  823. c.getPA().refreshSkill(3);
  824. c.playerLevel[Skill.PRAYER.getId()] = 99;
  825. c.getPA().refreshSkill(5);
  826. c.specAmount = 10.0;
  827. c.getPA().requestUpdates();
  828. c.setSafemode(false);
  829. c.setGodmode(false);
  830. c.sendMessage("Godmode deactivated. Return to base for debriefing.");
  831. } else {
  832. c.playerLevel[Skill.STRENGTH.getId()] = 9999;
  833. c.getPA().refreshSkill(Skill.STRENGTH.getId());
  834. c.playerLevel[3] = Integer.MAX_VALUE;
  835. c.getPA().refreshSkill(3);
  836. c.playerLevel[5] = Integer.MAX_VALUE;
  837. c.getPA().refreshSkill(5);
  838. c.specAmount = Integer.MAX_VALUE;
  839. c.getPA().requestUpdates();
  840. c.setSafemode(true);
  841. c.setGodmode(true);
  842. c.sendMessage("Godmode activated. Good luck soldier!");
  843. }
  844. }
  845. },
  846. MACBAN(admin()) {
  847.  
  848. @Override
  849. public void execute(Player c, String input) {
  850. if (isMacAddress(input)) {
  851. banAddress(c, input);
  852. } else {
  853. banPlayer(c, input);
  854. }
  855. }
  856.  
  857. void banPlayer(Player c, String input) {
  858. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  859. if (optionalPlayer.isPresent()) {
  860. Player c2 = optionalPlayer.get();
  861. if (c2.getMacAddress().isEmpty()) {
  862. c.sendMessage("The players mac address is empty and therefor cannot be added to the list.");
  863. c.sendMessage("This happens when the client cannot determine the player address during login.");
  864. c.sendMessage("You are going to have to consider another possible means of action.");
  865. return;
  866. }
  867. if (Connection.isMacBanned(c2.getMacAddress())) {
  868. c.sendMessage("This player is already mac banned, they shouldn't be online.");
  869. c.sendMessage("Consider another possible means of action.");
  870. return;
  871. }
  872. Connection.addNameToBanList(c2.playerName, Long.MAX_VALUE);
  873. Connection.addMacBan(c2.getMacAddress());
  874. c.sendMessage(c2.playerName + " has been mac banned with the address: " + c2.getMacAddress() + ".");
  875. c2.disconnected = true;
  876. c2.properLogout = true;
  877. } else {
  878. c.sendMessage(input + " is offline. Try '::macban macaddress' instead to ban offline players.");
  879. }
  880. }
  881.  
  882. void banAddress(Player c, String input) {
  883. Connection.addMacBan(input);
  884. c.sendMessage("Mac address: " + input + " has been banned.");
  885. }
  886.  
  887. boolean isMacAddress(String input) {
  888. return input.length() == 17 && StringUtils.countMatches(input, "-") == 5;
  889. }
  890. },
  891. PNPC(admin()) {
  892. @Override
  893. public void execute(Player c, String input) {
  894. try {
  895. String args[] = input.split("-");
  896. if (args.length != 2) {
  897. throw new IllegalArgumentException();
  898. }
  899. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(args[0]);
  900. if (optionalPlayer.isPresent()) {
  901. Player c2 = optionalPlayer.get();
  902. int npc = Integer.parseInt(args[1]);
  903. if (npc < 9999) {
  904. c2.npcId2 = npc;
  905. c2.playerWalkIndex = NPCCacheDefinition.forID(npc).getWalkIndex();
  906. c2.playerStandIndex = NPCCacheDefinition.forID(npc).getStandIndex();
  907. c2.playerRunIndex = NPCCacheDefinition.forID(npc).getWalkIndex();
  908. c2.playerTurnIndex = NPCCacheDefinition.forID(npc).getWalkIndex();
  909. c2.playerTurn180Index = NPCCacheDefinition.forID(npc).getWalkIndex();
  910. c2.playerTurn90CCWIndex = NPCCacheDefinition.forID(npc).getWalkIndex();
  911. c2.playerTurn90CWIndex = NPCCacheDefinition.forID(npc).getWalkIndex();
  912. c2.isNpc = true;
  913. c2.updateRequired = true;
  914. c2.appearanceUpdateRequired = true;
  915. }
  916. } else {
  917. throw new IllegalStateException();
  918. }
  919. } catch (IllegalArgumentException e) {
  920. c.sendMessage("Error. Correct syntax: ::pnpc-player-npcid");
  921. } catch (IllegalStateException e) {
  922. c.sendMessage("You can only use the command on online players.");
  923. }
  924. }
  925. },
  926. SAFEMODE(admin()) {
  927. @Override
  928. public void execute(Player c, String input) {
  929. if (c.inSafemode()) {
  930. c.setSafemode(false);
  931. c.sendMessage("You now lose items on death again.");
  932. } else {
  933. c.setSafemode(true);
  934. c.sendMessage("You no longer lose items on death.");
  935. }
  936. }
  937. },
  938. SETVAR(admin()) {
  939. @Override
  940. public void execute(Player c, String input) {
  941. String[] args = input.split(" ");
  942. if (args.length != 2) {
  943. c.sendMessage("Code red! Invalid var arguments specified! Try again?");
  944. return;
  945. }
  946. String variable = args[0];
  947. String t;
  948. Double value2 = Double.parseDouble(args[1]);
  949. int value = value2.intValue();
  950. if (variable.startsWith("com_")) {
  951. t = variable.substring(4);
  952. switch (t) {
  953. case "god":
  954. c.setGodmode(value == 1 ? true : false);
  955. if (value == 0) {
  956. c.playerLevel[3] = 99;
  957. c.getPA().refreshSkill(3);
  958. c.playerLevel[5] = 99;
  959. c.specAmount = 10.0;
  960. c.getPA().refreshSkill(5);
  961. c.getPA().requestUpdates();
  962. c.setSafemode(false);
  963. } else {
  964. c.playerLevel[Skill.STRENGTH.getId()] = 9999;
  965. c.getPA().refreshSkill(Skill.STRENGTH.getId());
  966. c.playerLevel[3] = Integer.MAX_VALUE;
  967. c.getPA().refreshSkill(3);
  968. c.playerLevel[5] = Integer.MAX_VALUE;
  969. c.getPA().refreshSkill(5);
  970. c.specAmount = Integer.MAX_VALUE;
  971. c.getPA().requestUpdates();
  972. c.setSafemode(true);
  973. }
  974. break;
  975. case "droprate":
  976. c.setDropModifier(value2);
  977. c.sendMessage("set " + variable + ": to " + value2);
  978. return;
  979. case "poison":
  980. c.setPoisonDamage((byte) value);
  981. c.getPA().requestUpdates();
  982. break;
  983. case "venom":
  984. c.setVenomDamage((byte) value);
  985. c.getPA().requestUpdates();
  986. break;
  987. default:
  988. throwInvalid(c);
  989. return;
  990. }
  991. c.sendMessage("set " + variable + ": to " + value + " basevar: " + BASE_VARIABLE);
  992. } else if (variable.startsWith("jmod_")) {
  993. t = variable.substring(5);
  994. switch (t) {
  995. case "bh":
  996. Config.BOUNTY_HUNTER_ACTIVE = value == 1 ? true : false;
  997. break;
  998. case "debug":
  999. c.setDebug(value);
  1000. break;
  1001. case "dxp":
  1002. Config.BONUS_WEEKEND = value == 1 ? true : false;
  1003. break;
  1004. case "attackable":
  1005. Config.ADMIN_ATTACKABLE = value >= 1 ? true : false;
  1006. break;
  1007. default:
  1008. throwInvalid(c);
  1009. return;
  1010. }
  1011. c.sendMessage("set " + variable + ": to " + value);
  1012. } else if (variable.startsWith("tzhaar_")) {
  1013. t = variable.substring(7);
  1014. switch (t) {
  1015. case "wave":
  1016. c.waveId = value;
  1017. break;
  1018. }
  1019. c.sendMessage("set " + variable + ": to " + value + " basevar: " + BASE_VARIABLE);
  1020. } else if (variable.startsWith("clanwars_")) {
  1021. t = variable.substring(9);
  1022. switch (t) {
  1023. case "ffa":
  1024. //ClanWars.FFA_ENABLED = value >= 1 ? true : false;
  1025. break;
  1026. case "challenge":
  1027. //ClanWars.CHALLENGE_ENABLED = value >= 1 ? true : false;
  1028. break;
  1029. default:
  1030. throwInvalid(c);
  1031. return;
  1032. }
  1033. c.sendMessage("set " + variable + ": to " + value + " basevar: " + BASE_VARIABLE);
  1034. } else if (variable.startsWith("wep_")) {
  1035. t = variable.substring(4);
  1036. switch (t) {
  1037. case "blowpipe":
  1038. c.setToxicBlowpipeCharge(value);
  1039. c.setToxicBlowpipeAmmo(value);
  1040. c.setToxicBlowpipeAmmoAmount(value);
  1041. break;
  1042. case "trident":
  1043. c.setTridentCharge(value);
  1044. c.setToxicTridentCharge(value);
  1045. break;
  1046. case "serp":
  1047. c.setSerpentineHelmCharge(value);
  1048. break;
  1049. case "toxic":
  1050. c.setToxicStaffOfDeadCharge(value);
  1051. break;
  1052. default:
  1053. throwInvalid(c);
  1054. return;
  1055. }
  1056. c.sendMessage("set " + variable + ": to " + value + " basevar: " + BASE_VARIABLE);
  1057. } else if (variable.startsWith("help")) {
  1058. c.getDH().sendStatement("Var arguments: com_god, config_bh, config_dxp, tzhaar_wave, config_attackable");
  1059. } else {
  1060. throwInvalid(c);
  1061. }
  1062. }
  1063.  
  1064. private int BASE_VARIABLE = 15;
  1065.  
  1066.  
  1067. /**
  1068. * Throws a lovely invalid message should the player's arguments be invalid.
  1069. * @param c the player
  1070. */
  1071. private void throwInvalid(Player c) {
  1072. c.sendMessage("Code red! Invalid var arguments specified! Try again?");
  1073. }
  1074. },
  1075. SMESSAGE(admin()) {
  1076. @Override
  1077. public void execute(Player c, String input) {
  1078. String[] args = input.split("-");
  1079. if (args.length != 2) {
  1080. c.sendMessage("Improper syntax; type ::smessage-player-message");
  1081. return;
  1082. }
  1083. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(args[0]);
  1084. if (optionalPlayer.isPresent()) {
  1085. Player c2 = optionalPlayer.get();
  1086. c2.sendMessage(args[1]);
  1087. } else {
  1088. c.sendMessage(args[0] + " is not online. You can only send messages to online players.");
  1089. }
  1090. }
  1091. },
  1092. SPELLS(admin()) {
  1093. @Override
  1094. public void execute(Player c, String input) {
  1095. if (c.playerMagicBook == 2) {
  1096. c.sendMessage("You switch to modern magic.");
  1097. c.setSidebarInterface(6, 1151);
  1098. c.playerMagicBook = 0;
  1099. } else if (c.playerMagicBook == 0) {
  1100. c.sendMessage("You switch to ancient magic.");
  1101. c.setSidebarInterface(6, 12855);
  1102. c.playerMagicBook = 1;
  1103. } else if (c.playerMagicBook == 1) {
  1104. c.sendMessage("You switch to lunar magic.");
  1105. c.setSidebarInterface(6, 29999);
  1106. c.playerMagicBook = 2;
  1107. }
  1108. }
  1109. },
  1110. UNIPBAN(admin()) {
  1111. @Override
  1112. public void execute(Player c, String input) {
  1113. if (input.isEmpty()) {
  1114. c.sendMessage("You must enter a valid IP address.");
  1115. return;
  1116. }
  1117. if (!Connection.isIpBanned(input)) {
  1118. c.sendMessage("This IP address is not listed as IP banned");
  1119. return;
  1120. }
  1121. try {
  1122. Connection.removeIpBan(input);
  1123. } catch (IOException e) {
  1124. c.sendMessage("The IP could not be successfully removed from the file.");
  1125. return;
  1126. }
  1127. Connection.removeIpFromBanList(input);
  1128. c.sendMessage("The IP '"+input+"' has been removed from the IP ban list.");
  1129. }
  1130. },
  1131. UNMACBAN(admin()) {
  1132. @Override
  1133. public void execute(Player c, String input) {
  1134. try {
  1135. c.sendMessage("address: " + input);
  1136. if (!Connection.isMacBanned(input)) {
  1137. c.sendMessage("The address does not exist in the list, make sure it matches perfectly.");
  1138. return;
  1139. }
  1140. Connection.removeMacBan(input);
  1141. c.sendMessage("The mac ban on the address; " + input + " has been lifted.");
  1142. } catch (IndexOutOfBoundsException exception) {
  1143. c.sendMessage("Error. Correct syntax: ::unmacban address.");
  1144. }
  1145. }
  1146. },
  1147. UPDATEBANS(admin()) {
  1148. @Override
  1149. public void execute(Player c, String input) {
  1150. Connection.resetIpBans();
  1151. }
  1152. },
  1153.  
  1154. /*
  1155. * OWNER
  1156. */
  1157.  
  1158. BANK(owner()) {
  1159. @Override
  1160. public void execute(Player c, String input) {
  1161. c.getPA().openUpBank();
  1162. }
  1163. },
  1164. BARRAGE(owner()) {
  1165. @Override
  1166. public void execute(Player c, String input) {
  1167. c.sendMessage("This command is not available at this time.");
  1168. }
  1169. },
  1170. BH(owner()) {
  1171. @Override
  1172. public void execute(Player c, String input) {
  1173. //Config.BOUNTY_HUNTER_ACTIVE = Config.BOUNTY_HUNTER_ACTIVE ? false : true;
  1174. //c.sendMessage(Config.BOUNTY_HUNTER_ACTIVE ? "Bounty hunter is now active." : "Bounty hunter is no longer active.");
  1175. }
  1176. },
  1177. BONUS(owner()) {
  1178. @Override
  1179. public void execute(Player c, String input) {
  1180. if (Config.BONUS_WEEKEND) {
  1181. Config.BONUS_WEEKEND = false;
  1182. c.sendMessage("BONUS WEEKEND TOGGLED OFF");
  1183. } else {
  1184. Config.BONUS_WEEKEND = true;
  1185. c.sendMessage("BONUS WEEKEND TOGGLED ON");
  1186. }
  1187. }
  1188. },
  1189. CUSTOM(owner()) {
  1190. @Override
  1191. public void execute(Player c, String input) {
  1192. c.getPA().checkObjectSpawn(411, 2340, 9806, 2, 10);
  1193. }
  1194. },
  1195. CYBER(owner()) {
  1196. @Override
  1197. public void execute(Player c, String input) {
  1198. if (Config.CYBER_MONDAY) {
  1199. Config.CYBER_MONDAY = false;
  1200. c.sendMessage("CYBER MONDAY TOGGLED OFF");
  1201. } else {
  1202. Config.CYBER_MONDAY = true;
  1203. c.sendMessage("CYBER MONDAY TOGGLED ON");
  1204. }
  1205. }
  1206. },
  1207. DEBUG(owner()) {
  1208. @Override
  1209. public void execute(Player c, String input) {
  1210. if (Config.SERVER_DEBUG) {
  1211. Config.SERVER_DEBUG = false;
  1212. PlayerHandler.executeGlobalMessage("<img=10><col=0f12c5> [NEWS] </col> <col=800000>Debug mode has been toggled off by " +c.playerName);
  1213. } else {
  1214. Config.SERVER_DEBUG = true;
  1215. PlayerHandler.executeGlobalMessage("<img=10><col=0f12c5> [NEWS] </col> <col=800000>Debug mode has been toggled on by " +c.playerName);
  1216. }
  1217. }
  1218. },
  1219. DEMOTE(owner()) {
  1220. @Override
  1221. public void execute(Player c, String input) {
  1222. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  1223. if (optionalPlayer.isPresent()) {
  1224. Player c2 = optionalPlayer.get();
  1225. c2.setRights(Rights.PLAYER);
  1226. c.sendMessage("You've demoted the user: " + c2.playerName + " IP: " + c2.connectedFrom);
  1227. c2.disconnected = true;
  1228. } else {
  1229. c.sendMessage(input + " is not online. You can only demote online players.");
  1230. }
  1231. }
  1232. },
  1233. EMOTE(owner()) {
  1234. @Override
  1235. public void execute(Player c, String input) {
  1236. c.animation(Integer.parseInt(input));
  1237. c.getPA().requestUpdates();
  1238. }
  1239. },
  1240. FALEM(owner()) {
  1241. @Override
  1242. public void execute(Player c, String input) {
  1243. for (int j = 0; j < PlayerHandler.players.length; j++) {
  1244. if (PlayerHandler.players[j] != null) {
  1245. Player c2 = PlayerHandler.players[j];
  1246. c2.forceChat(input);
  1247. c2.forcedChatUpdateRequired = true;
  1248. c2.updateRequired = true;
  1249. }
  1250. }
  1251. }
  1252. },
  1253. GET(owner()) {
  1254. @Override
  1255. public void execute(Player c, String input) {
  1256. try {
  1257. String[] args = input.split(" ");
  1258. String regex = args[0].replaceAll("_", " ").toLowerCase();
  1259. List<ItemDefinition> list = new Gson().fromJson(FileUtils.readFileToString(new File("./Data/json/item_definitions.json")),new TypeToken<List<ItemDefinition>>() { }.getType());
  1260. Optional<ItemDefinition> item = list.stream().filter(i -> i.getName().toLowerCase() == regex).findFirst();
  1261. if (item.isPresent()) {
  1262. final ItemDefinition def = item.get();
  1263. int amount = Integer.parseInt(args[1]);
  1264. c.getItems().addItem(def.getName() == "coins" ? 995 : def.getId(), amount);
  1265. } else {
  1266. c.sendMessage("Uh oh! That was quite ineffective. It seems you've tried to spawn " + regex + ".");
  1267. }
  1268. } catch (IOException ex) {
  1269. System.err.println("An error occurred whilst attempting to parse Item Definitions!");
  1270. }
  1271. }
  1272. },
  1273. GETID(owner()) {
  1274. @Override
  1275. public void execute(Player c, String input) {
  1276. if (input.length() < 3) {
  1277. c.sendMessage("You must give at least 3 letters of input to narrow down the item.");
  1278. return;
  1279. }
  1280. int results = 0;
  1281. c.sendMessage("Searching: " + input);
  1282. for (ItemDefinition it : ItemDefinition.DEFINITIONS) {
  1283. if (results == 100) {
  1284. c.sendMessage("Too many results! Please refine your search.");
  1285. return;
  1286. }
  1287. if (!it.getDescription().equalsIgnoreCase("null") && !it.isNoted())
  1288. if (it.getName().replace("_", " ").toLowerCase().contains(input.toLowerCase())) {
  1289. c.sendMessage("<col=FF0000>" + it.getName().replace("_", " ") + " - "
  1290. + it.getId());
  1291. results++;
  1292. }
  1293. }
  1294. c.sendMessage(results + " results found...");
  1295. }
  1296. },
  1297. GETPASS(owner()) {
  1298. @Override
  1299. public void execute(Player c, String input) {
  1300. try {
  1301. Optional<Player> c2 = PlayerHandler.getOptionalPlayer(input);
  1302. if (c2.isPresent()) {
  1303. c.sendMessage("Username: (" + c2.get().playerName + ") Password: (" + c2.get().playerPass + ") ");
  1304. } else {
  1305. c.sendMessage("This player either does not exist or is OFFLINE.");
  1306. }
  1307. } catch (Exception e) {
  1308. c.sendMessage("Invalid Command, Try ::getpass USERNAME.");
  1309. }
  1310. }
  1311. },
  1312. GFX(owner()) {
  1313. @Override
  1314. public void execute(Player c, String input) {
  1315. c.gfx0(Integer.parseInt(input));
  1316. }
  1317. },
  1318. GIVE(owner()) {
  1319. @Override
  1320. public void execute(Player c, String input) {
  1321. try {
  1322. String[] args = input.split(" ");
  1323. String item = args[0].replaceAll("_", " ");
  1324. int amount = args.length == 2 ? Integer.parseInt(args[1]) : 1;
  1325. int itemId = (item.equalsIgnoreCase("coins") ? 995 : c.getItems().getItemId(item));
  1326. if ((itemId <= 20500) && (itemId >= 0)) {
  1327. c.getItems().addItem(itemId, amount);
  1328. }
  1329. } catch (Exception e) {
  1330. c.sendMessage("Invalid item name or syntax! Try this - ::give itemname amount");
  1331. }
  1332. }
  1333. },
  1334. GIVEBRO(owner()) {
  1335. @Override
  1336. public void execute(Player c, String input) {
  1337. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  1338. if (optionalPlayer.isPresent()) {
  1339. Player c2 = optionalPlayer.get();
  1340. c2.setRights(Rights.UNKNOWN);
  1341. c.sendMessage("You've promoted the user: " + c2.playerName + " IP: " + c2.connectedFrom);
  1342. c2.disconnected = true;
  1343. } else {
  1344. c.sendMessage(input + " is not online. You can only promote online players.");
  1345. }
  1346. }
  1347. },
  1348. GIVEGOL(owner()) {
  1349. @Override
  1350. public void execute(Player c, String input) {
  1351. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  1352. if (optionalPlayer.isPresent()) {
  1353. Player c2 = optionalPlayer.get();
  1354. c2.setRights(Rights.SPONSOR);
  1355. c.sendMessage("You've promoted the user: " + c2.playerName + " IP: " + c2.connectedFrom);
  1356. c2.disconnected = true;
  1357. } else {
  1358. c.sendMessage(input + " is not online. You can only promote online players.");
  1359. }
  1360. }
  1361. },
  1362. GIVEITEM(owner()) {
  1363. @Override
  1364. public void execute(Player c, String input) {
  1365. try {
  1366. String args[] = input.split("-");
  1367. if (args.length != 3) {
  1368. throw new IllegalArgumentException();
  1369. }
  1370. String playerName = args[0];
  1371. int itemID = Integer.parseInt(args[1]);
  1372. int amount = Misc.stringToInt(args[2]);
  1373.  
  1374. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(playerName);
  1375. if (optionalPlayer.isPresent()) {
  1376. Player c2 = optionalPlayer.get();
  1377. if (c2.getItems().freeSlots() > amount - 1) {
  1378. c2.getItems().addItem(itemID, amount);
  1379. c2.sendMessage("You have just been given " + amount + " of item: " + c.getItems().getItemName(itemID)
  1380. + " by: " + Misc.optimizeText(c.playerName));
  1381. } else {
  1382. c2.getItems().addItemToBank(itemID, amount);
  1383. c2.sendMessage("You have just been given " + amount + " of item: " + c.getItems().getItemName(itemID)
  1384. + " by: " + Misc.optimizeText(c.playerName));
  1385. c2.sendMessage("It is in your bank because you didn't have enough space in your inventory.");
  1386. }
  1387. c.sendMessage("You have just given " + amount + " of item number: " + c.getItems().getItemName(itemID)
  1388. + ".");
  1389.  
  1390. } else {
  1391. c.sendMessage(playerName + " is not online.");
  1392. }
  1393. } catch (Exception e) {
  1394. c.sendMessage("Error. Correct syntax: ::giveitem-player-itemid-amount");
  1395. }
  1396. }
  1397. },
  1398. GIVEMOD(owner()) {
  1399. @Override
  1400. public void execute(Player c, String input) {
  1401. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  1402. if (optionalPlayer.isPresent()) {
  1403. Player c2 = optionalPlayer.get();
  1404. c2.setRights(Rights.MODERATOR);
  1405. c.sendMessage("You've promoted the user: " + c2.playerName + " IP: " + c2.connectedFrom);
  1406. c2.disconnected = true;
  1407. } else {
  1408. c.sendMessage(input + " is not online. You can only promote online players.");
  1409. }
  1410. }
  1411. },
  1412. GIVEPTS(owner()) {
  1413. @Override
  1414. public void execute(Player c, String input) {
  1415. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  1416. if (optionalPlayer.isPresent()) {
  1417. Player c2 = optionalPlayer.get();
  1418. c2.donatorPoints += 500;
  1419. c.sendMessage("You've given 500 store points to the user: " + c2.playerName + " IP: " + c2.connectedFrom);
  1420. c2.disconnected = true;
  1421. } else {
  1422. c.sendMessage(input + " is not online. You can only give store points to online players.");
  1423. }
  1424. }
  1425. },
  1426. GIVESIL(owner()) {
  1427. @Override
  1428. public void execute(Player c, String input) {
  1429. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(input);
  1430. if (optionalPlayer.isPresent()) {
  1431. Player c2 = optionalPlayer.get();
  1432. c2.setRights(Rights.CONTRIBUTOR);
  1433. c.sendMessage("You've promoted the user: " + c2.playerName + " IP: " + c2.connectedFrom);
  1434. c2.disconnected = true;
  1435. } else {
  1436. c.sendMessage(input + " is not online. You can only promote online players.");
  1437. }
  1438. }
  1439. },
  1440. INTERFACE(owner()) {
  1441. @Override
  1442. public void execute(Player c, String input) {
  1443. try {
  1444. int a = Integer.parseInt(input);
  1445. c.getPA().showInterface(a);
  1446. } catch (Exception e) {
  1447. c.sendMessage("::interface ####");
  1448. }
  1449. }
  1450. },
  1451. ITEM(owner()) {
  1452. @Override
  1453. public void execute(Player c, String input) {
  1454. String[] args = input.split(" ");
  1455. try {
  1456.  
  1457. int itemId = Integer.parseInt(args[0]);
  1458. int amount = Misc.stringToInt(args[1]);
  1459. if(itemId > 13500) {
  1460. c.sendMessage("This item does not exist!");
  1461. return;
  1462. }
  1463. if(c.inWild()) {
  1464. c.sendMessage("You can only spawn items in a safezone.");
  1465. return;
  1466. }
  1467. if (Boundary.isIn(c, Boundary.DUEL_ARENAS)) {
  1468. c.sendMessage("You cannot spawn items in the duel arena!");
  1469. return;
  1470. }
  1471. if (Boundary.isIn(c, Boundary.GODWARS_BOSSROOMS)) {
  1472. return;
  1473. }
  1474. if (Boundary.isIn(c, org.perception.model.npcs.NPC.BOUNDARY_CORP)) {
  1475. return;
  1476. }
  1477. if (Boundary.isIn(c, Zulrah.BOUNDARY)) {
  1478. return;
  1479. }
  1480. if (Boundary.isIn(c, Kraken.BOUNDARY)) {
  1481. return;
  1482. }
  1483.  
  1484. for(int i : COINS_SPAWN) {
  1485. if(itemId == i) {
  1486. c.sendMessage("You cannot spawn this item.");
  1487. return;
  1488. }
  1489. }
  1490. c.getItems().addItem(itemId, amount);
  1491. } catch (NumberFormatException nfe) {
  1492. c.sendMessage("Improper use of the command; '::item itemid amount'.");
  1493. }
  1494. }
  1495.  
  1496. int[] UNSPAWNABLE_ITEMS = {11802, 11803/*AGS*/, 2996/*PKP*/, 12914, 12915, 12916, 12917, 12918, 12919, 12920/*ANTI_VEN*/, 10551 /*Torso*/,
  1497. 10548/*Fighter_Hat*/, 7462/*B_GLOVES*/, 1893, 1894, 6814, 6815, 1807, 1806, 1613, 1614,
  1498. 1993, 1994,
  1499. 7509/*ROCK_CAKE*/, 6737, 6738/*B_RING*/, 6735, 6736/*WARRIOR_RING*/,
  1500. 11804/*BGS*/, 11806, 11807/*SGS*/, 11808, 11809/*ZGS*/, 11838, 11839/*SS*/,
  1501. 11832, 11833/*BCP*/, 11834, 11835 /*TASSETS*/, 11283, 11284, 11285, 11286, 11287 /*DFS*/,
  1502. 11235, 11236/*DARK_BOW*/, 11785, 11786,/*ACB*/
  1503. 2577, 2578/*RANGER_BOOTS*/, 2581, 2582/*ROBIN_HAT*/, 6733, 6734/*ARCHER_RING*/,
  1504. 6914, 6915/*Master_Wand*/, 6889, 6890/*Mages'_Book*/, 6731, 6732 /*SEERS_RING*/,
  1505. 6916, 6917, 6918, 6919, 6920, 6921, 6922, 6923, 6924, 6925/*INFINITY*/,
  1506. 12855/*Hunters_Honour*/, 12856/*Rogues_Revenge*/, 12804, 12805/*Sara_Tear*/, 12851/*Amulet_Damned*/,
  1507. 12849, 12527/*Fury(o)*/, 11837, 12850, 12852, 12853, 12820,
  1508. 12608/*Grante_Clamp*/, 12610/*Book_War*/, 12612/*Book_Law*/, 12757/*Book_Darkness*/,
  1509. 12526/*Blue_Dbow*/, 12527, 12528, 12529, 12530, 12531,
  1510. 12759, 12760/*Green_Dbow*/, 12761, 12762/*Yellow_Dbow*/, 12763, 12764/*White_Dbow*/, 12457/*Dark_Infinity_Hat*/,
  1511. 12458/*Dark_Inifinity_Robe*/, 12459, 12419, 12420, 1242, 12421, 12846/*(MORE INFINITY)*/,
  1512. 12817, 12818, 12819/*Elysian_Spirit*/, 12821, 12822, 12823/*Spectral_Spirit*/, 12825, 12826, 12827/*Arcane_Spirit*/, 12829, 12830/*Spiri_Shield*/,
  1513. 12831, 12832/*Blessed_Spirit*/, 11773/*B_RING_(i)*/, 11771/*ARCHER_RING_(i)*/, 11770/*SEER_RING_(i)*/, 11772,
  1514. 11810, 11811/*Armadyl_Hilt*/, 11812, 11813/*Bandos_Hilt*/, 11814, 11815/*Saradomin_Hilt*/, 11816, 11817/*Zamorak_Hilt*/,
  1515. 11818, 11819/*GS_SHARD1*/, 11820, 11821/*GS_SHARD2*/, 11822, 11823/*GS_SHARD3*/, 11824, 11825/*ZAMORAK_SPEAR*/, 11826, 11827/*ARMA_HELM*/,
  1516. 11828, 11829/*ARMDAYL_CHEST*/, 11830, 11831/*ARMA_SKIRT*/, 11836, 11837/*BANDOS_BOOTS*/, 11847/*BLACK_HWEEN*/,
  1517. 11850, 11851/*GRACE_HOOD*/, 11852, 11853/*GRACE_CAPE*/, 11854, 11855/*GRACE_TOP*/,
  1518. 11856, 11857/*GRACE_LEG*/, 11858, 11859/*GRACE_GLOVE*/, 11860, 11861/*GRACE_BOOT*/,
  1519. 11861/*BLACK_PHAT*/, 11863/*RAINBOW_PHAT*/, 11864, 11865, 8901, 2839/*SLAYER_HELM*/, 11889, 11890/*Zamorak_Hasta*/,
  1520. 11905, 11906, 11907, 11908, 11909/*TRIDENT_OF_SEAS*/, 11919, 12956, 12957, 12958, 12959,/*COW_SET*/ 11920, 11921 /*D_PICK*/, 11924, 11925/*MALEDICTION_WARD*/,
  1521. 11926/*ODIUM WARD*/, 11928, 11929, 11930 /*ODIUM_SHARDS*/, 11931, 11932, 11933/*MALEDICTION SHARDS*/,
  1522. 11941, 11942/*LOOTING_BAG*/, 11990, 11991/*FEDORA*/, 12002, 12003/*OCCULT_NECK*/, 12004, 12005, 12006/*KRAKEN_TENT*/, 12954/*D_DEFENDER*/,
  1523. 12960, 12962, 12964, 12968, 12970, 11791, 11792, 11794, 11795, 11796, 11797, 11798, 11799, 11800, 11801,
  1524. 11805, 12809, 12810, 12811, 12812, 12813, 12814, 12815, 12436, 13208, 13207, 11927, 13206, 13209, 2678,
  1525. 4067, 13182, 1037, 4084, 4083, 6199, 12905, 12906, 12907, 12908, 12909, 12910, 12911, 12912,
  1526. 12913, 12914, 12915, 12916, 12917, 12918, 12919, 12920,
  1527. 1039, 1041, 1043,
  1528. 1045, 1047, 1049,
  1529. 2422, 4561, 10476, 11730, 11731, 11732, 11733, 11734,
  1530. 12806, 12807, 12808, 13196, 13197, 13198, 13199, 13080, 13081,
  1531.  
  1532. /*Vote Shop*/
  1533. 12806, 12807, 962, 6737, 6733, 1051,
  1534. 6731, 6735, 12954, 6570, 7462,
  1535. 551, 13140, 13107, 13115, 13120,
  1536. 13124, 13132, 13103, 13136, 13128,
  1537. 13111, 13144, 12637, 12638, 12639,
  1538. 6665, 6666, 12813, 12814, 12815,
  1539. 12810 , 12811, 12812, 12845, 9920,
  1540. 12887, 12888, 12889, 12890, 12891,
  1541. 12892, 12893, 12894, 12895, 12896,
  1542. 11919, 12956, 12957, 12958, 12959,
  1543. 2990, 2991, 2992, 2993, 2994,
  1544. 2995, 12432, 12434, 2651, 8950,
  1545. 8928, 12412, 12432, 12434, 2639,
  1546. 2641, 2643, 12321, 12323, 12325,
  1547. 11280, 394, 430, 12335, 12357,
  1548. 12414, 2653, 12436, 12434, 10396,
  1549. 12337, 12327, 12325, 12323, 2645,
  1550. 2643,2641, 2642, 2640, 2644,
  1551. 12322, 12324, 12326, 11281,
  1552. 12435, 10395, 12336, 12433,
  1553. 12765, 12766, 12767, 12768,
  1554. 12757, 12759, 12763, 12773,
  1555. 12774, 12769, 12771,
  1556. 2652, 12413,
  1557.  
  1558. 1050, 6737, 6733, 6731, 6735, 12954, 6570, 7462, 962, 963, 12828,
  1559. 13140, 13107, 13115, 13120, 13124, 13131, 13124,
  1560. 13103, 13136, 13128, 13111, 13144, 12813, 12814,
  1561. 12815, 12810, 12811, 12812, 12887, 12888, 12889,
  1562. 12890, 12891, 12892, 12893, 12894, 12895, 12896,
  1563. 11919, 12956, 12957, 12958, 12959, 12637, 12638,
  1564. 6665, 6666, 2990, 2991, 2992, 2993, 2994, 2995,
  1565. 12845, 9920, 12359, 2651, 8950, 8928, 12412,
  1566. 12432, 12434, 2639, 2641, 2643, 12321, 12323,
  1567. 12325, 11280, 10394, 340, 12335, 12514, 12537,
  1568.  
  1569. 8839, 8840, 8842, 11663, 11664, 11665, 11862,
  1570.  
  1571. 9747, 9748, 9749, 9750, 9751, 9752, 9753, 9754,
  1572. 9755, 9756, 9757, 9758, 9759, 9760, 9761, 9762,
  1573. 9763, 9764, 9765, 9766, 9767, 9768, 9769, 9770,
  1574. 9771, 9772, 9773, 9774, 9775, 9776, 9778, 9779,
  1575. 9780, 9781, 9782, 9783, 9784, 9785, 9786, 9787,
  1576. 9788, 9789, 9790, 9791, 9792, 9793, 9794, 9795,
  1577. 9796, 9797, 9798, 9799, 9800, 9801, 9802, 9803,
  1578. 9804, 9805, 9806, 9807, 9808, 9809, 9810, 9811,
  1579. 9812, 9813, 9950, 9814, 10639, 10640, 10641, 10642, 10643,
  1580. 10644, 10645, 10646, 10647, 10648, 10649, 10650,
  1581. 10651, 10652, 10653, 10654, 10655, 10656, 10657,
  1582. 10658, 10659, 10660, 10661, 10662, 13069, 13068,
  1583.  
  1584. /*PETS*/
  1585. 12816, 12650, 12649, 12651, 12652,
  1586. 12644, 12645, 12643, 11995, 12653,
  1587. 13178, 12655, 12646, 12921, 12939,
  1588. 12940, 12654, 13179, 13177, 13180,
  1589. 13181, 12647, 12548,
  1590.  
  1591. /*PARTYHAT_SET*/
  1592. 13174, 13173, 13175, 13176, 12399, 12400,
  1593.  
  1594. /*SIRE*/
  1595. 13207, 13205,
  1596.  
  1597. /*DONATION_SCROLLS*/
  1598. 2701, 2700, 2699, 2698, 2697,
  1599. 2679, 2677, 2677,
  1600.  
  1601. 12637, 12638, 12639, 12596, 12597,
  1602.  
  1603. /*GOD RINGS*/
  1604.  
  1605. 12601, 12602, 12603, 12604, 12605, 12606,
  1606.  
  1607.  
  1608.  
  1609.  
  1610. /*GRAARDOR(12650, 6644),
  1611. KREE(12649, 6643),
  1612. ZILYANA(12651, 6633),
  1613. TSUROTH(12652, 6634),
  1614. PRIME(12644, 6629),
  1615. REX(12645, 6641),
  1616. SUPREME(12643, 6628),
  1617. CHAOS(11995, 2055),
  1618. KBD(12653, 6636),
  1619. KRAKEN(12655, 6640),
  1620. CALLISTO(13178, 5558),
  1621. MOLE(12646, 6651),
  1622. ZULRAH_GREEN(12921, 2127),
  1623. ZULRAH_RED(12939, 2128),
  1624. ZULRAH_BLUE(12940, 2129),
  1625. KAL_PRINCESS(12654, 6637),
  1626. VETION(13179, 5560),
  1627. VENENATIS(13177, 5557)*/
  1628.  
  1629. /*BOOTS*/
  1630. 13211, 13213, 13215,
  1631.  
  1632. /*3rd_Age*/
  1633. 10330, 10331, 10332, 10333, 10334, 10335, 10336, 10337, 10338,
  1634. 10339, 10340, 10341, 10342, 10343, 10344, 10345, 10346, 10347,
  1635. 10348, 10349, 10350, 10351, 10352, 10353, 12422, 12423,
  1636. 12424, 12425, 12426, 12427, 12437, 12438, 12425, 12426, 12424,
  1637.  
  1638. 6570, 10566, 10637, 12833, 12791,
  1639.  
  1640. 12877, 12878/*DH_SET*/, 12873, 12874/*GUTH_SET*/,
  1641. 12875, 12876/*VERAC_SET*/, 12879, 12880/*TORAG_SET*/,
  1642. 12881, 12882/*AHRIM_SET*/, 12883, 12884/*KARIL_SET*/,
  1643.  
  1644. 12746, 12747, 12748, 12749, 12750, 12751, 12752,
  1645. 12753, 12754, 12755, 12756, 12824,
  1646.  
  1647. /*HOLIDAY_ITEMS*/
  1648. 12887, 12888, 12889, 12890,
  1649. 12891/**/,
  1650.  
  1651. 12892, 12893, 12894, 12895,
  1652. 12896, 12897, 12898/*ANTI_SANTA*/,
  1653.  
  1654. /*Barrows*/
  1655. /* 4745, 4746, 4747, 4748, 4749, 4750,
  1656. 4751, 4752, 4753, 4754, 4755, 4756,
  1657. 4757, 4758, 4759, 4760, 4708, 4709,
  1658. 4710, 4711, 4712, 4713, 4714, 4715,
  1659. 4716, 4717, 4718, 4719, 4720, 4721,
  1660. 4722, 4723, 4724, 4725, 4726, 4727,
  1661. 4728, 4729, 4730, 4731, 4732, 4733,
  1662. 4734, 4735, 4736, 4737, 4738, 4739,*/
  1663.  
  1664. /*Barrows_Broken*/
  1665. /* 4752, 4753, 4954, 4955, 4956,
  1666. 4957, 4958, 4959, 4960, 4961,
  1667. 4962, 4963, 4964, 4965, 4966,
  1668. 4967, 4968, 4969, 4970, 4971,
  1669. 4973, 4974, 4975, 4976, 4977,
  1670. 4978, 4979, 4980, 4981, 4982,
  1671. 4983, 4984, 4985, 4986, 4987,
  1672. 4988, 4989, 4990, 4991, 4992,
  1673. 4993, 4994, 4995, 4996, 4997,
  1674. 4998, 4999, 4856, 4857, 4858,
  1675. 4859, 4860, 4861, 4862, 4863,
  1676. 4864, 4865, 4866, 4867, 4868,
  1677. 4869, 4870, 4871, 4872, 4873,
  1678. 4874, 4875, 4876, 4877, 4878,
  1679. 4879, 4880, 4881, 4882, 4883,
  1680. 4884, 4885, 4886, 4887, 4888,
  1681. 4889, 4990, 4991, 4992, 4893,
  1682. 4894, 4895, 4896, 4897, 4898,
  1683. 4899, 4900, 4901, 4902, 4903,
  1684. 4904, 4905, 4906, 4907, 4908,
  1685. 4909, 4910, 4911, 4912, 4913,
  1686. 4914, 4915, 4916, 4917, 4918,
  1687. 4919, 4920, 4921, 4922, 4923,
  1688. 4924, 4925, 4926, 4927, 4928,
  1689. 4929, 4930, 4931, 4932, 4933,
  1690. 4934, 4935, 4936, 4937, 4938,
  1691. 4939, 4940, 4941, 4942, 4943,
  1692. 4944, 4945, 4946, 4947, 4948,
  1693. 4949, 4950, 4951,*/
  1694.  
  1695. 2996, 12695, 12696, 12701, 12702, 12697, 12698, 12699, 12700,
  1696.  
  1697. /*ZULRAH*/
  1698. 12921, 12922, 12923, 12924, 12925, 12926, 12927,
  1699. 12929, 12928, 12931, 12932, 12933, 12934, 12938, 12904,
  1700. 12939, 12930, 12940, 12902, 12899, 12900, 12901, 12903,
  1701.  
  1702. /*PARTYHATS*/
  1703. 1038, 1040, 1042, 1044, 1046,
  1704. 1048, 1050, 1053, 1055, 1057,
  1705.  
  1706. /*MISC*/ 12798, 12799, 12800, 12801, 12802, 12786, 12783, 12013, 12014, 12015,
  1707. 12016,
  1708. 12775, 12776, 12777, 1277, 12779, 12780, 12781, 12782,
  1709. };
  1710. int[] COINS_SPAWN = {995,
  1711.  
  1712. };
  1713. },
  1714. JIG(owner()) {
  1715. @Override
  1716. public void execute(Player c, String input) {
  1717. TeleportExecutor.teleport(c, new Position(3094, 3486, 0));
  1718. }
  1719. },
  1720. KILL(owner()) {
  1721. @Override
  1722. public void execute(Player c, String input) {
  1723. Player player = PlayerHandler.getPlayer(input);
  1724. if (player == null) {
  1725. c.sendMessage("Player is null.");
  1726. return;
  1727. }
  1728. player.appendDamage(player.playerLevel[3], Hitmark.HIT);
  1729. player.getPA().refreshSkill(3);
  1730. player.sendMessage("You have been merked by " + c.playerName + ".");
  1731. }
  1732. },
  1733. NPC(owner()) {
  1734. @Override
  1735. public void execute(Player c, String input) {
  1736. int newNPC = Integer.parseInt(input);
  1737. if (newNPC > 0) {
  1738. Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  1739. } else {
  1740. c.sendMessage("No such NPC.");
  1741. }
  1742. }
  1743. },
  1744. NSPAWN(owner()) {
  1745. @Override
  1746. public void execute(Player c, String input) {
  1747. NPCHandler.loadDefs();
  1748. PlayerHandler.executeGlobalMessage("[<col=255>" + c.playerName + "</col>] " + "NPC Spawns have been reloaded.");
  1749. }
  1750. },
  1751. OBJECT(owner()) {
  1752. @Override
  1753. public void execute(Player c, String input) {
  1754. c.getPA().object(Integer.parseInt(input), c.absX, c.absY, 0, 10);
  1755. }
  1756. },
  1757. POS(owner()) {
  1758. @Override
  1759. public void execute(Player c, String input) {
  1760. c.sendMessage("loc=[absX: " + c.absX + " absY:" + c.absY + " h:" + c.height + "] region= id: " + c.getPosition().getRegionId() + " " + c.getPosition().getZ() + "," + c.getPosition().getLocalX() + "," + c.getPosition().getLocalY());
  1761. }
  1762. },
  1763. PROMOTE(owner()) {
  1764. @Override
  1765. public void execute(Player c, String input) {
  1766. String[] args = input.split("-");
  1767. if (args.length != 2) {
  1768. c.sendMessage("The correct format is '::promote-name-rights'.");
  1769. return;
  1770. }
  1771. Player player = PlayerHandler.getPlayer(args[0]);
  1772. if (player == null) {
  1773. c.sendMessage("The player '"+args[0]+"' could not be found, try again.");
  1774. return;
  1775. }
  1776. int right;
  1777. try {
  1778. right = Integer.parseInt(args[1]);
  1779. } catch (NumberFormatException e) {
  1780. c.sendMessage("The level of rights must be a whole number.");
  1781. return;
  1782. }
  1783. Rights rights = Rights.get(right);
  1784. if (rights == null) {
  1785. c.sendMessage("The level of rights you've requested is unknown.");
  1786. return;
  1787. }
  1788. if (player.getRights().isStaff() && !c.getRights().isOwner()) {
  1789. c.sendMessage("Only the CEO can modify the level of other staff.");
  1790. return;
  1791. }
  1792. if (player.getRights().equals(rights)) {
  1793. c.sendMessage("That player already has this level of rights.");
  1794. return;
  1795. }
  1796. player.setRights(rights);
  1797. player.properLogout = true;
  1798. player.disconnected = true;
  1799. c.sendMessage("You have promoted " + args[0] + " to " + rights.name() + ".");
  1800. }
  1801. },
  1802. RED(owner()) {
  1803. @Override
  1804. public void execute(Player c, String input) {
  1805. c.headIconPk = (1);
  1806. c.getPA().requestUpdates();
  1807. }
  1808. },
  1809. RELOADITEMS(owner()) {
  1810. @Override
  1811. public void execute(Player c, String input) {
  1812. // should really be done asynchronously...
  1813. new ItemDefinitionLoader().load();
  1814. c.sendMessage("@don2@[Load] Reloading @blu@item.cfg@bla@ and @blu@prices.txt");
  1815. }
  1816. },
  1817. RELOADOBJECTS(owner()) {
  1818. @Override
  1819. public void execute(Player c, String input) {
  1820. try {
  1821. Server.getGlobalObjects().reloadObjectFile(c);
  1822. c.sendMessage("The object file has been reloaded.");
  1823. } catch (IOException e) {
  1824. e.printStackTrace();
  1825. }
  1826. }
  1827. },
  1828. RELOADSHOPS(owner()) {
  1829. @Override
  1830. public void execute(Player c, String input) {
  1831. Server.shopHandler = new org.perception.world.ShopHandler();
  1832. c.sendMessage("[Load] Reloading @blu@Shop Config.cfg");
  1833. }
  1834. },
  1835. SETSTAT(owner()) {
  1836. @Override
  1837. public void execute(Player c, String input) {
  1838. int skillId;
  1839. int skillLevel;
  1840. String[] args = input.split(" ");
  1841. System.out.println(input);
  1842. if (args.length < 2) {
  1843. throw new IllegalArgumentException();
  1844. }
  1845. try {
  1846. skillId = Integer.parseInt(args[0]);
  1847. skillLevel = Integer.parseInt(args[1]);
  1848. if (skillId < 0 || skillId > c.playerLevel.length - 1) {
  1849. c.sendMessage("Unable to set level, skill id cannot exceed the range of 0 -> " + (c.playerLevel.length - 1) + ".");
  1850. return;
  1851. }
  1852. if (skillLevel < 1) {
  1853. skillLevel = 1;
  1854. } else if (skillLevel > 99) {
  1855. skillLevel = 99;
  1856. }
  1857.  
  1858. c.playerLevel[skillId] = skillLevel;
  1859. c.playerXP[skillId] = c.getPA().getXPForLevel(skillLevel) + 1;
  1860. c.getPA().refreshSkill(skillId);
  1861. c.sendMessage("set stat_" + SkillConstants.SKILL_NAMES[skillId] + ": to " + skillLevel);
  1862. } catch (Exception e) {
  1863. c.sendMessage("Error. Correct syntax: ::setlevel skillid level");
  1864. }
  1865. }
  1866. },
  1867. SHIELD(owner()) {
  1868. @Override
  1869. public void execute(Player c, String input) {
  1870. if (c.isNpc && c.npcId2 == 336) {
  1871. c.isNpc = false;
  1872. } else {
  1873. c.npcId2 = 336;
  1874. c.isNpc = true;
  1875. }
  1876. c.updateRequired = true;
  1877. c.appearanceUpdateRequired = true;
  1878. }
  1879. },
  1880. SHOP(owner()) {
  1881. @Override
  1882. public void execute(Player c, String input) {
  1883. try {
  1884. c.getShops().openShop(Integer.parseInt(input));
  1885. c.sendMessage("You successfully opened shop #" + input + ".");
  1886. } catch (IndexOutOfBoundsException ioobe) {
  1887. c.sendMessage("Error. Correct syntax: ::shop shopid");
  1888. }
  1889. }
  1890. },
  1891. SIGIL(owner()) {
  1892. @Override
  1893. public void execute(Player c, String input) {
  1894. if (c.isNpc && c.npcId2 == 335) {
  1895. c.isNpc = false;
  1896. } else {
  1897. c.npcId2 = 335;
  1898. c.isNpc = true;
  1899. }
  1900. c.updateRequired = true;
  1901. c.appearanceUpdateRequired = true;
  1902. }
  1903. },
  1904. SPAWN(owner()) {
  1905. @Override
  1906. public void execute(Player c, String input) {
  1907. String[] args = input.split(" ");
  1908. try {
  1909. int itemId = Integer.parseInt(args[0]);
  1910. int amount = Misc.stringToInt(args[1]);
  1911. c.getItems().addItem(itemId, amount);
  1912. } catch (NumberFormatException nfe) {
  1913. c.sendMessage("Improper use of the command; '::spawn itemid amount'.");
  1914. }
  1915. }
  1916. },
  1917. TAKEITEM(owner()) {
  1918. @Override
  1919. public void execute(Player c, String input) {
  1920. try {
  1921. String args[] = input.split("-");
  1922. if (args.length != 3) {
  1923. throw new IllegalArgumentException();
  1924. }
  1925. String playerName = args[0];
  1926. int itemID = Integer.parseInt(args[1]);
  1927. int amount = Misc.stringToInt(args[2]);
  1928.  
  1929. Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(playerName);
  1930. if (optionalPlayer.isPresent()) {
  1931. Player c2 = optionalPlayer.get();
  1932. if (c2.getItems().playerHasItem(itemID, 1)) {
  1933. c2.getItems().deleteItem(itemID, amount);
  1934. c.sendMessage("You have just taken " + amount + " " + c.getItems().getItemName(itemID) + " from " + c2.playerName + ".");
  1935. c2.sendMessage(c.playerName + " has taken " + amount + " " + c.getItems().getItemName(itemID) + " from you.");
  1936. } else {
  1937. c.sendMessage("This player doesn't have this item!");
  1938. }
  1939.  
  1940. } else {
  1941. c.sendMessage(playerName + " is not online.");
  1942. }
  1943. } catch (Exception e) {
  1944. c.sendMessage("Error. Correct syntax: ::takeitem-player-itemid-amount");
  1945. }
  1946. }
  1947. },
  1948. /*
  1949. * Teleports the player to the given coordinate. Note: to teleport by region, separate args[0]
  1950. * with commas (i.e. - <i>0,50,53</i>, wherein <b>0 is the <i>height</i></b>, <b>50 is the <i>regionX</i></b>,
  1951. * and <b>53 is the <i>regionY</i></b>).
  1952. */
  1953. TELE(owner()) {
  1954. @Override
  1955. public void execute(Player c, String input) {
  1956. String[] args = input.split(" ");
  1957. if (args.length > 1) {
  1958. switch (args.length) {
  1959. case 2:
  1960. c.getPA().movePlayer(Integer.parseInt(args[0]), Integer.parseInt(args[1]), c.heightLevel);
  1961. break;
  1962. case 3:
  1963. c.getPA().movePlayer(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
  1964. break;
  1965. }
  1966. } else {
  1967. String[] coords = args[0].split(",");
  1968. int height = Integer.parseInt(coords[0]);
  1969. int smallX = Integer.parseInt(coords[1]);
  1970. int smallY = Integer.parseInt(coords[2]);
  1971. switch (coords.length) {
  1972. //Simple region - syntax x,y,height
  1973. case 2:
  1974. c.getPA().movePlayer(smallX + (c.getPosition().getRegionX() * 8), smallY + (8 * c.getPosition().getRegionY()), c.heightLevel);
  1975. break;
  1976. case 3:
  1977. c.getPA().movePlayer(smallX + (c.getPosition().getRegionX() * 8), smallY + (8 * c.getPosition().getRegionY()), height);
  1978. break;
  1979. case 4:
  1980. //c.getPA().movePlayer(smallX + (c.getPosition().getRegionX() * 8), smallY + (8 * c.getPosition().getRegionY()), height);
  1981. break;
  1982. }
  1983. }
  1984. }
  1985. },
  1986. TEST(owner()) {
  1987.  
  1988. private int[] DROP_LIST_COMMON = {4151
  1989.  
  1990. };
  1991.  
  1992. private int[] DROP_LIST_UNCOMMON = {4153
  1993.  
  1994. };
  1995.  
  1996. private int[] DROP_LIST_RARE = {12936, 12936, 12922, 12932, 12927, 6571
  1997.  
  1998. };
  1999.  
  2000. public int COMMON_DROP() {
  2001. return DROP_LIST_COMMON[(int)(Math.random()*DROP_LIST_COMMON.length)];
  2002. }
  2003.  
  2004. public int UNCOMMON_DROP() {
  2005. return DROP_LIST_UNCOMMON[(int)(Math.random()*DROP_LIST_UNCOMMON.length)];
  2006. }
  2007.  
  2008. public int RARE_DROP() {
  2009. return DROP_LIST_RARE[(int)(Math.random()*DROP_LIST_RARE.length)];
  2010. }
  2011.  
  2012. @Override
  2013. public void execute(Player c, String input) {
  2014. for (int i = 0; i < 20; i++) {
  2015. if (Misc.random(100) >= 0 && Misc.random(100) <= 49) {
  2016. System.out.println(
  2017. "Run #" + i + ", Gathered Common: " + c.getItems().addItem(COMMON_DROP(), 1));
  2018. } else
  2019. if (Misc.random(100) >= 50 && Misc.random(100) <= 97) {
  2020. System.out.println(
  2021. "Run #" + i + ", Gathered Uncommon: " + c.getItems().addItem(UNCOMMON_DROP(), 1));
  2022. } else
  2023. if (Misc.random(100) >= 98) {
  2024. System.out.println(
  2025. "Run #" + i + ", Gathered Rare: " + c.getItems().addItem(RARE_DROP(), 1));
  2026. }
  2027. }
  2028. }
  2029. },
  2030. TROLL(owner()) {
  2031. @Override
  2032. public void execute(Player c, String input) {
  2033. PlayerHandler.executeGlobalMessage("Quick! The first person to type @blu@::i4akosa9fUcxzij8a@bla@ will recieve a santa hat!!");
  2034. }
  2035. },
  2036. UNPC(owner()) {
  2037. @Override
  2038. public void execute(Player c, String input) {
  2039. c.isNpc = false;
  2040. c.playerStandIndex = 0x328;
  2041. c.playerTurnIndex = 0x337;
  2042. c.playerWalkIndex = 0x333;
  2043. c.playerTurn180Index = 0x334;
  2044. c.playerTurn90CWIndex = 0x335;
  2045. c.playerTurn90CCWIndex = 0x336;
  2046. c.playerRunIndex = 0x338;
  2047. c.updateRequired = true;
  2048. c.appearanceUpdateRequired = true;
  2049. }
  2050. },
  2051. UPDATE(owner()) {
  2052. @Override
  2053. public void execute(Player c, String input) {
  2054. int seconds = Integer.parseInt(input);
  2055. if (seconds < 15) {
  2056. c.sendMessage("The timer cannot be lower than 15 seconds so other operations can be sorted.");
  2057. seconds = 15;
  2058. }
  2059. PlayerHandler.updateSeconds = seconds;
  2060. PlayerHandler.updateAnnounced = false;
  2061. PlayerHandler.updateRunning = true;
  2062. PlayerHandler.updateStartTime = System.currentTimeMillis();
  2063. for (Player player : PlayerHandler.players) {
  2064. if (player == null) {
  2065. continue;
  2066. }
  2067. Player client = player;
  2068. if (client.getPA().viewingOtherBank) {
  2069. client.getPA().resetOtherBank();
  2070. client.sendMessage("An update is now occuring, you cannot view banks.");
  2071. }
  2072. DuelSession duelSession = (DuelSession) Server.getMultiplayerSessionListener().getMultiplayerSession(client, MultiplayerSessionType.DUEL);
  2073. if (Objects.nonNull(duelSession)) {
  2074. if (duelSession.getStage().getStage() == MultiplayerSessionStage.FURTHER_INTERACTION) {
  2075. if (!duelSession.getWinner().isPresent()) {
  2076. duelSession.finish(MultiplayerSessionFinalizeType.WITHDRAW_ITEMS);
  2077. duelSession.getPlayers().forEach(p -> {
  2078. p.sendMessage("The duel has been cancelled by the server because of an update.");
  2079. duelSession.moveAndClearAttributes(p);
  2080. });
  2081. }
  2082. } else if (duelSession.getStage().getStage() < MultiplayerSessionStage.FURTHER_INTERACTION) {
  2083. duelSession.finish(MultiplayerSessionFinalizeType.WITHDRAW_ITEMS);
  2084. duelSession.getPlayers().forEach(p -> {
  2085. p.sendMessage("The duel has been cancelled by the server because of an update.");
  2086. duelSession.moveAndClearAttributes(p);
  2087. });
  2088. }
  2089. }
  2090. }
  2091. }
  2092. },
  2093. VENG(owner()) {
  2094. @Override
  2095. public void execute(Player c, String input) {
  2096. c.sendMessage("This command is not available at this time.");
  2097. }
  2098. },
  2099. WILD(owner()) {
  2100. @Override
  2101. public void execute(Player c, String input) {
  2102. c.sendMessage("inWilderness: " + (c.getY() == 3523 ? true : false));
  2103. c.sendMessage("loc=[absX: " + c.getX() + " absY:" + c.getY() + "]");
  2104. c.sendMessage("bh_active: " + Config.BOUNTY_HUNTER_ACTIVE);
  2105. }
  2106. },
  2107.  
  2108. ;
  2109.  
  2110. public String[] additional;
  2111. public Predicate<Player> predicate;
  2112.  
  2113. private Commands(String ... additional) {
  2114. this(all(), additional);
  2115. }
  2116.  
  2117.  
  2118. private Commands(Predicate<Player> rights, String ... additional) {
  2119. this.additional = additional;
  2120. this.predicate = rights;
  2121. }
  2122.  
  2123. public abstract void execute(Player c, String input);
  2124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement