示例#1
0
  /**
   * @param sender
   * @param args
   */
  @Override
  public void dispatch(CommandSender sender, String[] args) {
    if (args.length >= 3) {
      plugin.logDebug("Dispatching notice command...");
      int msgIdx = 2;
      String target;
      java.util.List<PurpleBot> myBots = new ArrayList<>();
      if (plugin.ircBots.containsKey(args[1])) {
        myBots.add(plugin.ircBots.get(args[1]));
        msgIdx = 3;
        target = args[2];
      } else {
        myBots.addAll(plugin.ircBots.values());
        target = args[1];
      }

      if (msgIdx == 3 && args.length <= 3) {
        sender.sendMessage(fullUsage);
        return;
      }

      for (PurpleBot ircBot : myBots) {
        String msg = "";
        for (int i = msgIdx; i < args.length; i++) {
          msg = msg + " " + args[i];
        }
        ircBot.asyncNotice(target, msg.substring(1));
        sender.sendMessage(
            "Sent notice message \"" + msg.substring(1) + "\" to \"" + target + "\"");
      }
    } else {
      sender.sendMessage(fullUsage);
    }
  }
示例#2
0
  /** @param event */
  @Override
  public void onMode(ModeEvent event) {
    Channel channel = event.getChannel();
    String mode = event.getMode();
    User user = event.getUser();

    if (!ircBot.isValidChannel(channel.getName())) {
      ircBot.broadcastIRCMode(user.getNick(), mode, channel.getName());
    }
  }
  /** @param event */
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
    if (event.isCancelled()) {
      return;
    }
    String msg = event.getMessage();
    if (event.getPlayer().hasPermission("irc.message.gamechat")) {
      if (msg.startsWith("/me ")) {
        for (PurpleBot ircBot : plugin.ircBots.values()) {
          if (ircBot.isConnected()) {
            ircBot.gameAction(event.getPlayer(), msg.replace("/me", ""));
          }
        }
      } else if (msg.startsWith("/broadcast ")) {
        for (PurpleBot ircBot : plugin.ircBots.values()) {
          if (ircBot.isConnected()) {
            ircBot.gameBroadcast(event.getPlayer(), msg.replace("/broadcast", ""));
          }
        }
      }
    }
    for (PurpleBot ircBot : plugin.ircBots.values()) {
      if (ircBot.isConnected()) {
        if (msg.startsWith("/")) {
          String cmd;
          String params = "";
          if (msg.contains(" ")) {
            cmd = msg.split(" ", 2)[0];
            params = msg.split(" ", 2)[1];
          } else {
            cmd = msg;
          }

          cmd = cmd.substring(0);
          if (ircBot.isConnected()) {
            if (ircBot.channelCmdNotifyEnabled) {
              ircBot.commandNotify(event.getPlayer(), cmd, params);
            }
          }
        }
      }
    }
  }
 /**
  * @param sender
  * @param args
  */
 @Override
 public void dispatch(CommandSender sender, String[] args) {
   for (PurpleBot ircBot : plugin.ircBots.values()) {
     ircBot.reload(sender);
   }
 }