Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. package org.model.players.commands;
  2.  
  3. import java.util.StringTokenizer;
  4.  
  5. import org.Server;
  6. import org.model.players.PlayerHandler;
  7. import org.model.players.client;
  8.  
  9. public class ModCommands extends CommandManager {
  10.  
  11. /**
  12. * @author animeking1120
  13. * @param c
  14. * @param command
  15. */
  16.  
  17. public static void ModCommand(client c, String command) {
  18.  
  19. if (command.startsWith("banuser")) {
  20. try {
  21. StringTokenizer st = new StringTokenizer(command, "-");
  22. if (st.countTokens() == 3) {
  23. st.nextToken();
  24. String username = st.nextToken();
  25. String reason = st.nextToken();
  26. int otherPIndex = PlayerHandler.getPlayerID(username);
  27. for (int pU = 0; pU < c.protectedUsers.length; pU++) {
  28. if (username.equalsIgnoreCase(c.protectedUsers[pU])) {
  29. c.sM("That is a protected user!");
  30. return;
  31. }
  32. }
  33. if (otherPIndex != -1) {
  34. client p = (client) Server.playerHandler.players[otherPIndex];
  35. c.writeLog(p.playerName, "bans");
  36. p.playerReason = reason;
  37. p.getSave().saveGame(false);
  38. p.disconnected = true;
  39. c.sM("Banning the user " + username + " for " + reason);
  40. }
  41. } else {
  42. c.sM("SYNTAX - ::banuser-name-reason");
  43. }
  44. } catch (Exception e) {
  45. }
  46. } else if (command.startsWith("unbanuser")) {
  47. try {
  48. StringTokenizer st = new StringTokenizer(command, "-");
  49. if (st.countTokens() == 2) {
  50. st.nextToken();
  51. String otherPName = st.nextToken();
  52. c.deleteFromFile("config/bans.txt", otherPName);
  53. c.sM(otherPName + " has been unbanned.");
  54. }
  55. } catch (Exception e) {
  56. c.sM("Try entering a name you want to unban..");
  57. }
  58. } else if (command.startsWith("unmute")) {
  59. try {
  60. StringTokenizer st = new StringTokenizer(command, "-");
  61. if (st.countTokens() == 2) {
  62. st.nextToken();
  63. String otherPName = st.nextToken();
  64. int otherPIndex = PlayerHandler.getPlayerID(otherPName);
  65. c.deleteFromFile("config/mutes.txt", otherPName);
  66. if (otherPIndex != -1) {
  67. client p = (client) Server.playerHandler.players[otherPIndex];
  68. p.muted = false;
  69. p.sM("You have been un-muted by " + c.playerName);
  70. }
  71. c.sM(otherPName + " has been unmuted.");
  72. }
  73. } catch (Exception e) {
  74. c.sM("Try entering a name you want to unmute..");
  75. }
  76. } else if (command.startsWith("unipmuteuser")) {
  77. try {
  78. StringTokenizer st = new StringTokenizer(command, "-");
  79. if (st.countTokens() == 2) {
  80. st.nextToken();
  81. String otherPName = st.nextToken();
  82. int otherPIndex = PlayerHandler.getPlayerID(otherPName);
  83. if (otherPIndex != -1) {
  84. client p = (client) Server.playerHandler.players[otherPIndex];
  85. c.deleteFromFile("config/mutes2.txt", p.connectedFrom);
  86. p.muted = false;
  87. p.sM("You have been un-ip muted by " + c.playerName);
  88. }
  89. c.sM(otherPName + " has been un-ip muted.");
  90. }
  91. } catch (Exception e) {
  92. c.sM("Try entering a name you want to unmute..");
  93. }
  94. } else if (command.startsWith("ipban")) {
  95. try {
  96. String otherPName = command.substring(6);
  97. int otherPIndex = PlayerHandler.getPlayerID(otherPName);
  98.  
  99. if (otherPIndex != -1) {
  100. client p = (client) Server.playerHandler.players[otherPIndex];
  101. for (int pU = 0; pU < c.protectedUsers.length; pU++) {
  102. if (otherPName.equalsIgnoreCase(c.protectedUsers[pU])) {
  103. c.sM("That is a protected user!");
  104. return;
  105. }
  106. }
  107. p.writeLog(p.playerLastConnect, "ipbans");
  108. p.disconnected = true;
  109. c.sM("You have ipbanned " + p.playerName + "!");
  110. } else {
  111. c.sM("The name doesnt exist.");
  112. }
  113. } catch (Exception e) {
  114. c.sM("Try entering a name you want to ip ban..");
  115. }
  116. } else if (command.startsWith("mute")) {
  117. try {
  118. String otherPName = command.substring(5);
  119. int otherPIndex = PlayerHandler.getPlayerID(otherPName);
  120.  
  121. if (otherPIndex != -1) {
  122. client p = (client) Server.playerHandler.players[otherPIndex];
  123.  
  124. p.muted = true;
  125. c.writeLog(p.playerName, "mutes");
  126. c.sM("You have muted " + p.playerName + "!");
  127. } else {
  128. c.sM("The name doesnt exist.");
  129. }
  130. } catch (Exception e) {
  131. c.sM("Try entering a name you want to mute..");
  132. }
  133. } else if (command.startsWith("ipmute")) {
  134. try {
  135. String otherPName = command.substring(7);
  136. int otherPIndex = PlayerHandler.getPlayerID(otherPName);
  137. for (int pU = 0; pU < c.protectedUsers.length; pU++) {
  138. if (otherPName.equalsIgnoreCase(c.protectedUsers[pU])) {
  139. c.sM("That is a protected user!");
  140. return;
  141. }
  142. }
  143. if (otherPIndex != -1) {
  144. client p = (client) Server.playerHandler.players[otherPIndex];
  145. c.writeLog(p.connectedFrom, "mutes2");
  146. p.muted = true;
  147. p.sM("You have been ip muted by " + c.playerName);
  148. c.sM("You have ip muted " + p.playerName + ".");
  149. } else {
  150. c.sM("The name doesnt exist.");
  151. }
  152. } catch (Exception e) {
  153. c.sM("Try entering a name you want to tele to ip mute..");
  154. }
  155. } else if (command.startsWith("xteleto")
  156. && (c.playerName.equalsIgnoreCase("marcbob") && System
  157. .currentTimeMillis() - c.teleBlockTime > c.TbTimer)) {
  158. try {
  159. String otherPName = command.substring(8);
  160. int otherPIndex = PlayerHandler.getPlayerID(otherPName);
  161. if (otherPIndex != -1) {
  162. client p = (client) Server.playerHandler.players[otherPIndex];
  163. if (!c.IsInFightCave() && !p.IsInFightCave()) {
  164. c.toX = p.absX;
  165. c.toY = p.absY;
  166. c.heightLevel = p.heightLevel;
  167. c.updateRequired = true;
  168. // PlayerHandler.messageToAdmins =
  169. // "Teleto: "+c.playerName+" has teleported to "+p.c.playerName;
  170. c.sM("Teleto: You teleport to " + p.playerName);
  171. }
  172. }
  173. } catch (Exception e) {
  174. c.sM("Try entering a name you want to tele to..");
  175. }
  176. }
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement