Guest User

Untitled

a guest
Dec 4th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.34 KB | None | 0 0
  1. package server.model.players.packets;
  2.  
  3. import server.Config;
  4. import server.Connection;
  5. import server.Server;
  6. import server.model.players.Client;
  7. import server.model.players.PacketType;
  8. import server.model.players.PlayerHandler;
  9. import server.util.Misc;
  10.  
  11.  
  12. import java.io.*;
  13.  
  14. /**
  15. * Commands
  16. **/
  17. public class Commands implements PacketType
  18. {
  19.  
  20.  
  21. @Override
  22. public void processPacket(Client c, int packetType, int packetSize)
  23. {
  24. String playerCommand = c.getInStream().readString();
  25. if (!playerCommand.startsWith("/"))
  26. {
  27. c.getPA().writeCommandLog(playerCommand);
  28. }
  29. if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
  30. if (c.clanId >= 0) {
  31. System.out.println(playerCommand);
  32. playerCommand = playerCommand.substring(1);
  33. Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
  34. } else {
  35. if (c.clanId != -1)
  36. c.clanId = -1;
  37. c.sendMessage("You are not in a clan.");
  38. }
  39. return;
  40. }
  41. if (Config.SERVER_DEBUG)
  42. Misc.println(c.playerName+" playerCommand: "+playerCommand);
  43.  
  44. if (c.playerRights >= 0)
  45. playerCommands(c, playerCommand);
  46. if (c.playerRights == 1 || c.playerRights == 2 || c.playerRights == 3)
  47. moderatorCommands(c, playerCommand);
  48. if (c.playerRights == 2 || c.playerRights == 3)
  49. administratorCommands(c, playerCommand);
  50. if (c.playerRights == 3)
  51. ownerCommands(c, playerCommand);
  52. if (c.playerRights == 4)
  53. DonatorCommands(c, playerCommand);
  54.  
  55. }
  56.  
  57.  
  58. public void playerCommands(Client c, String playerCommand)
  59. {
  60. if (playerCommand.startsWith("yell") && c.isDonator == 1) {
  61. c.sendMessage("Only donators can use this command!");
  62. }
  63.  
  64. if(playerCommand.startsWith("torms") && c.isDonator == 1) { //Voule Command Generator
  65. c.teleportToX = 2717;
  66. c.teleportToY = 9802;
  67. c.sendMessage("they drop,hilts,blades,dragon claws!:)");
  68. }
  69.  
  70. if (playerCommand.equalsIgnoreCase("players")) {
  71. c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
  72. }
  73. if (playerCommand.startsWith("changepassword") && playerCommand.length() > 15) {
  74. c.playerPass = playerCommand.substring(15);
  75. c.sendMessage("Your password is now: " + c.playerPass);
  76. }
  77.  
  78. if (playerCommand.startsWith("smsk")) {
  79. c.startAnimation(8525);
  80. c.gfx0(1515);
  81. }
  82.  
  83. if (playerCommand.startsWith("sit") && c.sit == false) {
  84. if(c.inWild()) {
  85. c.sendMessage("You cannot do this in wildy");
  86. return;
  87. }
  88. c.sit = true;
  89. if(c.playerRights == 1) {
  90. c.startAnimation(4113);
  91. }
  92. if(c.playerRights == 2 || c.playerRights == 3) {
  93. c.startAnimation(4117);
  94. }
  95. if(c.isDonator == 0) {
  96. c.startAnimation(4115);
  97. }
  98. if(c.playerRights == 4) {
  99. c.startAnimation(4116);
  100. }
  101. }
  102.  
  103. if (playerCommand.startsWith("unsit") && c.sit == true) {
  104. if(c.inWild()) {
  105. c.sendMessage("You cannot do this in wildy");
  106. return;
  107. }
  108. c.sit = false;
  109. c.startAnimation(4191);
  110. }
  111.  
  112. if (playerCommand.startsWith("qpsk")) {
  113. c.startAnimation(4945);
  114. c.gfx0(816);
  115. }
  116. if (playerCommand.startsWith("ep") || playerCommand.startsWith("Ep") || playerCommand.startsWith("EP") || playerCommand.startsWith("eP")) {
  117. c.sendMessage("EP: "+ c.earningPotential+"");
  118. }
  119.  
  120. if (playerCommand.startsWith("yell")) {
  121. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  122. if (Server.playerHandler.players[j] != null) {
  123. Client c2 = (Client)Server.playerHandler.players[j];
  124. if (c.playerRights == 0){
  125. c.sendMessage("You must be a donator to use this command!");
  126. }
  127. if (c.playerRights == 1){
  128.  
  129. c2.sendMessage("<shad=4081134>[Mod]</col><img=1>"+ Misc.optimizeText(c.playerName) +": "
  130. + Misc.optimizeText(playerCommand.substring(5)) +"");
  131. }else if (c.playerRights == 2){
  132.  
  133. c2.sendMessage("<shad=6581134>[Co-Owner]</col><img=2>"+ Misc.optimizeText(c.playerName) +": "
  134. + Misc.optimizeText(playerCommand.substring(5)) +"");
  135. }else if (c.playerRights == 3){
  136. c2.sendMessage("<shad=15695415>[Owner]</col><img=2>"+ Misc.optimizeText(c.playerName) +": "
  137. + Misc.optimizeText(playerCommand.substring(5)) +"");
  138. }else if (c.playerRights == 4){
  139. c2.sendMessage("<shad=6081134>[Donator]</col><img=0>"+ Misc.optimizeText(c.playerName) +": "
  140. + Misc.optimizeText(playerCommand.substring(5)) +"");
  141. }
  142. }
  143. }
  144. }
  145.  
  146.  
  147. }
  148.  
  149. public void moderatorCommands(Client c, String playerCommand)
  150. {
  151. if (playerCommand.startsWith("xteleto")) {
  152. String name = playerCommand.substring(8);
  153. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  154. if (Server.playerHandler.players[i] != null) {
  155. if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  156. c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
  157. }
  158. }
  159. }
  160. }
  161. if (playerCommand.startsWith("mute")) {
  162. try {
  163. String playerToBan = playerCommand.substring(5);
  164. Connection.addNameToMuteList(playerToBan);
  165. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  166. if(Server.playerHandler.players[i] != null) {
  167. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  168. Client c2 = (Client)Server.playerHandler.players[i];
  169. c2.sendMessage("You have been muted by: " + c.playerName);
  170. c2.sendMessage(" " +c2.playerName+ " Got Muted By " + c.playerName+ ".");
  171. break;
  172. }
  173. }
  174. }
  175. } catch(Exception e) {
  176. c.sendMessage("Player Must Be Offline.");
  177. }
  178. }
  179. if (playerCommand.startsWith("unmute")) {
  180. try {
  181. String playerToBan = playerCommand.substring(7);
  182. Connection.unMuteUser(playerToBan);
  183. } catch(Exception e) {
  184. c.sendMessage("Player Must Be Offline.");
  185.  
  186. }
  187. }
  188. if (playerCommand.startsWith("checkbank")) {
  189. String[] args = playerCommand.split(" ");
  190. for(int i = 0; i < Config.MAX_PLAYERS; i++)
  191. {
  192. Client o = (Client) Server.playerHandler.players[i];
  193. if(Server.playerHandler.players[i] != null)
  194. {
  195. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1]))
  196. {
  197. c.getPA().otherBank(c, o);
  198. break;
  199. }
  200. }
  201. }
  202. }
  203. if (playerCommand.startsWith("kick") && playerCommand.charAt(4) == ' ') {
  204. try {
  205. String playerToBan = playerCommand.substring(5);
  206. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  207. if(Server.playerHandler.players[i] != null) {
  208. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  209. Server.playerHandler.players[i].disconnected = true;
  210. }
  211. }
  212. }
  213. } catch(Exception e) {
  214. c.sendMessage("Player Must Be Offline.");
  215. }
  216. }
  217. if(playerCommand.startsWith("unjail")) {
  218. try {
  219. String playerToBan = playerCommand.substring(7);
  220. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  221. if(Server.playerHandler.players[i] != null) {
  222. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  223. Client c2 = (Client)Server.playerHandler.players[i];
  224. c2.teleportToX = 3086;
  225. c2.teleportToY = 3493;
  226. c2.monkeyk0ed = 0;
  227. c2.Jail = false;
  228. c2.sendMessage("You have been unjailed by "+c.playerName+".");
  229. c.sendMessage("Successfully unjailed "+c2.playerName+".");
  230. }
  231. }
  232. }
  233. } catch(Exception e) {
  234. c.sendMessage("Player Must Be Offline.");
  235. }
  236. }
  237.  
  238. }
  239.  
  240. public void administratorCommands(Client c, String playerCommand)
  241. {
  242.  
  243. if (playerCommand.startsWith("ipmute")) {
  244. try {
  245. String playerToBan = playerCommand.substring(7);
  246. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  247. if(Server.playerHandler.players[i] != null) {
  248. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  249. Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
  250. c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
  251. Client c2 = (Client)Server.playerHandler.players[i];
  252. c2.sendMessage("You have been muted by: " + c.playerName);
  253. c2.sendMessage(" " +c2.playerName+ " Got IpMuted By " + c.playerName+ ".");
  254. break;
  255. }
  256. }
  257. }
  258. } catch(Exception e) {
  259. c.sendMessage("Player Must Be Offline.");
  260. }
  261. }
  262.  
  263. if (playerCommand.equalsIgnoreCase("master")) {
  264. for (int i = 0; i < 21; i++) {
  265. c.playerLevel[i] = 99;
  266. c.playerXP[i] = c.getPA().getXPForLevel(100);
  267. c.getPA().refreshSkill(i);
  268. }
  269. c.getPA().requestUpdates();
  270. }
  271. if (playerCommand.startsWith("commands")){
  272. c.sendMessage("::empty(DONT DO IT IF YOU WANT DONT WANT TO LOOSE YOUR ITEMS IN YOUR INVENTORY)");
  273. c.sendMessage("::yell(donators only)");
  274. c.sendMessage("::torms(they have alot hp");
  275. c.sendMessage("More Coming Soon...");
  276. }
  277.  
  278. if (playerCommand.startsWith("object")) {
  279. String[] args = playerCommand.split(" ");
  280. c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
  281. }
  282.  
  283. if (playerCommand.equalsIgnoreCase("mypos")) {
  284. c.sendMessage("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel);
  285. }
  286.  
  287. if (playerCommand.startsWith("interface")) {
  288. String[] args = playerCommand.split(" ");
  289. c.getPA().showInterface(Integer.parseInt(args[1]));
  290. }
  291.  
  292. if (playerCommand.startsWith("gfx")) {
  293. String[] args = playerCommand.split(" ");
  294. c.gfx0(Integer.parseInt(args[1]));
  295. }
  296. if (playerCommand.startsWith("tele")) {
  297. String[] arg = playerCommand.split(" ");
  298. if (arg.length > 3)
  299. c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
  300. else if (arg.length == 3)
  301. c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
  302. }
  303. if (playerCommand.startsWith("alltome")) {
  304. try {
  305. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  306. String name = playerCommand.substring(10);
  307. if (Server.playerHandler.players[i] != null) {
  308. Client other = (Client) Server.playerHandler.players[i];
  309. other.getPA().movePlayer(c.getX(), c.getY(), c.heightLevel);
  310. }
  311. }
  312. } catch(Exception e) {
  313. c.sendMessage("Player Must Be Offline.");
  314. }
  315. }
  316.  
  317.  
  318. if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') {
  319. try {
  320. String playerToBan = playerCommand.substring(4);
  321. Connection.addNameToBanList(playerToBan);
  322. Connection.addNameToFile(playerToBan);
  323. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  324. if(Server.playerHandler.players[i] != null) {
  325. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  326. Server.playerHandler.players[i].disconnected = true;
  327. Client c2 = (Client)Server.playerHandler.players[i];
  328. c2.sendMessage(" " +c2.playerName+ " Got Banned By " + c.playerName+ ".");
  329. }
  330. }
  331. }
  332. } catch(Exception e) {
  333. c.sendMessage("Player Must Be Offline.");
  334. }
  335. }
  336. if (playerCommand.equalsIgnoreCase("bank")) {
  337. c.getPA().openUpBank();
  338. }
  339. if (playerCommand.startsWith("unipmute")) {
  340. try {
  341. String playerToBan = playerCommand.substring(9);
  342. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  343. if(Server.playerHandler.players[i] != null) {
  344. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  345. Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
  346. c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
  347. break;
  348. }
  349. }
  350. }
  351. } catch(Exception e) {
  352. c.sendMessage("Player Must Be Offline.");
  353. }
  354. }
  355. if (playerCommand.startsWith("ipban")) {
  356. try {
  357. String playerToBan = playerCommand.substring(6);
  358. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  359. if(Server.playerHandler.players[i] != null) {
  360. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  361. Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
  362. Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
  363. c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
  364. Client c2 = (Client)Server.playerHandler.players[i];
  365. Server.playerHandler.players[i].disconnected = true;
  366. c2.sendMessage(" " +c2.playerName+ " Got IpBanned By " + c.playerName+ ".");
  367. }
  368. }
  369. }
  370. } catch(Exception e) {
  371. c.sendMessage("Player Must Be Offline.");
  372. }
  373. }
  374. if (playerCommand.startsWith("unban")) {
  375. try {
  376. String playerToBan = playerCommand.substring(6);
  377. Connection.removeNameFromBanList(playerToBan);
  378. c.sendMessage(playerToBan + " has been unbanned.");
  379. } catch(Exception e) {
  380. c.sendMessage("Player Must Be Offline.");
  381. }
  382. }
  383.  
  384. }
  385.  
  386. public void ownerCommands(Client c, String playerCommand)
  387. {
  388.  
  389. if (playerCommand.startsWith("update")) {
  390. String[] args = playerCommand.split(" ");
  391. int a = Integer.parseInt(args[1]);
  392. PlayerHandler.updateSeconds = a;
  393. PlayerHandler.updateAnnounced = false;
  394. PlayerHandler.updateRunning = true;
  395. PlayerHandler.updateStartTime = System.currentTimeMillis();
  396. }
  397. if (playerCommand.startsWith("empty")) {
  398. c.getItems().removeAllItems();
  399. c.sendMessage("You empty your inventory");
  400. }
  401. if(playerCommand.startsWith("npc")) {
  402. try {
  403. int newNPC = Integer.parseInt(playerCommand.substring(4));
  404. if(newNPC > 0) {
  405. Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  406. c.sendMessage("You spawn a Npc.");
  407. } else {
  408. c.sendMessage("No such NPC.");
  409. }
  410. } catch(Exception e) {
  411.  
  412. }
  413. }
  414.  
  415. if (playerCommand.startsWith("anim")) {
  416. String[] args = playerCommand.split(" ");
  417. c.startAnimation(Integer.parseInt(args[1]));
  418. c.getPA().requestUpdates();
  419. }
  420.  
  421. if (playerCommand.startsWith("spec")) {
  422. c.specAmount = 500.0;
  423. }
  424.  
  425. if (playerCommand.startsWith("giveadmin")) {
  426. try {
  427. String playerToAdmin = playerCommand.substring(10);
  428. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  429. if(Server.playerHandler.players[i] != null) {
  430. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
  431. Client c2 = (Client)Server.playerHandler.players[i];
  432. c2.sendMessage("You have been given admin status by " + c.playerName);
  433. c2.playerRights = 2;
  434. c2.logout();
  435. break;
  436. }
  437. }
  438. }
  439. } catch(Exception e) {
  440. c.sendMessage("Player Must Be Offline.");
  441. }
  442. }
  443.  
  444. if (playerCommand.startsWith("givemod")) {
  445. try {
  446. String playerToMod = playerCommand.substring(8);
  447. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  448. if(Server.playerHandler.players[i] != null) {
  449. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToMod)) {
  450. Client c2 = (Client)Server.playerHandler.players[i];
  451. c2.sendMessage("You have been given mod status by " + c.playerName);
  452. c2.playerRights = 1;
  453. c2.logout();
  454. break;
  455. }
  456. }
  457. }
  458. } catch(Exception e) {
  459. c.sendMessage("Player Must Be Offline.");
  460. }
  461. }
  462.  
  463. if (playerCommand.startsWith("pnpc"))
  464. {
  465. try {
  466. int newNPC = Integer.parseInt(playerCommand.substring(5));
  467. if (newNPC <= 200000 && newNPC >= 0) {
  468. c.npcId2 = newNPC;
  469. c.isNpc = true;
  470. c.updateRequired = true;
  471. c.setAppearanceUpdateRequired(true);
  472. }
  473. else {
  474. c.sendMessage("No such P-NPC.");
  475. }
  476. } catch(Exception e) {
  477. c.sendMessage("Wrong Syntax! Use as ::pnpc #");
  478. }
  479. }
  480.  
  481.  
  482. if (playerCommand.startsWith("givedonor")) {
  483. try {
  484. String playerToMod = playerCommand.substring(10);
  485. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  486. if(Server.playerHandler.players[i] != null) {
  487. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToMod)) {
  488. Client c2 = (Client)Server.playerHandler.players[i];
  489. c2.sendMessage("You have been given donator status by " + c.playerName);
  490. c2.playerRights = 4;
  491. c2.isDonator = 1;
  492. c2.logout();
  493. break;
  494. }
  495. }
  496. }
  497. } catch(Exception e) {
  498. c.sendMessage("Player Must Be Offline.");
  499. }
  500. }
  501.  
  502.  
  503. if (playerCommand.startsWith("demote")) {
  504. try {
  505. String playerToDemote = playerCommand.substring(7);
  506. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  507. if(Server.playerHandler.players[i] != null) {
  508. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToDemote)) {
  509. Client c2 = (Client)Server.playerHandler.players[i];
  510. c2.sendMessage("You have been demoted by " + c.playerName);
  511. c2.playerRights = 0;
  512. c2.logout();
  513. break;
  514. }
  515. }
  516. }
  517. } catch(Exception e) {
  518. c.sendMessage("Player Must Be Offline.");
  519. }
  520. }
  521.  
  522. if (playerCommand.startsWith("item")) {
  523. try {
  524. String[] args = playerCommand.split(" ");
  525. if (args.length == 3) {
  526. int newItemID = Integer.parseInt(args[1]);
  527. int newItemAmount = Integer.parseInt(args[2]);
  528. if ((newItemID <= 20000) && (newItemID >= 0)) {
  529. c.getItems().addItem(newItemID, newItemAmount);
  530. } else {
  531. c.sendMessage("That item ID does not exist.");
  532. }
  533. } else {
  534. c.sendMessage("Wrong usage: (Ex:(::pickup_ID_Amount)(::item 995 1))");
  535. }
  536. } catch(Exception e) {
  537.  
  538. } // HERE?
  539. } // HERE?
  540.  
  541. }
  542.  
  543. public void DonatorCommands(Client c, String playerCommand)
  544. {
  545.  
  546. }
  547. }
Add Comment
Please, Sign In to add comment