Пример #1
0
 /** Get the formatted ChatComponent that will be used for the sender's username in chat */
 public IChatComponent getDisplayName() {
   if (this.hasCustomName()) {
     ChatComponentText chatcomponenttext = new ChatComponentText(this.entityName);
     chatcomponenttext.getChatStyle().setChatHoverEvent(this.getHoverEvent());
     chatcomponenttext.getChatStyle().setInsertion(this.getUniqueID().toString());
     return chatcomponenttext;
   } else {
     ChatComponentTranslation chatcomponenttranslation =
         new ChatComponentTranslation(this.getName(), new Object[0]);
     chatcomponenttranslation.getChatStyle().setChatHoverEvent(this.getHoverEvent());
     chatcomponenttranslation.getChatStyle().setInsertion(this.getUniqueID().toString());
     return chatcomponenttranslation;
   }
 }
Пример #2
0
  public static void sendNotice(ICommandSender sender, IChatComponent msg, String permission) {
    ChatComponentTranslation notice =
        new ChatComponentTranslation("chat.type.admin", sender.getName(), msg.createCopy());
    notice.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true);

    if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission)) {
      MinecraftServer.getServer().addChatMessage(notice);
    }

    for (EntityPlayer p : ServerUtils.getPlayers()) {
      if (p == sender) {
        p.addChatComponentMessage(msg);
      } else if (NEIServerConfig.canPlayerPerformAction(p.getName(), permission)) {
        p.addChatComponentMessage(notice);
      }
    }
  }
 // Couple of helpers because the mcp names are stupid and long...
 private ChatComponentTranslation format(EnumChatFormatting color, String str, Object... args) {
   ChatComponentTranslation ret = new ChatComponentTranslation(str, args);
   ret.func_150256_b().func_150238_a(color);
   return ret;
 }
Пример #4
0
  @Override
  public void processCommand(ICommandSender icommandsender, String[] astring) {
    if (!icommandsender.canCommandSenderUseCommand(
            getRequiredPermissionLevel(), this.getCommandName())
        && !MinecraftServer.getServer().isSinglePlayer()) {
      ChatComponentTranslation chatTranslation =
          new ChatComponentTranslation("commands.generic.permission", new Object[0]);
      MinecraftServer.getServer().addChatMessage(chatTranslation);
      icommandsender.addChatMessage(
          new ChatComponentText(chatTranslation.getUnformattedTextForChat()));
    } else {
      int playerX = 0;
      int playerY = 0;
      int playerZ = 0;
      if (!icommandsender.getCommandSenderName().equalsIgnoreCase("Rcon")) {
        EntityPlayer ep =
            MinecraftServer.getServer()
                .worldServerForDimension(0)
                .getPlayerEntityByName(icommandsender.getCommandSenderName());
        ChunkCoordinates cc = icommandsender.getPlayerCoordinates();
        playerX = cc.posX;
        playerY = cc.posY;
        playerZ = cc.posZ;
      }
      if (astring.length == 0 || astring[0].equalsIgnoreCase("help")) {
        ChatComponentTranslation chatTranslation =
            new ChatComponentTranslation(getCommandUsage(icommandsender), new Object[0]);
        MinecraftServer.getServer().addChatMessage(chatTranslation);
        icommandsender.addChatMessage(
            new ChatComponentText(chatTranslation.getUnformattedTextForChat()));
      } else if (astring[0].equalsIgnoreCase("stop")) {
        Reference.toGenerate.clear();
        ChatComponentTranslation chatTranslation = new ChatComponentTranslation("commands.stopped");
        MinecraftServer.getServer().addChatMessage(chatTranslation);
        icommandsender.addChatMessage(
            new ChatComponentText(chatTranslation.getUnformattedTextForChat()));
      } else {
        try {
          int x = 0;
          int z = 0;
          if (astring[0].equalsIgnoreCase("~")) {
            x = playerX / 16;
          } else {
            x = Integer.parseInt(astring[0]);
          }
          if (astring[1].equalsIgnoreCase("~")) {
            z = playerZ / 16;
          } else {
            z = Integer.parseInt(astring[1]);
          }
          int height = Integer.parseInt(astring[2]);
          int width = Integer.parseInt(astring[3]);
          int dimensionID = icommandsender.getEntityWorld().provider.dimensionId;
          if (astring.length == 5) {
            dimensionID = Integer.parseInt(astring[4]);
          }

          Utilities.queueChunkGeneration(icommandsender, 0, x, z, height, width, dimensionID);
        } catch (NumberFormatException e) {
          e.printStackTrace();
          ChatComponentTranslation chatTranslation =
              new ChatComponentTranslation("commands.numberFormatException");
          MinecraftServer.getServer().addChatMessage(chatTranslation);
          icommandsender.addChatMessage(
              new ChatComponentText(chatTranslation.getUnformattedTextForChat()));
        } catch (Exception e) {
          e.printStackTrace();
          ChatComponentTranslation chatTranslation =
              new ChatComponentTranslation("commands.failed");
          MinecraftServer.getServer().addChatMessage(chatTranslation);
          icommandsender.addChatMessage(
              new ChatComponentText(chatTranslation.getUnformattedTextForChat()));
        }
      }
    }
  }
  public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP playerIn) {
    GameProfile var3 = playerIn.getGameProfile();
    PlayerProfileCache var4 = this.mcServer.getPlayerProfileCache();
    GameProfile var5 = var4.func_152652_a(var3.getId());
    String var6 = var5 == null ? var3.getName() : var5.getName();
    var4.func_152649_a(var3);
    NBTTagCompound var7 = this.readPlayerDataFromFile(playerIn);
    playerIn.setWorld(this.mcServer.worldServerForDimension(playerIn.dimension));
    playerIn.theItemInWorldManager.setWorld((WorldServer) playerIn.worldObj);
    String var8 = "local";

    if (netManager.getRemoteAddress() != null) {
      var8 = netManager.getRemoteAddress().toString();
    }

    logger.info(
        playerIn.getName()
            + "["
            + var8
            + "] logged in with entity id "
            + playerIn.getEntityId()
            + " at ("
            + playerIn.posX
            + ", "
            + playerIn.posY
            + ", "
            + playerIn.posZ
            + ")");
    WorldServer var9 = this.mcServer.worldServerForDimension(playerIn.dimension);
    WorldInfo var10 = var9.getWorldInfo();
    BlockPos var11 = var9.getSpawnPoint();
    this.func_72381_a(playerIn, (EntityPlayerMP) null, var9);
    NetHandlerPlayServer var12 = new NetHandlerPlayServer(this.mcServer, netManager, playerIn);
    var12.sendPacket(
        new S01PacketJoinGame(
            playerIn.getEntityId(),
            playerIn.theItemInWorldManager.getGameType(),
            var10.isHardcoreModeEnabled(),
            var9.provider.getDimensionId(),
            var9.getDifficulty(),
            this.getMaxPlayers(),
            var10.getTerrainType(),
            var9.getGameRules().getGameRuleBooleanValue("reducedDebugInfo")));
    var12.sendPacket(
        new S3FPacketCustomPayload(
            "MC|Brand",
            (new PacketBuffer(Unpooled.buffer()))
                .writeString(this.getServerInstance().getServerModName())));
    var12.sendPacket(
        new S41PacketServerDifficulty(var10.getDifficulty(), var10.isDifficultyLocked()));
    var12.sendPacket(new S05PacketSpawnPosition(var11));
    var12.sendPacket(new S39PacketPlayerAbilities(playerIn.capabilities));
    var12.sendPacket(new S09PacketHeldItemChange(playerIn.inventory.currentItem));
    playerIn.getStatFile().func_150877_d();
    playerIn.getStatFile().func_150884_b(playerIn);
    this.func_96456_a((ServerScoreboard) var9.getScoreboard(), playerIn);
    this.mcServer.refreshStatusNextTick();
    ChatComponentTranslation var13;

    if (!playerIn.getName().equalsIgnoreCase(var6)) {
      var13 =
          new ChatComponentTranslation(
              "multiplayer.player.joined.renamed", new Object[] {playerIn.getDisplayName(), var6});
    } else {
      var13 =
          new ChatComponentTranslation(
              "multiplayer.player.joined", new Object[] {playerIn.getDisplayName()});
    }

    var13.getChatStyle().setColor(EnumChatFormatting.YELLOW);
    this.sendChatMsg(var13);
    this.playerLoggedIn(playerIn);
    var12.setPlayerLocation(
        playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    this.updateTimeAndWeatherForPlayer(playerIn, var9);

    if (this.mcServer.getResourcePackUrl().length() > 0) {
      playerIn.func_175397_a(
          this.mcServer.getResourcePackUrl(), this.mcServer.getResourcePackHash());
    }

    Iterator var14 = playerIn.getActivePotionEffects().iterator();

    while (var14.hasNext()) {
      PotionEffect var15 = (PotionEffect) var14.next();
      var12.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), var15));
    }

    playerIn.addSelfToInternalCraftingInventory();

    if (var7 != null && var7.hasKey("Riding", 10)) {
      Entity var16 = EntityList.createEntityFromNBT(var7.getCompoundTag("Riding"), var9);

      if (var16 != null) {
        var16.forceSpawn = true;
        var9.spawnEntityInWorld(var16);
        playerIn.mountEntity(var16);
        var16.forceSpawn = false;
      }
    }
  }