public void handleChat(Packet3Chat par1Packet3Chat) {
    ModLoader.serverChat(this, par1Packet3Chat.message);

    if (playerEntity.getChatVisibility() == 2) {
      sendPacketToPlayer(new Packet3Chat("Cannot send chat message."));
      return;
    }

    String s = par1Packet3Chat.message;

    if (s.length() > 100) {
      kickPlayerFromServer("Chat message too long");
      return;
    }

    s = s.trim();

    for (int i = 0; i < s.length(); i++) {
      if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) {
        kickPlayerFromServer("Illegal characters in chat");
        return;
      }
    }

    if (s.startsWith("/")) {
      func_72566_d(s);
    } else {
      if (playerEntity.getChatVisibility() == 1) {
        sendPacketToPlayer(new Packet3Chat("Cannot send chat message."));
        return;
      }

      s =
          (new StringBuilder())
              .append("<")
              .append(playerEntity.username)
              .append("> ")
              .append(s)
              .toString();
      logger.info(s);
      mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet3Chat(s, false));
    }

    chatSpamThresholdCount += 20;

    if (chatSpamThresholdCount > 200
        && !mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)) {
      kickPlayerFromServer("disconnect.spam");
    }
  }
Пример #2
0
  public void handleChat(Packet3Chat par1Packet3Chat) {
    if (this.playerEntity.func_71126_v() == 2) {
      this.sendPacket(new Packet3Chat("Cannot send chat message."));
    } else {
      String var2 = par1Packet3Chat.message;

      if (var2.length() > 100) {
        this.kickPlayer("Chat message too long");
      } else {
        var2 = var2.trim();

        for (int var3 = 0; var3 < var2.length(); ++var3) {
          if (!ChatAllowedCharacters.isAllowedCharacter(var2.charAt(var3))) {
            this.kickPlayer("Illegal characters in chat");
            return;
          }
        }

        if (var2.startsWith("/")) {
          this.handleSlashCommand(var2);
        } else {
          if (this.playerEntity.func_71126_v() == 1) {
            this.sendPacket(new Packet3Chat("Cannot send chat message."));
            return;
          }

          var2 = "<" + this.playerEntity.username + "> " + var2;
          logger.info(var2);
          this.mcServer
              .getConfigurationManager()
              .sendPacketToAllPlayers(new Packet3Chat(var2, false));
        }

        this.field_72581_m += 20;

        if (this.field_72581_m > 200
            && !this.mcServer.getConfigurationManager().isOp(this.playerEntity.username)) {
          this.kickPlayer("disconnect.spam");
        }
      }
    }
  }
Пример #3
0
  /** Call this method from you GuiScreen to process the keys into textbox. */
  public boolean textboxKeyTyped(char par1, int par2) {
    if (this.isEnabled && this.isFocused) {
      switch (par1) {
        case 1:
          this.setCursorPositionEnd();
          this.setSelectionPos(0);
          return true;

        case 3:
          GuiScreen.setClipboardString(this.getSelectedtext());
          return true;

        case 22:
          this.writeText(GuiScreen.getClipboardString());
          return true;

        case 24:
          GuiScreen.setClipboardString(this.getSelectedtext());
          this.writeText("");
          return true;

        default:
          switch (par2) {
            case 14:
              if (GuiScreen.isCtrlKeyDown()) {
                this.deleteWords(-1);
              } else {
                this.deleteFromCursor(-1);
              }

              return true;

            case 199:
              if (GuiScreen.isShiftKeyDown()) {
                this.setSelectionPos(0);
              } else {
                this.setCursorPositionZero();
              }

              return true;

            case 203:
              if (GuiScreen.isShiftKeyDown()) {
                if (GuiScreen.isCtrlKeyDown()) {
                  this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
                } else {
                  this.setSelectionPos(this.getSelectionEnd() - 1);
                }
              } else if (GuiScreen.isCtrlKeyDown()) {
                this.setCursorPosition(this.getNthWordFromCursor(-1));
              } else {
                this.moveCursorBy(-1);
              }

              return true;

            case 205:
              if (GuiScreen.isShiftKeyDown()) {
                if (GuiScreen.isCtrlKeyDown()) {
                  this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
                } else {
                  this.setSelectionPos(this.getSelectionEnd() + 1);
                }
              } else if (GuiScreen.isCtrlKeyDown()) {
                this.setCursorPosition(this.getNthWordFromCursor(1));
              } else {
                this.moveCursorBy(1);
              }

              return true;

            case 207:
              if (GuiScreen.isShiftKeyDown()) {
                this.setSelectionPos(this.text.length());
              } else {
                this.setCursorPositionEnd();
              }

              return true;

            case 211:
              if (GuiScreen.isCtrlKeyDown()) {
                this.deleteWords(1);
              } else {
                this.deleteFromCursor(1);
              }

              return true;

            default:
              if (ChatAllowedCharacters.isAllowedCharacter(par1)) {
                this.writeText(Character.toString(par1));
                return true;
              } else {
                return false;
              }
          }
      }
    } else {
      return false;
    }
  }