Advertisement
Guest User

Untitled

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