Beispiel #1
0
  private void handleCommand(String s) {
    // CraftBukkit start
    CraftPlayer player = (CraftPlayer) getPlayer();

    PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s);
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
      return;
    }

    try {
      if (server.dispatchCommand(player, s.substring(1))) {
        return;
      }
    } catch (CommandException ex) {
      player.sendMessage(
          ChatColor.RED + "An internal error occurred while attempting to perform this command");
      Logger.getLogger(NetServerHandler.class.getName()).log(Level.SEVERE, null, ex);
      return;
    }
    // CraftBukkit end

    if (s.toLowerCase().startsWith("/me ")) {
      s = "* " + this.player.name + " " + s.substring(s.indexOf(" ")).trim();
      a.info(s);
      this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(s));
    } else if (s.toLowerCase().startsWith("/kill")) {
      this.player.damageEntity((Entity) null, 1000);
    } else if (s.toLowerCase().startsWith("/tell ")) {
      String[] astring = s.split(" ");

      if (astring.length >= 3) {
        s = s.substring(s.indexOf(" ")).trim();
        s = s.substring(s.indexOf(" ")).trim();
        s = "\u00A77" + this.player.name + " whispers " + s;
        a.info(s + " to " + astring[1]);
        if (!this.minecraftServer.serverConfigurationManager.a(
            astring[1], (Packet) (new Packet3Chat(s)))) {
          this.sendPacket(new Packet3Chat("\u00A7cThere\'s no player by that name online."));
        }
      }

      /* CraftBukkit start - No longer neaded av we have already handled it server.dispatchCommand above.
      } else {
          String s1;

          if (this.minecraftServer.serverConfigurationManager.isOp(this.player.name)) {
              s1 = s.substring(1);
              a.info(this.player.name + " issued server command: " + s1);
              this.minecraftServer.issueCommand(s1, this);
          } else {
              s1 = s.substring(1);
              a.info(this.player.name + " tried command: " + s1);
          }
      */
      // CraftBukkit end
    }
  }