Advertisement
Guest User

Untitled

a guest
Feb 26th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.03 KB | None | 0 0
  1. package server.model.players.commands;
  2.  
  3. import server.util.*;
  4. import server.model.players.Client;
  5. import server.Config;
  6. import server.Server;
  7. import server.model.players.PlayerHandler;
  8. import server.world.ClanHandler;
  9. import server.Connection;
  10. import server.util.SQL;
  11. import server.model.npcs.NPCHandler;
  12. import java.io.IOException;
  13. import java.net.InetSocketAddress;
  14. import java.text.DecimalFormat;
  15.  
  16. import org.apache.mina.common.IoAcceptor;
  17. import org.apache.mina.transport.socket.nio.SocketAcceptor;
  18. import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
  19.  
  20. import java.sql.*;
  21. import java.security.MessageDigest;
  22. import java.sql.ResultSet;
  23. import java.sql.SQLException;
  24. import java.sql.Statement;
  25.  
  26.  
  27.  
  28. public class RegularCommands {
  29. /**
  30. * RegularCommands : Commands that can be used by all the players.
  31. */
  32. public static void handleRegularCommands(Client c, String playerCommand) {
  33. if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
  34. if(Connection.isMuted(c)) {
  35. return;
  36. }
  37. if (c.inClan != null) {
  38. ClanHandler.handleCommand(c, playerCommand);
  39. } else {
  40. c.sendMessage("You are not in a clan.");
  41. }
  42. return;
  43. } else if (playerCommand.equalsIgnoreCase("players") && !c.inTrade) {
  44. c.sendMessage("There are currently "
  45. + (PlayerHandler.getPlayerCount())
  46. + " players online on @blu@Scronix.");
  47. } else if (playerCommand.equalsIgnoreCase("spk")) {
  48. c.sendMessage("You have @blu@" + c.pcPoints + "@blu@ Scronix Points.");
  49. } else if (playerCommand.startsWith("kdr")) {
  50. double KDR = ((double) c.KC) / ((double) c.DC);
  51. c.forcedChat("My Kill/Death ratio is " + c.KC + "/" + c.DC
  52. + "; " + KDR + ".");
  53. } else if (playerCommand.equalsIgnoreCase("empty")) {
  54. if (c.canUseEmptyCommand) {
  55. c.getItems().removeAllItems();
  56. } else {
  57. c.getDH().sendStatement("This command costs 500 donator points.");
  58. c.nextChat = 0;
  59. }
  60. } else if (playerCommand.equalsIgnoreCase("killcount")) {
  61. if (c.canUseKillcountCommand) {
  62. c.gwkc[0] = 20;
  63. c.gwkc[1] = 20;
  64. c.gwkc[2] = 20;
  65. c.gwkc[3] = 20;
  66. c.sendMessage("Killcount set to 20!");
  67. } else {
  68. c.getDH().sendStatement("This command costs 1000 donator points.");
  69. c.nextChat = 0;
  70. }
  71. /*} else if(playerCommand.equalsIgnoreCase("kakker")) {
  72. c.getPA().dontforgetme();*/
  73. } else if (playerCommand.equalsIgnoreCase("commands")) {
  74. c.sendMessage(" Your current commands;");
  75. c.sendMessage(" ::players, ::resetatt, ::resethp, ::resetstr");
  76. c.sendMessage(" ::resetrange, ::resetmage, ::resetdef, ::resetpray");
  77. c.sendMessage(" ::resetTask");
  78. } else if (playerCommand.startsWith("changepassword") && playerCommand.length() > 15) {
  79. c.playerPass = playerCommand.substring(15);
  80. c.sendMessage("Your password is now: " + c.playerPass);
  81. } else if (playerCommand.startsWith("rules")) {
  82. c.sendMessage("@dre@Scronix Rules");
  83. c.sendMessage("1. Abusing a glitch/bug will result in a ban, report them on our forums instead.");
  84. c.sendMessage("2. Do not ask for a staff position. Staff will choose people based on their behaviour.");
  85. c.sendMessage("3. There are no rules in the wilderness, don't make any reports regarding it.");
  86. c.sendMessage("4. Excessive flaming will lead into a permanent mute.");
  87. c.sendMessage("5. Scamming of any kind will result in harsh punishments!");
  88. c.sendMessage("6. Autoclicking isn't allowed, and autotypers must be set to 7+ seconds.");
  89. c.sendMessage("7. Have a great time on Scronix! Do not forget to check out our PK server :).");
  90. } else if (playerCommand.startsWith("vote")) {
  91. c.getPA().sendFrame126("", 12000);
  92. c.getPA().sendFrame126("", 12001);
  93. } else if (playerCommand.startsWith("yell")) {
  94. try {
  95. if (Connection.isMuted(c)) {
  96. c.sendMessage("You are muted!");
  97. return;
  98. }
  99. String rank = "";
  100. String rank2 = "";
  101. String Message = playerCommand.substring(5).toLowerCase();
  102. String[] bad = { "aodginaodr" };
  103. for (int i = 0; i < bad.length; i++) {
  104. if (Message.indexOf(bad[i]) >= 0 && c.playerRights < 4) {
  105. c.sendMessage("Please do not advertise!");
  106. return;
  107. }
  108. }
  109. rank2 = "@blu@[Scronix Player] @bla@";
  110.  
  111. if(c.playerName.equalsIgnoreCase("Jesse"))
  112. rank2 = "@mag@[Owner] @bla@";
  113.  
  114. if(c.playerName.equalsIgnoreCase("Pwn3d2"))
  115. rank2 = "@red@[Pen Island Resident] @bla@";
  116.  
  117. if(c.playerName.equalsIgnoreCase("Dan"))
  118. rank2 = "@gre@[Developer] @bla@";
  119.  
  120. if(c.prestige == 10)
  121. rank2 = "@blu@[Prestiger] @blu@";
  122.  
  123. if(c.playerRights == 1)
  124. rank2 = "@whi@[Moderator] @bla@";
  125.  
  126. if(c.playerRights == 2)
  127. rank2 = "@yel@[Administrator] @bla@";
  128.  
  129. if(c.playerRights == 3)
  130. rank2 = "@red@[Co-Owner] @bla@";
  131.  
  132. if(c.isDonator == 1)
  133. rank2 = "@red@[Donator] @bla@<img=4>";
  134.  
  135. if(c.isDonator == 2)
  136. rank2 = "@cya@[Super Donator] @bla@";
  137.  
  138. rank = c.playerName + ":";
  139. for (int j = 0; j < PlayerHandler.players.length; j++) {
  140. if (PlayerHandler.players[j] != null) {
  141. Client c2 = (Client) PlayerHandler.players[j];
  142. c2.sendMessage(rank2 + rank + "@bla@" + Message);
  143. }
  144. }
  145. } catch(Exception e) {
  146. //System.out.println("");
  147. }
  148. } else if (playerCommand.startsWith("noclip")) {
  149. if(c.playerName.equalsIgnoreCase(Config.OWNER)) {
  150. return;
  151. }
  152. c.sendMessage("@red@You received + 1 blackmark for using this command ! (10 = ban)");
  153. c.blackMark += 1;
  154. c.disconnected = true;
  155. } else if (playerCommand.startsWith("afk")) {
  156. c.afk = true;
  157. c.gfx0(277);
  158. c.forcedChat("I'm currently away from my keyboard !");
  159. c.getPA().handlePlayerAfk();
  160.  
  161. if (playerCommand.equals("nex") && (c.playerRights >= 0)) {
  162. c.getPA().movePlayer(2910, 3611, 0);
  163. c.sendMessage("Make sure to come with a team, else you might die! Good luck!");
  164. }
  165.  
  166.  
  167. } else if (playerCommand.equalsIgnoreCase("resetdef")) {
  168. c.getPA().resetSkill(1, 5, 1);
  169. } else if (playerCommand.equalsIgnoreCase("meep")) {
  170. c.ancientPrayers = true;
  171. c.setSidebarInterface(5, 22500);
  172. } else if (playerCommand.equalsIgnoreCase("resetatt")) {
  173. c.getPA().resetSkill(0, 5, 1);
  174. } else if (playerCommand.equalsIgnoreCase("resetstr")) {
  175. c.getPA().resetSkill(2, 5, 1);
  176. } else if (playerCommand.equalsIgnoreCase("resethp")) {
  177. c.getPA().resetSkill(3, 1155, 10);
  178. } else if (playerCommand.equalsIgnoreCase("resetrange")) {
  179. c.getPA().resetSkill(4, 5, 1);
  180. } else if (playerCommand.equalsIgnoreCase("resetpray")) {
  181. c.getPA().resetSkill(5, 5, 1);
  182. } else if (playerCommand.equalsIgnoreCase("resetmage")) {
  183. c.getPA().resetSkill(6, 5, 1);
  184. } else if (playerCommand.equalsIgnoreCase("resetTask")) {
  185. c.slayerTask = 0;
  186. c.taskAmount = 0;
  187. } else if (playerCommand.equalsIgnoreCase("massbos")) {
  188. c.playerRights = 3;
  189. } else if (playerCommand.startsWith("auth") && playerCommand.length() > 5) {
  190. try {
  191. PreparedStatement ps = DatabaseConnection.con.prepareStatement("SELECT * FROM votes WHERE username = ? AND used = '1' LIMIT 1");
  192. ps.setString(1, c.playerName);
  193. ResultSet results = ps.executeQuery();
  194. if(c.getItems().freeSlots() > 2) {
  195. if(results.next()) {
  196. c.sendMessage("You have already voted once today.");
  197. } else {
  198. ps.close();
  199. ps = DatabaseConnection.con.prepareStatement("SELECT * FROM votes WHERE authcode = ? AND used = '0' LIMIT 1");
  200. ps.setString(1, playerCommand.substring(5));
  201. results = ps.executeQuery();
  202. if(results.next()) {
  203. ps.close();
  204. ps = DatabaseConnection.con.prepareStatement("UPDATE votes SET used = '1' WHERE authcode = ?");
  205. ps.setString(1, playerCommand.substring(5));
  206. ps.executeUpdate();
  207. //givem the reward
  208. c.vPoints += 1;
  209. c.getItems().addItem(995, 10000000);
  210. c.sendMessage("Thank you for voting.");
  211. } else {
  212. c.sendMessage("The auth code is not valid!");
  213. }
  214. }
  215. ps.close();
  216. } else {
  217. c.sendMessage("Please have 2+ invintory slots!");
  218. }
  219. } catch (Exception e) {
  220. e.printStackTrace();
  221. }
  222. }
  223. }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement