• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java JSONConfigurationLoader类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中ninja.leaping.configurate.json.JSONConfigurationLoader的典型用法代码示例。如果您正苦于以下问题:Java JSONConfigurationLoader类的具体用法?Java JSONConfigurationLoader怎么用?Java JSONConfigurationLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

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

示例1: load

点赞 3

import ninja.leaping.configurate.json.JSONConfigurationLoader; //导入依赖的package包/类
public static JsonConfigFile load(@Nonnull final Path path,
                                  @Nullable final String resource,
                                  final boolean overwrite) throws IOException {
    if (overwrite) {
        Files.deleteIfExists(path);
    }

    if (!Files.exists(path)) {
        Files.createDirectories(path.getParent());
        Files.copy(JsonConfigFile.class.getResourceAsStream(resource), path);
    }

    final JSONConfigurationLoader fileLoader = JSONConfigurationLoader.builder().setPath(path).build();

    return new JsonConfigFile(path, fileLoader, fileLoader.load());
}
 

开发者ID:FerusTech,
项目名称:Amicus,
代码行数:17,
代码来源:JsonConfigFile.java

示例2: PackagedSpriteSheetFactory

点赞 3

import ninja.leaping.configurate.json.JSONConfigurationLoader; //导入依赖的package包/类
public PackagedSpriteSheetFactory(String name, MultiRenderer renderer, ZipFile sourceFile) {
    this.name = name;
    this.renderer = renderer;
    this.sourceFile = sourceFile;

    this.sprites = new ObjectMap<>();

    InputStream configStream = null; // load the configuration json inside the archive for later reading
    try {
        configStream = sourceFile.getInputStream(sourceFile.getEntry(ENTRY_SHEETCONFIG));
        BufferedReader reader = new BufferedReader(new InputStreamReader(configStream));
        JSONConfigurationLoader loader = JSONConfigurationLoader.builder().setSource(() -> {
            return reader;
        }).build();

        sheetConfig = loader.load();
    } catch (IOException e) {
        log.error("Failed to load packaged spritesheet data", e);
    } finally {
        StreamUtil.closeQuietly(configStream);
    }
}
 

开发者ID:Xemiru,
项目名称:Undertailor,
代码行数:23,
代码来源:PackagedSpriteSheetFactory.java

示例3: Font

点赞 2

import ninja.leaping.configurate.json.JSONConfigurationLoader; //导入依赖的package包/类
public Font(String fontName, MultiRenderer renderer, ZipFile sourceFile)
    throws BadAssetException {
    PackagedSpriteSheetFactory sheetFactory =
        new PackagedSpriteSheetFactory("#fnt-" + fontName, renderer, sourceFile);
    this.sheet = sheetFactory.getResource();
    this.letterSpacing = new ObjectMap<>();
    this.renderer = renderer;

    InputStream configStream = null; // load the configuration json inside the archive for later reading
    try {
        ZipEntry configEntry = sourceFile.getEntry(ENTRY_FONT_CONFIG);
        if (configEntry == null)
            throw new BadAssetException("Font file does not contain font configuration");

        configStream = sourceFile.getInputStream(configEntry);
        BufferedReader reader = new BufferedReader(new InputStreamReader(configStream));
        JSONConfigurationLoader loader = JSONConfigurationLoader.builder().setSource(() -> {
            return reader;
        }).build();

        this.loadConfig(loader.load());
    } catch (IOException e) {
        BadAssetException thrown = new BadAssetException();
        thrown.initCause(e);
        throw thrown;
    } finally {
        StreamUtil.closeQuietly(configStream);
    }
}
 

开发者ID:Xemiru,
项目名称:Undertailor,
代码行数:30,
代码来源:Font.java

示例4: dataContainerToJSONObject

点赞 2

import ninja.leaping.configurate.json.JSONConfigurationLoader; //导入依赖的package包/类
public static JSONObject dataContainerToJSONObject(DataContainer container) {
    ConfigurationNode node = DataTranslators.CONFIGURATION_NODE.translate(container);
    StringWriter writer = new StringWriter();
    try {
        JSONConfigurationLoader.builder().build().saveInternal(node, writer);
        JSONObject data = new JSONObject(writer.toString());
        cleanData(data);
        return data;
    } catch (IOException e) {
        return new JSONObject();
    }
}
 

开发者ID:BadgeUp,
项目名称:badgeup-sponge-client,
代码行数:13,
代码来源:ObjectSerializers.java

示例5: JsonDataSource

点赞 2

import ninja.leaping.configurate.json.JSONConfigurationLoader; //导入依赖的package包/类
private JsonDataSource(@NotNull JSONConfigurationLoader loader, @NotNull SerializerSet serializerSet) {
    super(loader, serializerSet, false);
}
 

开发者ID:dumptruckman,
项目名称:dtmlibs,
代码行数:4,
代码来源:JsonDataSource.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)