Beispiel #1
0
    public JsonElement serialize(
        IChatComponent p_serialize_1_,
        Type p_serialize_2_,
        JsonSerializationContext p_serialize_3_) {
      if (p_serialize_1_ instanceof ChatComponentText
          && p_serialize_1_.getChatStyle().isEmpty()
          && p_serialize_1_.getSiblings().isEmpty()) {
        return new JsonPrimitive(
            ((ChatComponentText) p_serialize_1_).getChatComponentText_TextValue());
      } else {
        JsonObject var4 = new JsonObject();

        if (!p_serialize_1_.getChatStyle().isEmpty()) {
          this.serializeChatStyle(p_serialize_1_.getChatStyle(), var4, p_serialize_3_);
        }

        if (!p_serialize_1_.getSiblings().isEmpty()) {
          JsonArray var5 = new JsonArray();
          Iterator var6 = p_serialize_1_.getSiblings().iterator();

          while (var6.hasNext()) {
            IChatComponent var7 = (IChatComponent) var6.next();
            var5.add(this.serialize(var7, var7.getClass(), p_serialize_3_));
          }

          var4.add("extra", var5);
        }

        if (p_serialize_1_ instanceof ChatComponentText) {
          var4.addProperty(
              "text", ((ChatComponentText) p_serialize_1_).getChatComponentText_TextValue());
        } else if (p_serialize_1_ instanceof ChatComponentTranslation) {
          ChatComponentTranslation var11 = (ChatComponentTranslation) p_serialize_1_;
          var4.addProperty("translate", var11.getKey());

          if (var11.getFormatArgs() != null && var11.getFormatArgs().length > 0) {
            JsonArray var14 = new JsonArray();
            Object[] var16 = var11.getFormatArgs();
            int var8 = var16.length;

            for (int var9 = 0; var9 < var8; ++var9) {
              Object var10 = var16[var9];

              if (var10 instanceof IChatComponent) {
                var14.add(this.serialize((IChatComponent) var10, var10.getClass(), p_serialize_3_));
              } else {
                var14.add(new JsonPrimitive(String.valueOf(var10)));
              }
            }

            var4.add("with", var14);
          }
        } else if (p_serialize_1_ instanceof ChatComponentScore) {
          ChatComponentScore var12 = (ChatComponentScore) p_serialize_1_;
          JsonObject var15 = new JsonObject();
          var15.addProperty("name", var12.func_179995_g());
          var15.addProperty("objective", var12.func_179994_h());
          var15.addProperty("value", var12.getUnformattedTextForChat());
          var4.add("score", var15);
        } else {
          if (!(p_serialize_1_ instanceof ChatComponentSelector)) {
            throw new IllegalArgumentException(
                "Don\'t know how to serialize " + p_serialize_1_ + " as a Component");
          }

          ChatComponentSelector var13 = (ChatComponentSelector) p_serialize_1_;
          var4.addProperty("selector", var13.func_179992_g());
        }

        return var4;
      }
    }