当前位置: 首页>>代码示例>>Java>>正文


Java JsonUtils.isJsonArray方法代码示例

本文整理汇总了Java中net.minecraft.util.JsonUtils.isJsonArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.isJsonArray方法的具体用法?Java JsonUtils.isJsonArray怎么用?Java JsonUtils.isJsonArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.JsonUtils的用法示例。


在下文中一共展示了JsonUtils.isJsonArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public ServerStatusResponse.PlayerCountData deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
    ServerStatusResponse.PlayerCountData serverstatusresponse$playercountdata = new ServerStatusResponse.PlayerCountData(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));

    if (JsonUtils.isJsonArray(jsonobject, "sample"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");

        if (jsonarray.size() > 0)
        {
            GameProfile[] agameprofile = new GameProfile[jsonarray.size()];

            for (int i = 0; i < agameprofile.length; ++i)
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
                String s = JsonUtils.getString(jsonobject1, "id");
                agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
            }

            serverstatusresponse$playercountdata.setPlayers(agameprofile);
        }
    }

    return serverstatusresponse$playercountdata;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:ServerStatusResponse.java

示例2: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public ServerStatusResponse.Players deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
{
    JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
    ServerStatusResponse.Players serverstatusresponse$players = new ServerStatusResponse.Players(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));

    if (JsonUtils.isJsonArray(jsonobject, "sample"))
    {
        JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");

        if (jsonarray.size() > 0)
        {
            GameProfile[] agameprofile = new GameProfile[jsonarray.size()];

            for (int i = 0; i < agameprofile.length; ++i)
            {
                JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
                String s = JsonUtils.getString(jsonobject1, "id");
                agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
            }

            serverstatusresponse$players.setPlayers(agameprofile);
        }
    }

    return serverstatusresponse$players;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:ServerStatusResponse.java

示例3: parseGroup

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public void parseGroup(TextureManager p_152765_1_, ResourceLocation p_152765_2_) throws JsonException, IOException, JsonSyntaxException
{
    JsonParser jsonparser = new JsonParser();
    InputStream inputstream = null;

    try
    {
        IResource iresource = this.resourceManager.getResource(p_152765_2_);
        inputstream = iresource.getInputStream();
        JsonObject jsonobject = jsonparser.parse(IOUtils.toString(inputstream, Charsets.UTF_8)).getAsJsonObject();

        if (JsonUtils.isJsonArray(jsonobject, "targets"))
        {
            JsonArray jsonarray = jsonobject.getAsJsonArray("targets");
            int i = 0;

            for (JsonElement jsonelement : jsonarray)
            {
                try
                {
                    this.initTarget(jsonelement);
                }
                catch (Exception exception1)
                {
                    JsonException jsonexception1 = JsonException.func_151379_a(exception1);
                    jsonexception1.func_151380_a("targets[" + i + "]");
                    throw jsonexception1;
                }

                ++i;
            }
        }

        if (JsonUtils.isJsonArray(jsonobject, "passes"))
        {
            JsonArray jsonarray1 = jsonobject.getAsJsonArray("passes");
            int j = 0;

            for (JsonElement jsonelement1 : jsonarray1)
            {
                try
                {
                    this.parsePass(p_152765_1_, jsonelement1);
                }
                catch (Exception exception)
                {
                    JsonException jsonexception2 = JsonException.func_151379_a(exception);
                    jsonexception2.func_151380_a("passes[" + j + "]");
                    throw jsonexception2;
                }

                ++j;
            }
        }
    }
    catch (Exception exception2)
    {
        JsonException jsonexception = JsonException.func_151379_a(exception2);
        jsonexception.func_151381_b(p_152765_2_.getResourcePath());
        throw jsonexception;
    }
    finally
    {
        IOUtils.closeQuietly(inputstream);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:67,代码来源:ShaderGroup.java

示例4: deserialize

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public static SetAttributes.Modifier deserialize(JsonObject jsonObj, JsonDeserializationContext context)
{
    String s = JsonUtils.getString(jsonObj, "name");
    String s1 = JsonUtils.getString(jsonObj, "attribute");
    int i = getOperationFromInt(JsonUtils.getString(jsonObj, "operation"));
    RandomValueRange randomvaluerange = (RandomValueRange)JsonUtils.deserializeClass(jsonObj, "amount", context, RandomValueRange.class);
    UUID uuid = null;
    EntityEquipmentSlot[] aentityequipmentslot;

    if (JsonUtils.isString(jsonObj, "slot"))
    {
        aentityequipmentslot = new EntityEquipmentSlot[] {EntityEquipmentSlot.fromString(JsonUtils.getString(jsonObj, "slot"))};
    }
    else
    {
        if (!JsonUtils.isJsonArray(jsonObj, "slot"))
        {
            throw new JsonSyntaxException("Invalid or missing attribute modifier slot; must be either string or array of strings.");
        }

        JsonArray jsonarray = JsonUtils.getJsonArray(jsonObj, "slot");
        aentityequipmentslot = new EntityEquipmentSlot[jsonarray.size()];
        int j = 0;

        for (JsonElement jsonelement : jsonarray)
        {
            aentityequipmentslot[j++] = EntityEquipmentSlot.fromString(JsonUtils.getString(jsonelement, "slot"));
        }

        if (aentityequipmentslot.length == 0)
        {
            throw new JsonSyntaxException("Invalid attribute modifier slot; must contain at least one entry.");
        }
    }

    if (jsonObj.has("id"))
    {
        String s2 = JsonUtils.getString(jsonObj, "id");

        try
        {
            uuid = UUID.fromString(s2);
        }
        catch (IllegalArgumentException var12)
        {
            throw new JsonSyntaxException("Invalid attribute modifier id \'" + s2 + "\' (must be UUID format, with dashes)");
        }
    }

    return new SetAttributes.Modifier(s, s1, i, randomvaluerange, aentityequipmentslot, uuid);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:SetAttributes.java

示例5: parseGroup

import net.minecraft.util.JsonUtils; //导入方法依赖的package包/类
public void parseGroup(TextureManager p_152765_1_, ResourceLocation p_152765_2_) throws JsonException, IOException, JsonSyntaxException
{
    JsonParser jsonparser = new JsonParser();
    IResource iresource = null;

    try
    {
        iresource = this.resourceManager.getResource(p_152765_2_);
        JsonObject jsonobject = jsonparser.parse(IOUtils.toString(iresource.getInputStream(), Charsets.UTF_8)).getAsJsonObject();

        if (JsonUtils.isJsonArray(jsonobject, "targets"))
        {
            JsonArray jsonarray = jsonobject.getAsJsonArray("targets");
            int i = 0;

            for (JsonElement jsonelement : jsonarray)
            {
                try
                {
                    this.initTarget(jsonelement);
                }
                catch (Exception exception1)
                {
                    JsonException jsonexception1 = JsonException.forException(exception1);
                    jsonexception1.prependJsonKey("targets[" + i + "]");
                    throw jsonexception1;
                }

                ++i;
            }
        }

        if (JsonUtils.isJsonArray(jsonobject, "passes"))
        {
            JsonArray jsonarray1 = jsonobject.getAsJsonArray("passes");
            int j = 0;

            for (JsonElement jsonelement1 : jsonarray1)
            {
                try
                {
                    this.parsePass(p_152765_1_, jsonelement1);
                }
                catch (Exception exception)
                {
                    JsonException jsonexception2 = JsonException.forException(exception);
                    jsonexception2.prependJsonKey("passes[" + j + "]");
                    throw jsonexception2;
                }

                ++j;
            }
        }
    }
    catch (Exception exception2)
    {
        JsonException jsonexception = JsonException.forException(exception2);
        jsonexception.setFilenameAndFlush(p_152765_2_.getResourcePath());
        throw jsonexception;
    }
    finally
    {
        IOUtils.closeQuietly((Closeable)iresource);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:66,代码来源:ShaderGroup.java


注:本文中的net.minecraft.util.JsonUtils.isJsonArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。