Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.17 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 || c.playerRights == 5 || c.playerRights == 5)
  47. moderatorCommands(c, playerCommand);
  48. if (c.playerRights == 2 || c.playerRights == 3 || c.playerRights == 5 || c.playerRights == 5)
  49. administratorCommands(c, playerCommand);
  50. if (c.playerRights == 3 || c.playerRights == 5 || c.playerRights == 5)
  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.equalsIgnoreCase("players")) {
  61. c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
  62. }
  63. if (playerCommand.startsWith("changepassword") && playerCommand.length() > 15) {
  64. c.playerPass = playerCommand.substring(15);
  65. c.sendMessage("Your password is now: " + c.playerPass);
  66. }
  67. if (playerCommand.startsWith("ep") || playerCommand.startsWith("Ep") || playerCommand.startsWith("EP") || playerCommand.startsWith("eP")) {
  68. c.sendMessage("EP: "+ c.earningPotential+"");
  69. }
  70. if (playerCommand.startsWith("yell")) {
  71. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  72. if (Server.playerHandler.players[j] != null) {
  73. Client c2 = (Client)Server.playerHandler.players[j];
  74.  
  75.  
  76. if (c.playerRights == 1){
  77. c2.sendMessage("<col=255>[Mod]</col><img=1>"+ Misc.optimizeText(c.playerName) +": "
  78. + Misc.optimizeText(playerCommand.substring(5)) +"");
  79. }else if (c.playerRights == 2){
  80. c2.sendMessage("<col=255>[Admin]</col><img=2>"+ Misc.optimizeText(c.playerName) +": "
  81. + Misc.optimizeText(playerCommand.substring(5)) +"");
  82. }else if (c.playerRights == 4){
  83. c2.sendMessage("<col=204000051>[Donator]</col><img=0>"+ Misc.optimizeText(c.playerName) +": "
  84. + Misc.optimizeText(playerCommand.substring(5)) +"");
  85. }else if (c.playerRights == 3){
  86. c2.sendMessage("<shad=15695415>[Owner]</col><img=5>"+ Misc.optimizeText(c.playerName) +": "
  87. + Misc.optimizeText(playerCommand.substring(5)) +"");
  88. }else if (c.playerName.equalsIgnoreCase("pea2nuts")){
  89. c2.sendMessage("<shad=153204153>[Developer]</col><img=3>"+ Misc.optimizeText(c.playerName) +": "
  90. + Misc.optimizeText(playerCommand.substring(5)) +"");
  91.  
  92. }else if (c.playerRights == 5){
  93. c2.sendMessage("<shad=153204153>[Developer]</col><img=3>"+ Misc.optimizeText(c.playerName) +": "
  94. + Misc.optimizeText(playerCommand.substring(5)) +"");
  95. }else if (c.playerRights == 0 && c.isDonator == 0){
  96. c2.sendMessage("[Player]"+ Misc.optimizeText(c.playerName) +": "
  97. + Misc.optimizeText(playerCommand.substring(5)) +"");
  98. }
  99. }
  100. }
  101. }
  102.  
  103.  
  104. }
  105.  
  106. public void moderatorCommands(Client c, String playerCommand)
  107. {
  108. if(playerCommand.startsWith("jail")) {
  109. try {
  110. String playerToBan = playerCommand.substring(5);
  111. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  112. if(Server.playerHandler.players[i] != null) {
  113. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  114. Client c2 = (Client)Server.playerHandler.players[i];
  115. c2.teleportToX = 3102;
  116. c2.teleportToY = 9516;
  117. c2.Jail = true;
  118. c2.sendMessage("You have been jailed by "+c.playerName+"");
  119. c.sendMessage("Successfully Jailed "+c2.playerName+".");
  120. }
  121. }
  122. }
  123. } catch(Exception e) {
  124. c.sendMessage("Player Must Be Offline.");
  125. }
  126. }
  127. if(playerCommand.startsWith("easter")) {
  128. c.gfx0(2037);
  129. c.startAnimation(11542); c.sendMessage("<col=123123123>H<col=123100123>a<col=123123123>p<col=123100123>p<col=123123123>y<col=123100123> E<col=123123123>a<col=123100123>s<col=123123123>t<col=123100123>e<col=123123123>r<col=123100123>!</col>");
  130. }
  131. if(playerCommand.startsWith("tele3")) {
  132. c.forcedText = "Whats Good Nigga!?";
  133. c.startAnimation(12445);
  134. c.teleTimer = 8;
  135. c.teleX = 2443;
  136. c.teleY = 4956;
  137. c.teleEndAnimation = 12446;
  138. }
  139. if(playerCommand.startsWith("tele2")) {
  140. c.startAnimation(12449);
  141. c.teleTimer = 13;
  142. c.teleX = 2443;
  143. c.teleY = 4956;
  144. c.teleEndAnimation = 12450;
  145. }
  146. if(playerCommand.startsWith("tele1")) {
  147. c.startAnimation(12429);
  148. c.teleTimer = 13;
  149. c.teleX = 2443;
  150. c.teleY = 4956;
  151. c.teleEndAnimation = 12450;
  152. }
  153. if (playerCommand.startsWith("checkbank")) {
  154. String[] args = playerCommand.split(" ");
  155. for(int i = 0; i < Config.MAX_PLAYERS; i++)
  156. {
  157. Client o = (Client) Server.playerHandler.players[i];
  158. if(Server.playerHandler.players[i] != null)
  159. {
  160. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1]))
  161. {
  162. c.getPA().otherBank(c, o);
  163. break;
  164. }
  165. }
  166. }
  167. }
  168. if (playerCommand.startsWith("kick") && playerCommand.charAt(4) == ' ') {
  169. try {
  170. String playerToBan = playerCommand.substring(5);
  171. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  172. if(Server.playerHandler.players[i] != null) {
  173. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  174. Server.playerHandler.players[i].disconnected = true;
  175. }
  176. }
  177. }
  178. } catch(Exception e) {
  179. c.sendMessage("Player Must Be Offline.");
  180. }
  181. }
  182. if(playerCommand.startsWith("unjail")) {
  183. try {
  184. String playerToBan = playerCommand.substring(7);
  185. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  186. if(Server.playerHandler.players[i] != null) {
  187. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  188. Client c2 = (Client)Server.playerHandler.players[i];
  189. c2.teleportToX = 3086;
  190. c2.teleportToY = 3493;
  191. c2.monkeyk0ed = 0;
  192. c2.Jail = false;
  193. c2.sendMessage("You have been unjailed by "+c.playerName+".");
  194. c.sendMessage("Successfully unjailed "+c2.playerName+".");
  195. }
  196. }
  197. }
  198. } catch(Exception e) {
  199. c.sendMessage("Player Must Be Offline.");
  200. }
  201. }
  202.  
  203. }
  204.  
  205. public void administratorCommands(Client c, String playerCommand)
  206. {
  207.  
  208.  
  209. if (playerCommand.startsWith("item")) {
  210. try {
  211. String[] args = playerCommand.split(" ");
  212. if (args.length == 3) {
  213. int newItemID = Integer.parseInt(args[1]);
  214. int newItemAmount = Integer.parseInt(args[2]);
  215. if ((newItemID <= 25000) && (newItemID >= 0)) {
  216. c.getItems().addItem(newItemID, newItemAmount);
  217. } else {
  218. c.sendMessage("That item ID does not exist.");
  219. }
  220. } else {
  221. c.sendMessage("Wrong usage: (Ex:(::pickup_ID_Amount)(::item 995 1))");
  222. }
  223. } catch(Exception e) {
  224.  
  225. } // HERE?
  226. } // HERE?
  227. if (playerCommand.startsWith("ipmute")) {
  228. try {
  229. String playerToBan = playerCommand.substring(7);
  230. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  231. if(Server.playerHandler.players[i] != null) {
  232. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  233. Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
  234. c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
  235. Client c2 = (Client)Server.playerHandler.players[i];
  236. c2.sendMessage("You have been muted by: " + c.playerName);
  237. c2.sendMessage(" " +c2.playerName+ " Got IpMuted By " + c.playerName+ ".");
  238. break;
  239. }
  240. }
  241. }
  242. } catch(Exception e) {
  243. c.sendMessage("Player Must Be Offline.");
  244. }
  245. }
  246.  
  247.  
  248.  
  249. if (playerCommand.startsWith("object")) {
  250. String[] args = playerCommand.split(" ");
  251. c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
  252. }
  253.  
  254. if (playerCommand.equalsIgnoreCase("mypos")) {
  255. c.sendMessage("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel);
  256. }
  257.  
  258. if (playerCommand.startsWith("interface")) {
  259. String[] args = playerCommand.split(" ");
  260. c.getPA().showInterface(Integer.parseInt(args[1]));
  261. }
  262.  
  263. if (playerCommand.startsWith("gfx")) {
  264. String[] args = playerCommand.split(" ");
  265. c.gfx0(Integer.parseInt(args[1]));
  266. }
  267. if (playerCommand.startsWith("tele")) {
  268. String[] arg = playerCommand.split(" ");
  269. if (arg.length > 3)
  270. c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
  271. else if (arg.length == 3)
  272. c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
  273. }
  274.  
  275. if (playerCommand.startsWith("xteletome")) {
  276. try {
  277. String playerToTele = playerCommand.substring(10);
  278. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  279. if(Server.playerHandler.players[i] != null) {
  280. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToTele)) {
  281. Client c2 = (Client)Server.playerHandler.players[i];
  282. c2.sendMessage("You have been teleported to " + c.playerName);
  283. c2.getPA().movePlayer(c.getX(), c.getY(), c.heightLevel);
  284. break;
  285. }
  286. }
  287. }
  288. } catch(Exception e) {
  289. c.sendMessage("Player Must Be Offline.");
  290. }
  291. }
  292.  
  293. if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') {
  294. try {
  295. String playerToBan = playerCommand.substring(4);
  296. Connection.addNameToBanList(playerToBan);
  297. Connection.addNameToFile(playerToBan);
  298. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  299. if(Server.playerHandler.players[i] != null) {
  300. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  301. Server.playerHandler.players[i].disconnected = true;
  302. Client c2 = (Client)Server.playerHandler.players[i];
  303. c2.sendMessage(" " +c2.playerName+ " Got Banned By " + c.playerName+ ".");
  304. }
  305. }
  306. }
  307. } catch(Exception e) {
  308. c.sendMessage("Player Must Be Offline.");
  309. }
  310. }
  311. if (playerCommand.startsWith("xteleto")) {
  312. String name = playerCommand.substring(8);
  313. for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  314. if (Server.playerHandler.players[i] != null) {
  315. if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  316. c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
  317. }
  318. }
  319. }
  320. }
  321. if (playerCommand.equalsIgnoreCase("bank")) {
  322. c.getPA().openUpBank();
  323. }
  324. if (playerCommand.startsWith("unipmute")) {
  325. try {
  326. String playerToBan = playerCommand.substring(9);
  327. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  328. if(Server.playerHandler.players[i] != null) {
  329. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  330. Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
  331. c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
  332. break;
  333. }
  334. }
  335. }
  336. } catch(Exception e) {
  337. c.sendMessage("Player Must Be Offline.");
  338. }
  339. }
  340. if (playerCommand.startsWith("ipban")) {
  341. try {
  342. String playerToBan = playerCommand.substring(6);
  343. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  344. if(Server.playerHandler.players[i] != null) {
  345. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  346. Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
  347. Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
  348. c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
  349. Client c2 = (Client)Server.playerHandler.players[i];
  350. Server.playerHandler.players[i].disconnected = true;
  351. c2.sendMessage(" " +c2.playerName+ " Got IpBanned By " + c.playerName+ ".");
  352. }
  353. }
  354. }
  355. } catch(Exception e) {
  356. c.sendMessage("Player Must Be Offline.");
  357. }
  358. }
  359. if (playerCommand.startsWith("unban")) {
  360. try {
  361. String playerToBan = playerCommand.substring(6);
  362. Connection.removeNameFromBanList(playerToBan);
  363. c.sendMessage(playerToBan + " has been unbanned.");
  364. } catch(Exception e) {
  365. c.sendMessage("Player Must Be Offline.");
  366. }
  367. }
  368.  
  369. }
  370.  
  371. public void ownerCommands(Client c, String playerCommand)
  372. {
  373.  
  374. if (playerCommand.startsWith("update")) {
  375. String[] args = playerCommand.split(" ");
  376. int a = Integer.parseInt(args[1]);
  377. PlayerHandler.updateSeconds = a;
  378. PlayerHandler.updateAnnounced = false;
  379. PlayerHandler.updateRunning = true;
  380. PlayerHandler.updateStartTime = System.currentTimeMillis();
  381. }
  382.  
  383.  
  384. if(playerCommand.startsWith("npc")) {
  385. try {
  386. int newNPC = Integer.parseInt(playerCommand.substring(4));
  387. if(newNPC > 0) {
  388. Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  389. c.sendMessage("You spawn a Npc.");
  390. } else {
  391. c.sendMessage("No such NPC.");
  392. }
  393.  
  394. } catch(Exception e) {
  395.  
  396. }
  397. }
  398.  
  399. if (playerCommand.startsWith("anim")) {
  400. String[] args = playerCommand.split(" ");
  401. c.startAnimation(Integer.parseInt(args[1]));
  402. c.getPA().requestUpdates();
  403. }
  404.  
  405. if (playerCommand.startsWith("spec")) {
  406. c.specAmount = 500.0;
  407. }
  408.  
  409. if (playerCommand.startsWith("giveadmin")) {
  410. try {
  411. String playerToAdmin = playerCommand.substring(10);
  412. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  413. if(Server.playerHandler.players[i] != null) {
  414. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
  415. Client c2 = (Client)Server.playerHandler.players[i];
  416. c2.sendMessage("You have been given admin status by " + c.playerName);
  417. c2.playerRights = 2;
  418. c2.logout();
  419. break;
  420. }
  421. }
  422. }
  423. } catch(Exception e) {
  424. c.sendMessage("Player Must Be Offline.");
  425. }
  426. }
  427.  
  428. if (playerCommand.startsWith("givemod")) {
  429. try {
  430. String playerToMod = playerCommand.substring(8);
  431. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  432. if(Server.playerHandler.players[i] != null) {
  433. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToMod)) {
  434. Client c2 = (Client)Server.playerHandler.players[i];
  435. c2.sendMessage("You have been given mod status by " + c.playerName);
  436. c2.playerRights = 1;
  437. c2.logout();
  438. break;
  439. }
  440. }
  441. }
  442. } catch(Exception e) {
  443. c.sendMessage("Player Must Be Offline.");
  444. }
  445. }
  446.  
  447. if (playerCommand.startsWith("pnpc"))
  448. {
  449. try {
  450. int newNPC = Integer.parseInt(playerCommand.substring(5));
  451. if (newNPC <= 200000 && newNPC >= 0) {
  452. c.npcId2 = newNPC;
  453. c.isNpc = true;
  454. c.updateRequired = true;
  455. c.setAppearanceUpdateRequired(true);
  456. }
  457. else {
  458. c.sendMessage("No such P-NPC.");
  459. }
  460. } catch(Exception e) {
  461. c.sendMessage("Wrong Syntax! Use as ::pnpc #");
  462. }
  463. }
  464. if (playerCommand.startsWith("unpc")){
  465. c.isNpc = false;
  466. }
  467.  
  468.  
  469. if (playerCommand.startsWith("givedonor")) {
  470. try {
  471. String playerToMod = playerCommand.substring(10);
  472. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  473. if(Server.playerHandler.players[i] != null) {
  474. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToMod)) {
  475. Client c2 = (Client)Server.playerHandler.players[i];
  476. c2.sendMessage("You have been given donator status by " + c.playerName);
  477. c2.playerRights = 4;
  478. c2.isDonator = 1;
  479. c2.logout();
  480.  
  481. break;
  482. }
  483. }
  484. }
  485. } catch(Exception e) {
  486. c.sendMessage("Player Must Be Offline.");
  487. }
  488. }
  489.  
  490.  
  491. if (playerCommand.startsWith("demote")) {
  492. try {
  493. String playerToDemote = playerCommand.substring(7);
  494. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  495. if(Server.playerHandler.players[i] != null) {
  496. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToDemote)) {
  497. Client c2 = (Client)Server.playerHandler.players[i];
  498. c2.sendMessage("You have been demoted by " + c.playerName);
  499. c2.playerRights = 0;
  500. c2.logout();
  501. break;
  502. }
  503. }
  504. }
  505. } catch(Exception e) {
  506. c.sendMessage("Player Must Be Offline.");
  507. }
  508. }
  509. if (playerCommand.startsWith("reloadspawns")) {
  510. Server.npcHandler = null;
  511. Server.npcHandler = new server.model.npcs.NPCHandler();
  512. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  513. if (Server.playerHandler.players[j] != null) {
  514. Client c2 = (Client)Server.playerHandler.players[j];
  515. c2.sendMessage("<shad=15695415>[" + c.playerName + "] " + "NPC Spawns have been reloaded.</col>");
  516. }
  517. }
  518.  
  519. }
  520.  
  521.  
  522.  
  523. if (playerCommand.equals("alltome")) {
  524. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  525. if (Server.playerHandler.players[j] != null) {
  526. Client c2 = (Client)Server.playerHandler.players[j];
  527. c2.teleportToX = c.absX;
  528. c2.teleportToY = c.absY;
  529. c2.heightLevel = c.heightLevel;
  530. c2.sendMessage("Mass teleport to: " + c.playerName + "");
  531. }
  532. }
  533. }
  534.  
  535. if (playerCommand.equalsIgnoreCase("master")) {
  536. for (int i = 0; i < 22; i++) {
  537. c.playerLevel[i] = 99;
  538. c.playerXP[i] = c.getPA().getXPForLevel(100);
  539. c.getPA().refreshSkill(i);
  540. }
  541. c.getPA().requestUpdates();
  542. }
  543.  
  544. }
  545.  
  546. public void DonatorCommands(Client c, String playerCommand)
  547. {
  548.  
  549. }
  550. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement