PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Trunk/src/net/sf/odinms/client/NinjaMS/IRCStuff/Commands/IRCCommands.java

https://github.com/system32/NinjaMS
Java | 116 lines | 102 code | 6 blank | 8 comment | 53 complexity | 0c5585d05e317357fa72801f4d93916f MD5 | raw file
Possible License(s): AGPL-3.0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package net.sf.odinms.client.NinjaMS.IRCStuff.Commands;
  6. import java.util.List;
  7. import net.sf.odinms.client.MapleCharacter;
  8. import net.sf.odinms.client.NinjaMS.IRCStuff.MainIRC;
  9. import net.sf.odinms.client.NinjaMS.Processors.CharInfoProcessor;
  10. import net.sf.odinms.client.NinjaMS.Processors.ConnectedProcessor;
  11. import net.sf.odinms.client.NinjaMS.Processors.SearchProcessor;
  12. import net.sf.odinms.net.channel.ChannelServer;
  13. import net.sf.odinms.net.world.remote.WorldLocation;
  14. import net.sf.odinms.tools.StringUtil;
  15. /**
  16. *
  17. * @author Owner
  18. */
  19. class IRCCommands {
  20. static void execute(String sender, String[] splitted, String channel) {
  21. String command = splitted[0];
  22. if (command.equalsIgnoreCase("commands")) {
  23. ircMsg(sender, "You should bang a wall and get Raped by AJ");
  24. } else if (command.equalsIgnoreCase("connected")) {
  25. ircMsg(channel, ConnectedProcessor.getConnected());
  26. } else if (command.equalsIgnoreCase("onlineall")) {
  27. int i = 0;
  28. while (i < ChannelServer.getAllInstances().size()) {
  29. i++;
  30. ircMsg(channel, ConnectedProcessor.getOnline(i));
  31. }
  32. } else if (command.equalsIgnoreCase("online")) {
  33. if (splitted.length != 2) {
  34. ircMsg(channel, sender + " is a retard. Syntax : !online <channel number>");
  35. } else {
  36. int chan = Integer.parseInt(splitted[1]);
  37. ircMsg(channel, ConnectedProcessor.getOnline(chan));
  38. }
  39. } else if (command.equalsIgnoreCase("ninjaglare")) {
  40. MapleCharacter other = null;
  41. try {
  42. WorldLocation loc = ChannelServer.getInstance(1).getWorldInterface().getLocation(splitted[1]);
  43. if (loc != null) {
  44. other = ChannelServer.getInstance(loc.channel).getPlayerStorage().getCharacterByName(splitted[1]);
  45. } else {
  46. ircMsg(sender, splitted[1] + "' does not exist, is CCing, or is offline.");
  47. }
  48. } catch (Exception e) {
  49. ircMsg(sender, splitted[1] + "' does not exist, is CCing, or is offline.");
  50. }
  51. for (String lol : CharInfoProcessor.getNinjaGlare(other)) {
  52. ircMsg(sender, lol);
  53. }
  54. } else if (command.equalsIgnoreCase("playercommands")) {
  55. ircMsg(sender, "Under Construction");
  56. } else if (command.equalsIgnoreCase("itemid")) {
  57. List<String> ids = SearchProcessor.getItemId(StringUtil.joinStringFrom(splitted, 1));
  58. if (ids != null && ids.size() > 0) {
  59. for (String id : ids) {
  60. ircMsg(sender, id);
  61. }
  62. }
  63. } else if (command.equalsIgnoreCase("mapid")) {
  64. List<String> ids = SearchProcessor.getMapId(StringUtil.joinStringFrom(splitted, 1));
  65. if (ids != null && ids.size() > 0) {
  66. for (String id : ids) {
  67. ircMsg(sender, id);
  68. }
  69. }
  70. } else if (command.equalsIgnoreCase("mobid")) {
  71. List<String> ids = SearchProcessor.getMobId(StringUtil.joinStringFrom(splitted, 1));
  72. if (ids != null && ids.size() > 0) {
  73. for (String id : ids) {
  74. ircMsg(sender, id);
  75. }
  76. }
  77. } else if (command.equalsIgnoreCase("npcid")) {
  78. List<String> ids = SearchProcessor.getItemId(StringUtil.joinStringFrom(splitted, 1));
  79. if (ids != null && ids.size() > 0) {
  80. for (String id : ids) {
  81. ircMsg(sender, id);
  82. }
  83. }
  84. } else if (command.equalsIgnoreCase("whodrops")) {
  85. int itemid = Integer.parseInt(splitted[1]);
  86. List<String> ret = SearchProcessor.whoDrops(itemid);
  87. if (ret != null && ret.size() > 0) {
  88. for (String id : ret) {
  89. ircMsg(sender, id);
  90. }
  91. }
  92. } else if (command.equalsIgnoreCase("roulette")) {
  93. double lol = Math.random() * 100;
  94. if (lol > 50) {
  95. ircMsg(channel, " You seem to be lucky today. :p");
  96. } else {
  97. kick(channel, sender, "You are such a unlucky fag");
  98. }
  99. }
  100. }
  101. private static void ircMsg(String message) {
  102. MainIRC.getInstance().sendIrcMessage(message);
  103. }
  104. private static void ircMsg(String target, String message) {
  105. MainIRC.getInstance().sendMessage(target, message);
  106. }
  107. private static void kick(String channel, String sender, String reason) {
  108. MainIRC.getInstance().kick(channel, sender, reason);
  109. }
  110. }