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");
    }
  }
  /** run once each game tick */
  public void networkTick() {
    field_72584_h = false;
    currentTicks++;
    mcServer.theProfiler.startSection("packetflow");
    theNetworkManager.processReadPackets();
    mcServer.theProfiler.endStartSection("keepAlive");

    if ((long) currentTicks - ticksOfLastKeepAlive > 20L) {
      ticksOfLastKeepAlive = currentTicks;
      keepAliveTimeSent = System.nanoTime() / 0xf4240L;
      keepAliveRandomID = randomGenerator.nextInt();
      sendPacketToPlayer(new Packet0KeepAlive(keepAliveRandomID));
    }

    if (chatSpamThresholdCount > 0) {
      chatSpamThresholdCount--;
    }

    if (creativeItemCreationSpamThresholdTally > 0) {
      creativeItemCreationSpamThresholdTally--;
    }

    mcServer.theProfiler.endStartSection("playerTick");

    if (!field_72584_h && !playerEntity.playerHasConqueredTheEnd) {
      playerEntity.onUpdateEntity();
    }

    mcServer.theProfiler.endSection();
  }
 public void kickPlayerFromServer(String par1Str) {
   if (serverShuttingDown) {
     return;
   } else {
     playerEntity.mountEntityAndWakeUp();
     sendPacketToPlayer(new Packet255KickDisconnect(par1Str));
     theNetworkManager.serverShutdown();
     mcServer
         .getConfigurationManager()
         .sendPacketToAllPlayers(
             new Packet3Chat(
                 (new StringBuilder())
                     .append("\247e")
                     .append(playerEntity.username)
                     .append(" left the game.")
                     .toString()));
     mcServer.getConfigurationManager().func_72367_e(playerEntity);
     serverShuttingDown = true;
     return;
   }
 }
  public void handlePlace(Packet15Place par1Packet15Place) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);
    ItemStack itemstack = playerEntity.inventory.getCurrentItem();
    boolean flag = false;
    int i = par1Packet15Place.getXPosition();
    int j = par1Packet15Place.getYPosition();
    int k = par1Packet15Place.getZPosition();
    int l = par1Packet15Place.getDirection();
    boolean flag1 =
        worldserver.actionsAllowed =
            worldserver.provider.worldType != 0
                || mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)
                || mcServer.isSinglePlayer();

    if (par1Packet15Place.getDirection() == 255) {
      if (itemstack == null) {
        return;
      }

      playerEntity.theItemInWorldManager.tryUseItem(playerEntity, worldserver, itemstack);
    } else if (par1Packet15Place.getYPosition() < mcServer.getBuildLimit() - 1
        || par1Packet15Place.getDirection() != 1
            && par1Packet15Place.getYPosition() < mcServer.getBuildLimit()) {
      ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
      int i1 = MathHelper.abs_int(i - chunkcoordinates.posX);
      int j1 = MathHelper.abs_int(k - chunkcoordinates.posZ);

      if (i1 > j1) {
        j1 = i1;
      }

      if (field_72587_r
          && playerEntity.getDistanceSq((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D)
              < 64D
          && (j1 > 16 || flag1)) {
        playerEntity.theItemInWorldManager.activateBlockOrUseItem(
            playerEntity,
            worldserver,
            itemstack,
            i,
            j,
            k,
            l,
            par1Packet15Place.getXOffset(),
            par1Packet15Place.getYOffset(),
            par1Packet15Place.getZOffset());
      }

      flag = true;
    } else {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet3Chat(
              (new StringBuilder())
                  .append("\2477Height limit for building is ")
                  .append(mcServer.getBuildLimit())
                  .toString()));
      flag = true;
    }

    if (flag) {
      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));

      if (l == 0) {
        j--;
      }

      if (l == 1) {
        j++;
      }

      if (l == 2) {
        k--;
      }

      if (l == 3) {
        k++;
      }

      if (l == 4) {
        i--;
      }

      if (l == 5) {
        i++;
      }

      playerEntity.serverForThisPlayer.sendPacketToPlayer(
          new Packet53BlockChange(i, j, k, worldserver));
    }

    itemstack = playerEntity.inventory.getCurrentItem();

    if (itemstack != null && itemstack.stackSize == 0) {
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
      itemstack = null;
    }

    if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) {
      playerEntity.playerInventoryBeingManipulated = true;
      playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] =
          ItemStack.copyItemStack(
              playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]);
      Slot slot =
          playerEntity.craftingInventory.getSlotFromInventory(
              playerEntity.inventory, playerEntity.inventory.currentItem);
      playerEntity.craftingInventory.updateCraftingResults();
      playerEntity.playerInventoryBeingManipulated = false;

      if (!ItemStack.areItemStacksEqual(
          playerEntity.inventory.getCurrentItem(), par1Packet15Place.getItemStack())) {
        sendPacketToPlayer(
            new Packet103SetSlot(
                playerEntity.craftingInventory.windowId,
                slot.slotNumber,
                playerEntity.inventory.getCurrentItem()));
      }
    }

    worldserver.actionsAllowed = false;
  }