Advertisement
Guest User

Untitled

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