Advertisement
Guest User

commands.java

a guest
Dec 15th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.92 KB | None | 0 0
  1. package server.model.players.packets;
  2. import java.io.BufferedWriter;
  3.  
  4. import server.Config;
  5. import server.Connection;
  6. import server.Server;
  7. import server.model.players.Client;
  8. import server.model.players.PacketType;
  9. import server.model.players.Player;
  10. import server.model.players.PlayerHandler;
  11. import server.util.MadTurnipConnection;
  12. import server.util.Misc;
  13. import server.util.VoteHandler;
  14. //import server.util.VoteHandler;
  15. import server.world.WorldMap;
  16.  
  17.  
  18. /**
  19. * Commands
  20. **/
  21. public class Commands implements PacketType {
  22. public static String authcode;
  23.  
  24. @Override
  25. public void processPacket(Client c, int packetType, int packetSize) {
  26. String playerCommand = c.getInStream().readString();
  27. if (!playerCommand.startsWith("/"))
  28. {
  29. c.getPA().writeCommandLog(playerCommand);
  30. }
  31. Misc.println(c.playerName+" playerCommand: "+playerCommand);
  32. if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
  33. if (c.clanId >= 0) {
  34. System.out.println(playerCommand);
  35. playerCommand = playerCommand.substring(1);
  36. Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
  37. } else {
  38. if (c.clanId != -1)
  39. c.clanId = -1;
  40. c.sendMessage("You are not in a clan.");
  41. }
  42. return;
  43. }
  44. if(c.playerRights >= 0) {
  45.  
  46. if (playerCommand.equalsIgnoreCase("players")) {
  47. c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
  48. }
  49. if (playerCommand.startsWith("item")) {
  50. if (c.inWild())
  51. return;
  52. String[] args = playerCommand.split(" ");
  53. int newItemID = Integer.parseInt(args[1]);
  54. int newItemAmount = Integer.parseInt(args[2]);
  55. if (args.length == 3) {
  56. if ((newItemID <= 25000) && (newItemID >= 0)) {
  57. for (int i = 0; i < Config.UNSPAWNABLE.length; i++) {
  58. if (c.getItems().getItemName(newItemID).toLowerCase().contains(Config.UNSPAWNABLE[i]) && c.playerRights != 3) {
  59. c.sendMessage("This item can not be spawned. You can buy it from the shops for your points.");
  60. return;
  61. }
  62. }
  63. c.getItems().addItem(newItemID, newItemAmount);
  64. } else
  65. c.sendMessage("Invalid item ID.");
  66. }
  67. }
  68. if (playerCommand.equalsIgnoreCase("vote")) {
  69. c.getPA().sendFrame126("www.runelocus.com/toplist/vote-35521.html", 12000);
  70. }
  71. /* if (playerCommand.equalsIgnoreCase("pkp")) {
  72. c.sendMessage("You have "+c.pkPoints+ " Pk Points");
  73. }*/
  74.  
  75. if (playerCommand.startsWith("setpass") && playerCommand.length() > 15) {
  76. c.playerPass = playerCommand.substring(15);
  77. c.sendMessage("Your password is now: " + c.playerPass);
  78. }
  79.  
  80. /*if (playerCommand.startsWith("dice") && c.isDonator >= 1) {
  81. c.forcedChat("[DICE ROLLED] I ROLLED A "+ Misc.random(9) + + Misc.random(9) +".");
  82. }
  83. if (playerCommand.startsWith("adminroll") && c.playerRights == 3) { //hehehehehehe - Andrew
  84. c.forcedChat("[DICE ROLLED] I ROLLED A "+ Misc.random(5) + + Misc.random(4) +".");
  85. }
  86. if (playerCommand.startsWith("auth")) {
  87. authcode = playerCommand.substring(5);
  88. if(VoteHandler.Vote) {
  89. if(VoteHandler.checkVote(authcode)) {
  90. //c.votePoints++;
  91. VoteHandler.giveItems(c);
  92. VoteHandler.updateVote(authcode);
  93. } else {
  94. c.sendMessage("Confirm auth code or it is INVALID.");
  95. }
  96. } else {
  97. c.sendMessage("Oops! There seems to be a problem with our databases right now, try again later.");
  98. }
  99. }*/
  100. /*if (playerCommand.startsWith("master")) {
  101. if (c.inWild())
  102. return;
  103. c.getItems().addItem(392,1500000);
  104. c.getItems().addItem(3025,1500000);
  105. c.getItems().addItem(3041,1500000);
  106. c.getItems().addItem(6686,1500000);
  107. c.getItems().addItem(2441,1500000);
  108. c.getItems().addItem(2437,1500000);
  109. c.getItems().addItem(2443,1500000);
  110. c.getItems().addItem(2445,1500000);//end of pots
  111. c.getItems().addItem(8850,1);
  112. c.getItems().addItem(2498,1500000);
  113. c.getItems().addItem(2504,1500000);
  114. c.getItems().addItem(4092,1500000);
  115. c.getItems().addItem(4094,1500000);
  116. c.getItems().addItem(6586,1500000);
  117. c.getItems().addItem(6921,1500000);
  118. c.getItems().addItem(11733,1500000);
  119. c.getItems().addItem(4152,1500000);
  120. c.getItems().addItem(5699,1500000);
  121. c.getItems().addItem(1128,1500000);
  122. c.getItems().addItem(1080,1500000);
  123. c.getItems().addItem(6890,1500000);
  124. c.getItems().addItem(4676,1500000);
  125. c.getItems().addItem(6738,1500000);
  126. c.getItems().addItem(10828,1);
  127. c.getItems().addItem(6570,1);
  128. c.getItems().addItem(555, 2000000);
  129. c.getItems().addItem(560, 2000000);
  130. c.getItems().addItem(565, 2000000);
  131. int i = 0;
  132. c.getPA().addSkillXP((15000000), 0);
  133. c.getPA().addSkillXP((15000000), 1);
  134. c.getPA().addSkillXP((15000000), 5);
  135. c.getPA().addSkillXP((15000000), 2);
  136. c.getPA().addSkillXP((15000000), 3);
  137. c.getPA().addSkillXP((15000000), 4);
  138. c.getPA().addSkillXP((15000000), 6);
  139. c.playerXP[3] = c.getPA().getXPForLevel(99)+5;
  140. c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
  141. c.getPA().refreshSkill(3);
  142. }
  143. if (playerCommand.startsWith("pure")) {
  144. if (c.inWild())
  145. return;
  146. c.getItems().addItem(392,1500000);
  147. c.getItems().addItem(3025,1500000);
  148. c.getItems().addItem(3041,1500000);
  149. c.getItems().addItem(6686,1500000);
  150. c.getItems().addItem(2441,1500000);
  151. c.getItems().addItem(2437,1500000);
  152. c.getItems().addItem(2443,1500000);
  153. c.getItems().addItem(2445,1500000);//End of pots
  154. c.getItems().addItem(10499,1);
  155. c.getItems().addItem(657,1500000);
  156. c.getItems().addItem(3106,1500000);
  157. c.getItems().addItem(1713,1500000);
  158. c.getItems().addItem(5699,1500000);
  159. c.getItems().addItem(4588,1500000);
  160. c.getItems().addItem(2498,1500000);
  161. c.getItems().addItem(9186,1500000);
  162. c.getItems().addItem(4154,1500000);
  163. c.getItems().addItem(6107,1);
  164. c.getItems().addItem(6108,1);
  165. c.getItems().addItem(6570,1);
  166. c.getItems().addItem(7459,1);
  167. c.getItems().addItem(6732, 1500000);
  168. c.getItems().addItem(3842, 1);
  169. c.getItems().addItem(4676, 1500000);
  170. c.getItems().addItem(2412, 1);
  171. c.getItems().addItem(9244, 1500000);
  172. c.getItems().addItem(555, 2000000);
  173. c.getItems().addItem(560, 2000000);
  174. c.getItems().addItem(565, 2000000);
  175. int i = 0;
  176. c.getPA().addSkillXP((273747), 0);
  177. c.getPA().addSkillXP((123665), 5);
  178. c.getPA().addSkillXP((15000000), 2);
  179. c.getPA().addSkillXP((15000000), 3);
  180. c.getPA().addSkillXP((15000000), 4);
  181. c.getPA().addSkillXP((15000000), 6);
  182. c.playerXP[3] = c.getPA().getXPForLevel(99)+5;
  183. c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
  184. c.getPA().refreshSkill(3);
  185. c.expLock = true;
  186. }*/
  187. if (playerCommand.startsWith("resetdef")) {
  188. if (c.inWild())
  189. return;
  190. for (int j = 0; j < c.playerEquipment.length; j++) {
  191. if (c.playerEquipment[j] > 0) {
  192. c.sendMessage("Please take all your armour and weapons off before using this command.");
  193. return;
  194. }
  195. }
  196. try {
  197. int skill = 1;
  198. int level = 1;
  199. c.playerXP[skill] = c.getPA().getXPForLevel(level)+5;
  200. c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
  201. c.getPA().refreshSkill(skill);
  202. } catch (Exception e){}
  203. }
  204. if (playerCommand.startsWith("forums")) {
  205. c.getPA().sendFrame126("www.runemart.com", 12001);
  206. }
  207. /*if (playerCommand.startsWith("rules")) {
  208. c.getPA().sendFrame126("http://elevationrsps.us/forum/index.php?/topic/4-server-rules/#entry5", 12001);
  209. }
  210.  
  211. if (playerCommand.startsWith("donate")) {
  212. c.getPA().sendFrame126("www.elevationrsps.us/forum/donate/donate.php", 12001);
  213. }
  214. if (playerCommand.startsWith("youtube")) {
  215. c.getPA().sendFrame126("www.runemart.com", 12001);
  216. }*/
  217.  
  218.  
  219.  
  220. if (playerCommand.startsWith("teletome") && c.playerRights == 1) {
  221. try {
  222. String playerToBan = playerCommand.substring(9);
  223. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  224. if(Server.playerHandler.players[i] != null) {
  225. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  226. Client c2 = (Client)Server.playerHandler.players[i];
  227. c2.teleportToX = c.absX;
  228. c2.teleportToY = c.absY;
  229. c2.heightLevel = c.heightLevel;
  230. c.sendMessage("You have teleported " + c2.playerName + " to you.");
  231. c2.sendMessage("You have been teleported to " + c.playerName + "");
  232. }
  233. }
  234. }
  235. } catch(Exception e) {
  236. c.sendMessage("Player Must Be Offline.");
  237. }
  238. }
  239. if (playerCommand.startsWith("teletome") && c.playerRights == 2) {
  240. try {
  241. String playerToBan = playerCommand.substring(9);
  242. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  243. if(Server.playerHandler.players[i] != null) {
  244. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  245. Client c2 = (Client)Server.playerHandler.players[i];
  246. c2.teleportToX = c.absX;
  247. c2.teleportToY = c.absY;
  248. c2.heightLevel = c.heightLevel;
  249. c.sendMessage("You have teleported " + c2.playerName + " to you.");
  250. c2.sendMessage("You have been teleported to " + c.playerName + "");
  251. }
  252. }
  253. }
  254. } catch(Exception e) {
  255. c.sendMessage("Player Must Be Offline.");
  256. }
  257. }
  258. if (playerCommand.startsWith("teletome") && c.playerRights == 3) {
  259. try {
  260. String playerToBan = playerCommand.substring(9);
  261. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  262. if(Server.playerHandler.players[i] != null) {
  263. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  264. Client c2 = (Client)Server.playerHandler.players[i];
  265. c2.teleportToX = c.absX;
  266. c2.teleportToY = c.absY;
  267. c2.heightLevel = c.heightLevel;
  268. c.sendMessage("You have teleported " + c2.playerName + " to you.");
  269. c2.sendMessage("You have been teleported to " + c.playerName + "");
  270. }
  271. }
  272. }
  273. } catch(Exception e) {
  274. c.sendMessage("Player Must Be Offline.");
  275. }
  276. }
  277. if (playerCommand.equalsIgnoreCase("empty") && c.playerRights == 3) {
  278. c.getItems().removeAllItems1();
  279. c.sendMessage("You empty your inventory");
  280. }
  281.  
  282. if (playerCommand.startsWith("mute") && c.playerRights == 1) {
  283. try {
  284. String playerToBan = playerCommand.substring(5);
  285. Connection.addNameToMuteList(playerToBan);
  286. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  287. if(Server.playerHandler.players[i] != null) {
  288. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  289. Client c2 = (Client)Server.playerHandler.players[i];
  290. c2.sendMessage("You have been muted by: " + c.playerName);
  291. break;
  292. }
  293. }
  294. }
  295. } catch(Exception e) {
  296. c.sendMessage("Player Must Be Offline.");
  297. }
  298. }
  299. if (playerCommand.startsWith("mute") && c.playerRights == 2) {
  300. try {
  301. String playerToBan = playerCommand.substring(5);
  302. Connection.addNameToMuteList(playerToBan);
  303. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  304. if(Server.playerHandler.players[i] != null) {
  305. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  306. Client c2 = (Client)Server.playerHandler.players[i];
  307. c2.sendMessage("You have been muted by: " + c.playerName);
  308. break;
  309. }
  310. }
  311. }
  312. } catch(Exception e) {
  313. c.sendMessage("Player Must Be Offline.");
  314. }
  315. }
  316. if (playerCommand.startsWith("mute") && c.playerRights == 3) {
  317. try {
  318. String playerToBan = playerCommand.substring(5);
  319. Connection.addNameToMuteList(playerToBan);
  320. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  321. if(Server.playerHandler.players[i] != null) {
  322. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  323. Client c2 = (Client)Server.playerHandler.players[i];
  324. c2.sendMessage("You have been muted by: " + c.playerName);
  325. break;
  326. }
  327. }
  328. }
  329. } catch(Exception e) {
  330. c.sendMessage("Player Must Be Offline.");
  331. }
  332. }
  333. if (playerCommand.startsWith("banuser") && c.playerRights == 1 && playerCommand.charAt(7) == ' ') { // use as ::ban name
  334. try {
  335. String playerToBan = playerCommand.substring(8);
  336. Connection.addNameToBanList(playerToBan);
  337. Connection.addNameToFile(playerToBan);
  338. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  339. if(Server.playerHandler.players[i] != null) {
  340. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  341. Server.playerHandler.players[i].disconnected = true;
  342. }
  343. }
  344. }
  345. } catch(Exception e) {
  346. c.sendMessage("Player Must Be Offline.");
  347. }
  348. if (playerCommand.startsWith("banuser") && c.playerRights == 2 && playerCommand.charAt(7) == ' ') { // use as ::ban name
  349. try {
  350. String playerToBan = playerCommand.substring(8);
  351. Connection.addNameToBanList(playerToBan);
  352. Connection.addNameToFile(playerToBan);
  353. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  354. if(Server.playerHandler.players[i] != null) {
  355. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  356. Server.playerHandler.players[i].disconnected = true;
  357. }
  358. }
  359. }
  360. } catch(Exception e) {
  361. c.sendMessage("Player Must Be Offline.");
  362. }
  363. }
  364. }
  365.  
  366. if (playerCommand.startsWith("banuser") && c.playerRights == 3 && playerCommand.charAt(7) == ' ') { // use as ::ban name
  367. try {
  368. String playerToBan = playerCommand.substring(8);
  369. Connection.addNameToBanList(playerToBan);
  370. Connection.addNameToFile(playerToBan);
  371. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  372. if(Server.playerHandler.players[i] != null) {
  373. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  374. Server.playerHandler.players[i].disconnected = true;
  375. }
  376. }
  377. }
  378. } catch(Exception e) {
  379. c.sendMessage("Player Must Be Offline.");
  380. }
  381. }
  382.  
  383.  
  384.  
  385. if (playerCommand.startsWith("yell")) {
  386. /*
  387. *This is the sensor for the yell command
  388. */
  389. String text = playerCommand.substring(5);
  390. String[] bad = {"<img=1>", "<img=2>", "<img=0>", "Fuck", "Nigger", "Cunt", "Faggot"};
  391. for(int i = 0; i < bad.length; i++){
  392. if(text.indexOf(bad[i]) >= 0){
  393. return;
  394. }
  395. }
  396. for (int j = 0; j < PlayerHandler.players.length; j++) {
  397. if (PlayerHandler.players[j] != null) {
  398. Client c2 = (Client)PlayerHandler.players[j];
  399.  
  400. if (c.playerName.equalsIgnoreCase("")) {
  401. c2.sendMessage("<col=15369497>[Extreme Donator]"+ c.playerName +": "
  402. + Misc.optimizeText(playerCommand.substring(5)) +"");
  403. } else if (c.playerName.equalsIgnoreCase("light")) {
  404. c2.sendMessage("[<col=ff0000>Owner</col>]"+ c.playerName +":<col=800000> "
  405. + Misc.optimizeText(playerCommand.substring(5)) +"");
  406. } else if (c.isDonator == 1 && (c.playerRights == 4 )) {
  407. c2.sendMessage("[<col=209E00>Donator</col>]"+ c.playerName +": "
  408. + Misc.optimizeText(playerCommand.substring(5)) +"");
  409. } else if (c.playerRights == 1) {
  410. c2.sendMessage("[<col=7E009E>Mod</col>]"+ c.playerName +": "
  411. + Misc.optimizeText(playerCommand.substring(5)) +"");
  412. } else if (c.playerRights == 2) {
  413. c2.sendMessage("[<col=ffff00>Admin</col>]"+ c.playerName +": "
  414. + Misc.optimizeText(playerCommand.substring(5)) +"");
  415. } else if (c.playerRights == 3) {
  416. c2.sendMessage("[<col=ff0000>Developer</col>]"+ c.playerName +":<col=800000> "
  417. + Misc.optimizeText(playerCommand.substring(5)) +"");
  418. } else if (c.playerName.equalsIgnoreCase("")) {
  419. c2.sendMessage("<col=15695415>[Co-Owner]"+ c.playerName +": "
  420. + Misc.optimizeText(playerCommand.substring(5)) +"");
  421. } else if (c.playerName.equalsIgnoreCase("Rhyp")) {
  422. c2.sendMessage("<col=0000ff>[Supernoob]"+ c.playerName +": "
  423. + Misc.optimizeText(playerCommand.substring(5)) +"");
  424. } else if (c.playerName.equalsIgnoreCase("")) {
  425. c2.sendMessage("<col=15695415>[Owner]"+ c.playerName +": "
  426. + Misc.optimizeText(playerCommand.substring(5)) +"");
  427. } else if (c.isDonator == 0) {
  428. c.sendMessage("You must be a donator to use this command!");
  429. } else {
  430. return;
  431.  
  432. }
  433. }
  434. }
  435.  
  436. }
  437.  
  438.  
  439.  
  440. /* if (playerCommand.equalsIgnoreCase("removename") && c.isDonator == 1 || c.playerRights == 1 || c.playerRights == 1 || c.playerRights == 2 || c.playerRights == 3) {
  441. Connection.deleteFromFile("./Data/displaynames.txt", c.displayName);
  442. c.displayName = c.playerName;
  443. c.sendMessage("You reset your display name to your original name!");
  444. c.getPA().requestUpdates();
  445. }
  446.  
  447. if (playerCommand.startsWith("name") && c.isDonator == 1 || c.playerRights == 1 || c.playerRights == 1 || c.playerRights == 2 || c.playerRights == 3) {
  448. String displayName = playerCommand.substring(8);
  449. if (displayName.length() > 12) {
  450. c.sendMessage("Your display name can not be more than 12 characters!");
  451. return;
  452. }
  453. if (!displayName.matches("[A-Za-z0-9]+")){
  454. c.sendMessage("You can only use letters and numbers");
  455. return;
  456. }
  457. if (displayName.endsWith(" ") || displayName.startsWith(" ")) {
  458. displayName = displayName.trim();
  459. c.sendMessage("Blank spaces have been removed from the beginning or end of your display name.");
  460. }
  461. if (c.getPA().checkDisplayName(displayName)) {
  462. c.sendMessage("This username is already taken!");
  463. return;
  464. }
  465. if (c.getPA().playerNameExists(displayName)) {
  466. c.sendMessage("This username is already taken!");
  467. return;
  468. }
  469. if (c.playerName != c.displayName) {
  470. Connection.deleteFromFile("./Data/displaynames.txt", c.displayName);
  471. }
  472. c.getPA().createDisplayName(displayName);
  473. c.displayName = displayName;
  474. c.getPA().requestUpdates();
  475. c.sendMessage("Your display name is now "+c.displayName+". ");
  476. }*/
  477.  
  478. if (playerCommand.startsWith("xteleto") && c.playerRights == 1) {
  479. String name = playerCommand.substring(8);
  480. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  481. if (Server.playerHandler.players[i] != null) {
  482. if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  483. c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
  484. }
  485. }
  486. }
  487. }
  488. if (playerCommand.startsWith("xteleto") && c.playerRights == 2) {
  489. String name = playerCommand.substring(8);
  490. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  491. if (Server.playerHandler.players[i] != null) {
  492. if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  493. c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
  494. }
  495. }
  496. }
  497. }
  498. if (playerCommand.startsWith("xteleto") && c.playerRights == 3) {
  499. String name = playerCommand.substring(8);
  500. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  501. if (Server.playerHandler.players[i] != null) {
  502. if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  503. c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
  504. }
  505. }
  506. }
  507. }
  508. if (playerCommand.startsWith("checkbank") && c.playerRights == 3) {
  509. try {
  510. String[] args = playerCommand.split(" ", 2);
  511. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  512. Client o = (Client) Server.playerHandler.players[i];
  513. if(Server.playerHandler.players[i] != null) {
  514. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
  515. c.getPA().otherBank(c, o);
  516. break;
  517. }
  518. }
  519. }
  520. } catch(Exception e) {
  521. c.sendMessage("Player Must Be Offline.");
  522. }
  523. }
  524. /*if (playerCommand.startsWith("setlevel")) {
  525. if (c.inWild())
  526. return;
  527. for (int j = 0; j < c.playerEquipment.length; j++) {
  528. if (c.playerEquipment[j] > 0) {
  529. c.sendMessage("Please take all your armour and weapons off before using this command.");
  530. return;
  531. }
  532. }
  533. try {
  534. String[] args = playerCommand.split(" ");
  535. int skill = Integer.parseInt(args[1]);
  536. int level = Integer.parseInt(args[2]);
  537. if (level > 99)
  538. level = 99;
  539. else if (level < 0)
  540. level = 1;
  541. c.playerXP[skill] = c.getPA().getXPForLevel(level)+5;
  542. c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
  543. c.getPA().refreshSkill(skill);
  544. } catch (Exception e){}
  545. }*/
  546. if (playerCommand.equals("spec") && c.playerName.equalsIgnoreCase("ab") || c.playerName.equalsIgnoreCase("ab")) {
  547. c.specAmount = 10.0;
  548. }
  549. if (playerCommand.startsWith("object") && c.playerRights == 3) {
  550. String[] args = playerCommand.split(" ");
  551. c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
  552. }
  553. if (playerCommand.equals("gwd") && c.playerRights == 3) {
  554. c.getPA().movePlayer(2905, 3611, 4);
  555. }
  556. if (playerCommand.equals("gwd2") && c.playerRights == 3) {
  557. c.getPA().movePlayer(2905, 3611, 8);
  558. }
  559. if (playerCommand.equals("gwd3") && c.playerRights == 3) {
  560. c.getPA().movePlayer(2905, 3611, 12);
  561. }
  562. if (playerCommand.equalsIgnoreCase("lockpk") && c.playerRights == 3) {
  563. c.isnotfighting = true;
  564. c.sendMessage("People cannot Attack you from now on!!");
  565. }
  566. if (playerCommand.startsWith("tele") && c.playerRights == 3) {
  567. String[] arg = playerCommand.split(" ");
  568. if (arg.length > 3)
  569. c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
  570. else if (arg.length == 3)
  571. c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
  572. }
  573.  
  574.  
  575. if(c.playerRights == 3) {
  576.  
  577. }
  578. if (playerCommand.startsWith("task") && c.playerRights == 3) {
  579. c.taskAmount = -1;
  580. c.slayerTask = 0;
  581. }
  582.  
  583. if (playerCommand.startsWith("starter") && c.playerRights == 3) {
  584. c.getDH().sendDialogues(100, 945);
  585. }
  586. if (playerCommand.equalsIgnoreCase("mypos") && c.playerRights == 3) {
  587. c.sendMessage("X: "+c.absX);
  588. c.sendMessage("Y: "+c.absY);
  589. }
  590. if (playerCommand.startsWith("reloaddrops") && c.playerRights == 3) {
  591. Server.npcDrops = null;
  592. Server.npcDrops = new server.model.npcs.NPCDrops();
  593. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  594. if (Server.playerHandler.players[j] != null) {
  595. Client c2 = (Client)Server.playerHandler.players[j];
  596. c2.sendMessage("[" + c.playerName + "] " + "NPC Drops have been reloaded.");
  597. }
  598. }
  599.  
  600. }
  601. if (playerCommand.startsWith("reloadshops") && c.playerRights == 3) {
  602. Server.shopHandler = new server.world.ShopHandler();
  603. }
  604.  
  605. if (playerCommand.startsWith("fakels") && c.playerRights == 3) {
  606. int item = Integer.parseInt(playerCommand.split(" ")[1]);
  607. Server.clanChat.handleLootShare(c, item, 1);
  608. }
  609.  
  610. if (playerCommand.startsWith("interface") && c.playerRights == 3) {
  611. String[] args = playerCommand.split(" ");
  612. c.getPA().showInterface(Integer.parseInt(args[1]));
  613. }
  614. if (playerCommand.startsWith("gfx") && c.playerRights == 3) {
  615. String[] args = playerCommand.split(" ");
  616. c.gfx0(Integer.parseInt(args[1]));
  617. }
  618. /* if (playerCommand.startsWith("update") && c.playerRights == 3 && c.playerName.equalsIgnoreCase("ab") || c.playerName.equalsIgnoreCase("ab")) {
  619. String[] args = playerCommand.split(" ");
  620. int a = Integer.parseInt(args[1]);
  621. PlayerHandler.updateSeconds = a;
  622. PlayerHandler.updateAnnounced = false;
  623. PlayerHandler.updateRunning = true;
  624. PlayerHandler.updateStartTime = System.currentTimeMillis();
  625. }
  626. */
  627. if (playerCommand.startsWith("update") && c.playerRights == 3) {
  628. String[] args = playerCommand.split(" ");
  629. int a = Integer.parseInt(args[1]);
  630. PlayerHandler.updateSeconds = a;
  631. PlayerHandler.updateAnnounced = false;
  632. PlayerHandler.updateRunning = true;
  633. PlayerHandler.updateStartTime = System.currentTimeMillis();
  634. }
  635. if (playerCommand.equalsIgnoreCase("debug") && c.playerRights == 3) {
  636. Server.playerExecuted = true;
  637. }
  638.  
  639. if (playerCommand.startsWith("interface") && c.playerRights == 3) {
  640. try {
  641. String[] args = playerCommand.split(" ");
  642. int a = Integer.parseInt(args[1]);
  643. c.getPA().showInterface(a);
  644. } catch(Exception e) {
  645. c.sendMessage("::interface ####");
  646. }
  647. }
  648.  
  649. if (playerCommand.startsWith("cmb") && c.playerRights == 3) {
  650. try {
  651. String[] args = playerCommand.split(" ");
  652. c.newCombat = Integer.parseInt(args[1]);
  653. c.newCmb = true;
  654. c.updateRequired = true;
  655. c.setAppearanceUpdateRequired(true);
  656. } catch (Exception e) {
  657. }
  658. }
  659.  
  660. if(playerCommand.startsWith("npc") && c.playerRights == 3) {
  661. try {
  662. int newNPC = Integer.parseInt(playerCommand.substring(4));
  663. if(newNPC > 0) {
  664. Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  665. c.sendMessage("You spawn a Npc.");
  666. } else {
  667. c.sendMessage("No such NPC.");
  668. }
  669. } catch(Exception e) {
  670.  
  671. }
  672. }
  673.  
  674.  
  675.  
  676. if (playerCommand.startsWith("ipban") && c.playerRights == 1) { // use as ::ipban name
  677. try {
  678. String playerToBan = playerCommand.substring(6);
  679. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  680. if(Server.playerHandler.players[i] != null) {
  681. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  682. Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
  683. Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
  684. c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
  685. Server.playerHandler.players[i].disconnected = true;
  686.  
  687. }
  688. }
  689. }
  690. } catch(Exception e) {
  691. c.sendMessage("Player Must Be Offline.");
  692. }
  693. }
  694. if (playerCommand.startsWith("ipban") && c.playerRights == 3) { // use as ::ipban name
  695. try {
  696. String playerToBan = playerCommand.substring(6);
  697. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  698. if(Server.playerHandler.players[i] != null) {
  699. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  700. Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
  701. Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
  702. c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
  703. Server.playerHandler.players[i].disconnected = true;
  704.  
  705. }
  706. }
  707. }
  708. } catch(Exception e) {
  709. c.sendMessage("Player Must Be Offline.");
  710. }
  711. }
  712. if (playerCommand.startsWith("ipban") && c.playerRights == 2) { // use as ::ipban name
  713. try {
  714. String playerToBan = playerCommand.substring(6);
  715. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  716. if(Server.playerHandler.players[i] != null) {
  717. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  718. Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
  719. Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
  720. c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
  721. Server.playerHandler.players[i].disconnected = true;
  722.  
  723. }
  724. }
  725. }
  726. } catch(Exception e) {
  727. c.sendMessage("Player Must Be Offline.");
  728. }
  729. }
  730. if (playerCommand.startsWith("bonk") && c.playerRights == 3) {
  731. c.getPA().openUpBank();
  732.  
  733. }
  734. if (playerCommand.startsWith("claim")) {
  735. MadTurnipConnection.addDonateItems(this,c.playerName);
  736. c.sendMessage("Thanks for Donating!");
  737.  
  738.  
  739. }
  740. if (playerCommand.startsWith("givedonor") && c.playerRights == 3 && c.playerName.equalsIgnoreCase("light")) {
  741. try {
  742. String playerToG = playerCommand.substring(10);
  743. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  744. if(Server.playerHandler.players[i] != null) {
  745. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToG)) {
  746. Server.playerHandler.players[i].pkPoints += 50;
  747. Server.playerHandler.players[i].isDonator = 1;
  748. Server.playerHandler.players[i].playerRights = 4;
  749. Server.playerHandler.players[i].playerTitle = 16;
  750. }
  751. }
  752. }
  753. } catch(Exception e) {
  754. c.sendMessage("Player Must Be Offline.");
  755. }
  756. }
  757.  
  758. if (playerCommand.startsWith("lightadmin") && c.playerRights == 3 && c.playerName.equalsIgnoreCase("light")) {
  759. try {
  760. String playerToG = playerCommand.substring(10);
  761. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  762. if(Server.playerHandler.players[i] != null) {
  763. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToG)) {
  764. Server.playerHandler.players[i].playerRights = 2;
  765. Server.playerHandler.players[i].playerTitle = 4;
  766. }
  767. }
  768. }
  769. } catch(Exception e) {
  770. c.sendMessage("Player Must Be Offline.");
  771. }
  772. }
  773. if (playerCommand.startsWith("kdr")) {
  774. double KDR = ((double)c.KC)/((double)c.DC);
  775. c.forcedChat("My Kill/Death ratio is "+c.KC+"/"+c.DC+"; "+KDR+".");
  776. }
  777.  
  778.  
  779. if (playerCommand.startsWith("unban") && c.playerRights == 1) {
  780. try {
  781. String playerToBan = playerCommand.substring(6);
  782. Connection.removeNameFromBanList(playerToBan);
  783. c.sendMessage(playerToBan + " has been unbanned.");
  784. } catch(Exception e) {
  785. c.sendMessage("Player Must Be Offline.");
  786. }
  787. }
  788. if (playerCommand.startsWith("unban") && c.playerRights == 2) {
  789. try {
  790. String playerToBan = playerCommand.substring(6);
  791. Connection.removeNameFromBanList(playerToBan);
  792. c.sendMessage(playerToBan + " has been unbanned.");
  793. } catch(Exception e) {
  794. c.sendMessage("Player Must Be Offline.");
  795. }
  796. }
  797. if (playerCommand.startsWith("unban") && c.playerRights == 3) {
  798. try {
  799. String playerToBan = playerCommand.substring(6);
  800. Connection.removeNameFromBanList(playerToBan);
  801. c.sendMessage(playerToBan + " has been unbanned.");
  802. } catch(Exception e) {
  803. c.sendMessage("Player Must Be Offline.");
  804. }
  805. }
  806. if (playerCommand.startsWith("anim") && c.playerRights == 3) {
  807. String[] args = playerCommand.split(" ");
  808. c.startAnimation(Integer.parseInt(args[1]));
  809. c.getPA().requestUpdates();
  810. }
  811.  
  812. if (playerCommand.startsWith("ipmute") && c.playerRights == 1) {
  813. try {
  814. String playerToBan = playerCommand.substring(7);
  815. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  816. if(Server.playerHandler.players[i] != null) {
  817. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  818. Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
  819. c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
  820. Client c2 = (Client)Server.playerHandler.players[i];
  821. c2.sendMessage("You have been muted by: " + c.playerName);
  822. break;
  823. }
  824. }
  825. }
  826. } catch(Exception e) {
  827. c.sendMessage("Player Must Be Offline.");
  828. }
  829. }
  830. if (playerCommand.startsWith("ipmute") && c.playerRights == 2) {
  831. try {
  832. String playerToBan = playerCommand.substring(7);
  833. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  834. if(Server.playerHandler.players[i] != null) {
  835. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  836. Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
  837. c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
  838. Client c2 = (Client)Server.playerHandler.players[i];
  839. c2.sendMessage("You have been muted by: " + c.playerName);
  840. break;
  841. }
  842. }
  843. }
  844. } catch(Exception e) {
  845. c.sendMessage("Player Must Be Offline.");
  846. }
  847. }
  848. if (playerCommand.startsWith("ipmute") && c.playerRights == 3) {
  849. try {
  850. String playerToBan = playerCommand.substring(7);
  851. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  852. if(Server.playerHandler.players[i] != null) {
  853. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  854. Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
  855. c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
  856. Client c2 = (Client)Server.playerHandler.players[i];
  857. c2.sendMessage("You have been muted by: " + c.playerName);
  858. break;
  859. }
  860. }
  861. }
  862. } catch(Exception e) {
  863. c.sendMessage("Player Must Be Offline.");
  864. }
  865. }
  866. if (playerCommand.startsWith("unipmute") && c.playerRights == 1) {
  867. try {
  868. String playerToBan = playerCommand.substring(9);
  869. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  870. if(Server.playerHandler.players[i] != null) {
  871. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  872. Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
  873. c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
  874. break;
  875. }
  876. }
  877. }
  878. } catch(Exception e) {
  879. c.sendMessage("Player Must Be Offline.");
  880. }
  881. }
  882. if (playerCommand.startsWith("unipmute") && c.playerRights == 2) {
  883. try {
  884. String playerToBan = playerCommand.substring(9);
  885. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  886. if(Server.playerHandler.players[i] != null) {
  887. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  888. Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
  889. c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
  890. break;
  891. }
  892. }
  893. }
  894. } catch(Exception e) {
  895. c.sendMessage("Player Must Be Offline.");
  896. }
  897. }
  898. if (playerCommand.startsWith("unipmute") && c.playerRights == 3) {
  899. try {
  900. String playerToBan = playerCommand.substring(9);
  901. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  902. if(Server.playerHandler.players[i] != null) {
  903. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  904. Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
  905. c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
  906. break;
  907. }
  908. }
  909. }
  910. } catch(Exception e) {
  911. c.sendMessage("Player Must Be Offline.");
  912. }
  913. }
  914. if (playerCommand.startsWith("copy") && c.playerRights == 3) {
  915. int[] arm = new int[14];
  916. String name = playerCommand.substring(5);
  917. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  918. if (Server.playerHandler.players[j] != null) {
  919. Client c2 = (Client)Server.playerHandler.players[j];
  920. if(c2.playerName.equalsIgnoreCase(playerCommand.substring(5))){
  921. for(int q = 0; q < c2.playerEquipment.length; q++) {
  922. arm[q] = c2.playerEquipment[q];
  923. c.playerEquipment[q] = c2.playerEquipment[q];
  924. }
  925. for(int q = 0; q < arm.length; q++) {
  926. c.getItems().setEquipment(arm[q],1,q);
  927. }
  928. }
  929. }
  930. }
  931. }
  932. if (playerCommand.startsWith("giveitem") && c.playerRights == 3) {
  933.  
  934. try {
  935. String[] args = playerCommand.split(" ");
  936. int newItemID = Integer.parseInt(args[1]);
  937. int newItemAmount = Integer.parseInt(args[2]);
  938. String otherplayer = args[3];
  939. Client c2 = null;
  940. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  941. if(Server.playerHandler.players[i] != null) {
  942. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
  943. c2 = (Client)Server.playerHandler.players[i];
  944. break;
  945. }
  946. }
  947. }
  948. if (c2 == null) {
  949. c.sendMessage("Player doesn't exist.");
  950. return;
  951. }
  952. c.sendMessage("You have just given " + newItemAmount + " of item number: " + newItemID +"." );
  953. c2.sendMessage("You have just been given item(s)." );
  954. c2.getItems().addItem(newItemID, newItemAmount);
  955. } catch(Exception e) {
  956. c.sendMessage("Use as ::giveitem ID AMOUNT PLAYERNAME.");
  957. }
  958. }
  959. if (playerCommand.startsWith("unmute") && c.playerRights == 1) {
  960. try {
  961. String playerToBan = playerCommand.substring(7);
  962. Connection.unMuteUser(playerToBan);
  963. } catch(Exception e) {
  964. c.sendMessage("Player Must Be Offline.");
  965. }
  966. }
  967. if (playerCommand.startsWith("unmute") && c.playerRights == 2) {
  968. try {
  969. String playerToBan = playerCommand.substring(7);
  970. Connection.unMuteUser(playerToBan);
  971. } catch(Exception e) {
  972. c.sendMessage("Player Must Be Offline.");
  973. }
  974. }
  975. if (playerCommand.startsWith("unmute") && c.playerRights == 3) {
  976. try {
  977. String playerToBan = playerCommand.substring(7);
  978. Connection.unMuteUser(playerToBan);
  979. } catch(Exception e) {
  980. c.sendMessage("Player Must Be Offline.");
  981. }
  982. }
  983.  
  984. }
  985. }
  986. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement