Java源码示例:codechicken.lib.config.ConfigFile

示例1
private static void loadConfig() {
    File file = new File(saveDir, "server.cfg");
    serverConfig = new ConfigFile(file);

    serverConfig.setNewLineMode(1);
    serverConfig.getTag("permissions").useBraces();
    serverConfig.getTag("permissions").setComment("List of players who can use these features.\nEg. time=CodeChicken, Friend1");

    setDefaultFeature("time");
    setDefaultFeature("rain");
    setDefaultFeature("heal");
    setDefaultFeature("magnet");
    setDefaultFeature("creative");
    setDefaultFeature("creative+");
    setDefaultFeature("adventure");
    setDefaultFeature("enchant");
    setDefaultFeature("potion");
    setDefaultFeature("save-state");
    setDefaultFeature("item");
    setDefaultFeature("delete");
    setDefaultFeature("notify-item", "CONSOLE, OP");
}
 
示例2
private static void loadConfig() {
    File file = new File(saveDir, "server.cfg");
    serverConfig = new ConfigFile(file);

    serverConfig.setNewLineMode(1);
    serverConfig.getTag("permissions").useBraces();
    serverConfig.getTag("permissions").setComment("List of players who can use these features.\nEg. time=CodeChicken, Friend1");

    setDefaultFeature("time");
    setDefaultFeature("rain");
    setDefaultFeature("heal");
    setDefaultFeature("magnet");
    setDefaultFeature("creative");
    setDefaultFeature("creative+");
    setDefaultFeature("adventure");
    setDefaultFeature("enchant");
    setDefaultFeature("potion");
    setDefaultFeature("save-state");
    setDefaultFeature("item");
    setDefaultFeature("delete");
    setDefaultFeature("notify-item", "CONSOLE, OP");
}
 
示例3
public static void loadWorld(String saveName) {
    setInternalEnabled(true);
    LogHelper.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
    //ItemMobSpawner.loadSpawners(ClientUtils.getWorld());

    File saveDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + saveName);
    boolean newWorld = !saveDir.exists();
    if (newWorld) {
        saveDir.mkdirs();
    }

    world = new ConfigSet(new File(saveDir, "NEI.dat"), new ConfigFile(new File(saveDir, "NEI.cfg")));
    onWorldLoad(newWorld);
}
 
示例4
public static void initConfig(ConfigFile config) {
    config.getTag("players").setPosition(0).useBraces().setComment("Per player chunk limiting. Values ignored if 0.:Simply add <username>=<value>");
    config.getTag("players.DEFAULT").setComment("Forge gives everyone 12500 by default").getIntValue(5000);
    config.getTag("players.OP").setComment("For server op's only.").getIntValue(5000);
    config.getTag("allowoffline").setPosition(1).useBraces().setComment("If set to false, players will have to be logged in for their chunkloaders to work.:Simply add <username>=<true|false>");
    config.getTag("allowoffline.DEFAULT").getBooleanValue(true);
    config.getTag("allowoffline.OP").getBooleanValue(true);
    config.getTag("allowchunkviewer").setPosition(2).useBraces().setComment("Set to false to deny a player access to the chunk viewer");
    config.getTag("allowchunkviewer.DEFAULT").getBooleanValue(true);
    config.getTag("allowchunkviewer.OP").getBooleanValue(true);
    if (!FMLCommonHandler.instance().getModName().contains("mcpc"))
        cleanupTicks = config.getTag("cleanuptime")
                .setComment("The number of ticks to wait between attempting to unload orphaned chunks")
                .getIntValue(1200);
    reloadDimensions = config.getTag("reload-dimensions")
            .setComment("Set to false to disable the automatic reloading of mystcraft dimensions on server restart")
            .getBooleanValue(true);
    opInteract = config.getTag("op-interact")
            .setComment("Enabling this lets OPs alter other player's chunkloaders. WARNING: If you change a chunkloader, you have no idea what may break/explode by not being chunkloaded.")
            .getBooleanValue(false);
    maxChunks = config.getTag("maxchunks")
            .setComment("The maximum number of chunks per chunkloader")
            .getIntValue(400);
    awayTimeout = config.getTag("awayTimeout")
            .setComment("The number of minutes since last login within which chunks from a player will remain active, 0 for infinite.")
            .getIntValue(0);
}
 
示例5
public static void loadWorld(String saveName) {
    setInternalEnabled(true);
    logger.debug("Loading "+(Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote")+" World");
    bootNEI(ClientUtils.getWorld());

    File saveDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + saveName);
    boolean newWorld = !saveDir.exists();
    if (newWorld)
        saveDir.mkdirs();

    world = new ConfigSet(new File(saveDir, "NEI.dat"), new ConfigFile(new File(saveDir, "NEI.cfg")));
    onWorldLoad(newWorld);
}
 
示例6
private static ConfigFile loadConfig() {
    try {//weak reference for environments without FML
        File mcDir = (File)((Object[])Class.forName("net.minecraftforge.fml.relauncher.FMLInjectionData").getMethod("data").invoke(null))[6];
        File file = new File(mcDir, "config/CodeChickenLib.cfg");
        if(ObfMapping.obfuscated)
            return new DefaultingConfigFile(file);
        else
            return new ConfigFile(file).setComment("CodeChickenLib development configuration file.");
    } catch (Exception ignored) {
        return null;//no config for these systems
    }
}
 
示例7
public static void loadConfig(ConfigFile config2) {
    config = config2;
    for (Entry<String, EnderStoragePlugin> plugin : plugins.entrySet())
        plugin.getValue().loadConfig(config.getTag(plugin.getKey()));
}
 
示例8
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    config = new ConfigFile(new File(CommonUtils.getMinecraftDir() + "/config", "EnderStorage.cfg")).setComment("EnderStorage Configuration File\nDeleting any element will restore it to it's default value\nBlock ID's will be automatically generated the first time it's run");

    proxy.preInit();
}
 
示例9
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    config = new ConfigFile(new File(event.getModConfigurationDirectory(), "ChickenChunks.cfg"))
            .setComment("ChunkLoader Configuration File\nDeleting any element will restore it to it's default value\nBlock ID's will be automatically generated the first time it's run");
}
 
示例10
public static void loadConfig() {
    if(config == null)
        config = new ConfigFile(new File(CodeChickenCorePlugin.minecraftDir, "config/CodeChickenCore.cfg")).setComment("CodeChickenCore configuration file.");
}
 
示例11
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    config = new ConfigFile(new File(CommonUtils.getMinecraftDir() + "/config", "Translocator.cfg")).setComment("Translocator Configuration File\nDeleting any element will restore it to it's default value\nBlock ID's will be automatically generated the first time it's run");
}
 
示例12
public static ConfigFile config()
{
    return globalconfig;
}