Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 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. import server.world.WorldMap;
  11.  
  12. /**
  13. * Commands
  14. **/
  15.  
  16. /*RIGHTS
  17. *Regualr = 0
  18. *Donator = 1
  19. *Super-donator = 2
  20. *Moderator = 3
  21. *Developer = 4
  22. *Co-owner = 5
  23. *Owner = 6
  24. */
  25.  
  26. public class Commands implements PacketType {
  27.  
  28.  
  29. @Override
  30. public void processPacket(Client c, int packetType, int packetSize) {
  31. String playerCommand = c.getInStream().readString();
  32. if(Config.SERVER_DEBUG)
  33. Misc.println(c.playerName+" playerCommand: "+playerCommand);
  34. if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
  35. if (c.clanId >= 0) {
  36. System.out.println(playerCommand);
  37. playerCommand = playerCommand.substring(1);
  38. Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
  39. } else {
  40. if (c.clanId != -1)
  41. c.clanId = -1;
  42. c.sendMessage("You are not in a clan.");
  43. }
  44. return;
  45. }
  46.  
  47.  
  48.  
  49.  
  50. if(c.playerRights >= 0) { //Regular Commands
  51.  
  52. if (playerCommand.equalsIgnoreCase("players")) {
  53. c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
  54. }
  55. if (playerCommand.startsWith("changepassword") && playerCommand.length() > 15) {
  56. c.playerPass = playerCommand.substring(15);
  57. c.sendMessage("Your password is now: " + c.playerPass);
  58. }
  59.  
  60. if (playerCommand.equals("home")) {
  61. c.getPA().movePlayer(3352, 3343, 4);
  62. c.sendMessage("Welcome Home!");
  63. }
  64. }
  65.  
  66.  
  67.  
  68.  
  69. //if(c.playerRights >= 1) { //Donator Commands
  70.  
  71.  
  72.  
  73.  
  74. //if(c.playerRights >= 2) { //Super-donator Commands
  75.  
  76.  
  77.  
  78.  
  79. //if(c.playerRights >= 3) { //Moderator Commands
  80.  
  81. if (playerCommand.startsWith("mute")) {
  82. try {
  83. String playerToBan = playerCommand.substring(5);
  84. Connection.addNameToMuteList(playerToBan);
  85. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  86. if(Server.playerHandler.players[i] != null) {
  87. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  88. Client c2 = (Client)Server.playerHandler.players[i];
  89. c2.sendMessage("You have been muted by: " + c.playerName);
  90. break;
  91. }
  92. }
  93. }
  94. } catch(Exception e) {
  95. c.sendMessage("Player Must Be Offline.");
  96. }
  97. }
  98.  
  99. if (playerCommand.startsWith("unmute")) {
  100. try {
  101. String playerToBan = playerCommand.substring(7);
  102. Connection.unMuteUser(playerToBan);
  103. } catch(Exception e) {
  104. c.sendMessage("Player Must Be Offline.");
  105. }
  106. }
  107.  
  108. if(c.playerRights >= 4) { //Developer Commands
  109.  
  110. if (playerCommand.equalsIgnoreCase("debug")) {
  111. Server.playerExecuted = true;
  112. }
  113.  
  114. if (playerCommand.startsWith("update")) {
  115. String[] args = playerCommand.split(" ");
  116. int a = Integer.parseInt(args[1]);
  117. PlayerHandler.updateSeconds = a;
  118. PlayerHandler.updateAnnounced = false;
  119. PlayerHandler.updateRunning = true;
  120. PlayerHandler.updateStartTime = System.currentTimeMillis();
  121. }
  122.  
  123. if (playerCommand.startsWith("object")) {
  124. String[] args = playerCommand.split(" ");
  125. c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
  126. }
  127.  
  128. if(playerCommand.startsWith("npc") && c.playerName.equalsIgnoreCase("Sanity")) {
  129. try {
  130. int newNPC = Integer.parseInt(playerCommand.substring(4));
  131. if(newNPC > 0) {
  132. Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  133. c.sendMessage("You spawn a Npc.");
  134. } else {
  135. c.sendMessage("No such NPC.");
  136. }
  137. } catch(Exception e) {
  138.  
  139. }
  140. }
  141.  
  142. if (playerCommand.startsWith("gfx")) {
  143. String[] args = playerCommand.split(" ");
  144. c.gfx0(Integer.parseInt(args[1]));
  145. }
  146.  
  147. if (playerCommand.startsWith("interface")) {
  148. try {
  149. String[] args = playerCommand.split(" ");
  150. int a = Integer.parseInt(args[1]);
  151. c.getPA().showInterface(a);
  152. } catch(Exception e) {
  153. c.sendMessage("::interface ####");
  154. }
  155. }
  156.  
  157. if (playerCommand.startsWith("anim")) {
  158. String[] args = playerCommand.split(" ");
  159. c.startAnimation(Integer.parseInt(args[1]));
  160. c.getPA().requestUpdates();
  161. }
  162.  
  163. if (playerCommand.startsWith("reloaddrops")) {
  164. Server.npcDrops = null;
  165. Server.npcDrops = new server.model.npcs.NPCDrops();
  166. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  167. if (Server.playerHandler.players[j] != null) {
  168. Client c2 = (Client)Server.playerHandler.players[j];
  169. c2.sendMessage("[" + c.playerName + "] " + "NPC Drops have been reloaded.");
  170. }
  171. }
  172. }
  173.  
  174. if (playerCommand.startsWith("reloadshops")) {
  175. Server.shopHandler = new server.world.ShopHandler();
  176. }
  177. }
  178.  
  179.  
  180.  
  181.  
  182. if(c.playerRights >= 5) { //Co-owner Commands
  183.  
  184. if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') { // use as ::ban name
  185. try {
  186. String playerToBan = playerCommand.substring(4);
  187. Connection.addNameToBanList(playerToBan);
  188. Connection.addNameToFile(playerToBan);
  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.  
  201. if (playerCommand.startsWith("ipban")) { // use as ::ipban name
  202. try {
  203. String playerToBan = playerCommand.substring(6);
  204. for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  205. if(Server.playerHandler.players[i] != null) {
  206. if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  207. Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
  208. Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
  209. c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
  210. Server.playerHandler.players[i].disconnected = true;
  211. }
  212. }
  213. }
  214. } catch(Exception e) {
  215. c.sendMessage("Player Must Be Offline.");
  216. }
  217. }
  218.  
  219. if (playerCommand.startsWith("unban")) {
  220. try {
  221. String playerToBan = playerCommand.substring(6);
  222. Connection.removeNameFromBanList(playerToBan);
  223. c.sendMessage(playerToBan + " has been unbanned.");
  224. } catch(Exception e) {
  225. c.sendMessage("Player Must Be Offline.");
  226. }
  227. }
  228.  
  229. if (playerCommand.startsWith("additem")) {
  230. if (c.inWild())
  231. return;
  232. try {
  233. String[] args = playerCommand.split(" ");
  234. if (args.length == 3) {
  235. int newItemID = Integer.parseInt(args[1]);
  236. int newItemAmount = Integer.parseInt(args[2]);
  237. if ((newItemID <= 20000) && (newItemID >= 0)) {
  238. c.getItems().addItem(newItemID, newItemAmount);
  239. System.out.println("Spawned: " + newItemID + " by: " + c.playerName);
  240. } else {
  241. c.sendMessage("No such item.");
  242. }
  243. } else {
  244. c.sendMessage("Use as ::item 995 200");
  245. }
  246. } catch (Exception e) {
  247.  
  248. }
  249.  
  250. if (playerCommand.startsWith("setlevel")) {
  251. if (c.inWild())
  252. return;
  253. for (int j = 0; j < c.playerEquipment.length; j++) {
  254. if (c.playerEquipment[j] > 0) {
  255. c.sendMessage("Please un-equip all items before use!");
  256. return;
  257. }
  258. }
  259. try {
  260. String[] args = playerCommand.split(" ");
  261. int skill = Integer.parseInt(args[1]);
  262. int level = Integer.parseInt(args[2]);
  263. if (level > 120)
  264. level = 120;
  265. else if (level < 0)
  266. level = 1;
  267. c.playerXP[skill] = c.getPA().getXPForLevel(level)+5;
  268. c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
  269. c.getPA().refreshSkill(skill);
  270. } catch (Exception e){}
  271. }
  272.  
  273. if (playerCommand.equals("special")) {
  274. if (!c.inWild())
  275. c.specAmount = 10.0;
  276. }
  277.  
  278. //if(c.playerRights >= 6) { //Owner Commands
  279.  
  280. }
  281. }
  282. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement