當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationNode類代碼示例

本文整理匯總了Java中ninja.leaping.configurate.ConfigurationNode的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationNode類的具體用法?Java ConfigurationNode怎麽用?Java ConfigurationNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConfigurationNode類屬於ninja.leaping.configurate包,在下文中一共展示了ConfigurationNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseSqlite

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
@Nullable
private static ConfigProfile parseSqlite(@Nonnull final String key, @Nonnull final ConfigurationNode config) {
    final String fileName = StorageKeys.SQLITE_FILE.get(config);
    if (fileName.isEmpty()) {
        LOGGER.error("\"sqlite.file-name\" in \"{}\" cannot be empty!", key);
        return null;
    }

    final Path database = AmicusCore.getInstance().getConfigDir().resolve(fileName);
    if (!Files.exists(database)) {
        LOGGER.info("Database file doesn't exist and is being created: ", database.toString());
        if (!FilesWrapper.createFile(database)) {
            LOGGER.warn("Couldn't create database. Scrapping profile for key \"{}\".", key);
            return null;
        }
    }

    return new ConfigProfile(key, new SqliteStorage(database));
}
 
開發者ID:FerusTech,項目名稱:Amicus,代碼行數:20,代碼來源:ConfigProfile.java

示例2: save

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
@Override
public void save() {
    super.save();
    try {
        ConfigurationNode node = getNode();
        ConfigurationNode floor_block_type_node = node.getNode("FLOOR_BLOCK_TYPE");
        ConfigurationNode fence_block_type_node = node.getNode("FENCE_BLOCK_TYPE");
        ConfigurationNode crate_block_type_node = node.getNode("CRATE_BLOCK_TYPE");
        ConfigurationNode hologram_node = node.getNode("HOLOGRAM");
        ConfigurationNode close_delay_node = node.getNode("CLOSE_DELAY");
        ConfigurationNode open_manager_node = node.getNode("OPEN_MANAGER");
        floor_block_type_node.setValue(floor_block_type_combo_box.getSelectedText());
        fence_block_type_node.setValue(fence_block_type_combo_box.getSelectedText());
        crate_block_type_node.setValue(crate_block_type_combo_box.getSelectedText());
        hologram_node.setValue(hologram_field.hasText() ? hologram_field.getText() : null);
        close_delay_node.setValue(close_delay_field.hasText() ? close_delay_field.getText() : null);
        open_manager_node.setValue(open_manager_panel.getNode());
    } catch (Exception e) {
        throw new RuntimeException("Exception saving Animation1 Open Manager Configuration Dialog!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:22,代碼來源:Animation1OpenManagerConfigurationDialog.java

示例3: MultipleAmountKeyConfigurationDialog

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
public MultipleAmountKeyConfigurationDialog(ConfigurationNode node) {
    super("MULTIPLE-AMOUNT", node);
    child_key_panel = new SuperObjectPanel(false, "Child Key", SuperObjectType.KEY, GUIConstants.KEY_TYPES);
    child_key_panel.setLocation(8, 110);
    add(child_key_panel);
    amount_label = new JLabel("Amount");
    amount_label.setLocation(8, 160);
    amount_label.setSize(190, 20);
    add(amount_label);
    amount_field = new AdvancedTextField("Enter amount here...");
    amount_field.setLocation(8, 180);
    amount_field.setSize(190, 20);
    amount_field.setFunction(Optional.of(new CheckIntegerFunction()));
    add(amount_field);
    load();
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:17,代碼來源:MultipleAmountKeyConfigurationDialog.java

示例4: MultiDrop

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
public MultiDrop(ConfigurationNode node) {
    super(node);
    try {
        ConfigurationNode drops_node = node.getNode("DROPS");
        ConfigurationNode give_all_node = node.getNode("GIVE_ALL");
        if (drops_node.isVirtual()) {
            throw new RuntimeException("DROPS node does not exist");
        }
        drops = new ArrayList<Drop>();
        for (ConfigurationNode drop_node : drops_node.getChildrenList()) {
            drops.add((Drop) Utils.createSuperObject(drop_node, SuperObjectType.DROP));
        }
        give_all = give_all_node.getBoolean(true);
    } catch (Exception e) {
        throw new RuntimeException("Exception creating Multi Drop!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:18,代碼來源:MultiDrop.java

示例5: save

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
@Override
public void save() {
    super.save();
    try {
        ConfigurationNode node = getNode();
        ConfigurationNode commands_node = node.getNode("COMMANDS");
        if (commands.isEmpty()) {
            commands_node.setValue(null);
        } else {
            List<ConfigurationNode> command_nodes = new ArrayList<ConfigurationNode>();
            for (CommandPanel command_panel : commands) {
                if (command_panel.getCommandField().hasText()) {
                    ConfigurationNode command_node = SimpleConfigurationNode.root();
                    command_node.getNode("CMD").setValue(command_panel.getCommandField().getText());
                    command_node.getNode("CONSOLE").setValue(command_panel.getConsoleCheckBox().isSelected());
                    command_nodes.add(command_node);
                }
            }
            commands_node.setValue(command_nodes);
        }
    } catch (Exception e) {
        throw new RuntimeException("Exception saving Commands Drop Configuration Dialog!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:25,代碼來源:CommandsDropConfigurationDialog.java

示例6: Config

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
public Config(String name, boolean auto_save) {
    this.name = name;
    try {
        file = new File(GWMCrates.getInstance().getConfigDirectory(), name);
        loader = HoconConfigurationLoader.builder().setFile(file).build();
        node = loader.load();
        if (!file.exists()) {
            file.createNewFile();
            URL defaultsURL = GWMCrates.class.getResource("/" + name);
            ConfigurationLoader<CommentedConfigurationNode> defaultsLoader =
                    HoconConfigurationLoader.builder().setURL(defaultsURL).build();
            ConfigurationNode defaultsNode = defaultsLoader.load();
            node.mergeValuesFrom(defaultsNode);
            Sponge.getScheduler().createTaskBuilder().delayTicks(1).execute(this::save).
                    submit(GWMCrates.getInstance());
        }
        if (auto_save) {
            Sponge.getScheduler().createTaskBuilder().async().execute(this::save).
                    interval(AUTO_SAVE_INTERVAL, TimeUnit.SECONDS).submit(GWMCrates.getInstance());
        }
    } catch (Exception e) {
        GWMCrates.getInstance().getLogger().warn("Failed initialize config \"" + getName() + "\"!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:25,代碼來源:Config.java

示例7: load

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
private void load() {
    try {
        ConfigurationNode node = getNode();
        ConfigurationNode display_name_node = node.getNode("DISPLAY_NAME");
        ConfigurationNode decorative_items_node = node.getNode("DECORATIVE_ITEMS");
        ConfigurationNode scroll_delay_node = node.getNode("SCROLL_DELAY");
        ConfigurationNode decorative_items_change_mode_node = node.getNode("DECORATIVE_ITEMS_CHANGE_MODE");
        if (!display_name_node.isVirtual()) {
            display_name_field.setText(display_name_node.getString());
        }
        if (!scroll_delay_node.isVirtual()) {
            scroll_delay_field.setText(String.valueOf(scroll_delay_node.getInt()));
        }
        if (!decorative_items_change_mode_node.isVirtual()) {
            decorative_items_change_mode_panel.setNode(decorative_items_change_mode_node);
        }
    } catch (Exception e) {
        throw new RuntimeException("Exception loading First Preview Configuration Dialog!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:21,代碼來源:FirstPreviewConfigurationDialog.java

示例8: ChangeModeConfigurationDialog

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
public ChangeModeConfigurationDialog(String type, ConfigurationNode node) {
    super(SuperObjectType.DECORATIVE_ITEMS_CHANGE_MODE, type, node);
    change_delay_label = new JLabel("Change delay");
    change_delay_label.setLocation(8, 60);
    change_delay_label.setSize(190, 20);
    add(change_delay_label);
    change_delay_field = new AdvancedTextField("Enter delay here...");
    change_delay_field.setLocation(8, 80);
    change_delay_field.setSize(190, 20);
    add(change_delay_field);
    ignored_indices_label = new JLabel("Ignored indices");
    ignored_indices_label.setLocation(8, 110);
    ignored_indices_label.setSize(190, 20);
    add(ignored_indices_label);
    ignored_indices_field = new AdvancedTextField("Enter ignored indices here...");
    ignored_indices_field.setLocation(8, 130);
    ignored_indices_field.setSize(190, 20);
    ignored_indices_field.setFunction(Optional.of(new CheckIntListFunction()));
    add(ignored_indices_field);
    load();
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:22,代碼來源:ChangeModeConfigurationDialog.java

示例9: PermissionOpenManager

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
public PermissionOpenManager(ConfigurationNode node) {
    super(node);
    try {
        ConfigurationNode permission_node = node.getNode("PERMISSION");
        ConfigurationNode open_manager1_node = node.getNode("OPEN_MANAGER1");
        ConfigurationNode open_manager2_node = node.getNode("OPEN_MANAGER2");
        if (permission_node.isVirtual()) {
            throw new RuntimeException("PERMISSION node does not exist!");
        }
        if (open_manager1_node.isVirtual()) {
            throw new RuntimeException("OPEN_MANAGER1 node does not exist!");
        }
        if (open_manager2_node.isVirtual()) {
            throw new RuntimeException("OPEN_MANAGER2 node does not exist!");
        }
        permission = permission_node.getString();
        open_manager1 = (OpenManager) Utils.createSuperObject(open_manager1_node, SuperObjectType.OPEN_MANAGER);
        open_manager2 = (OpenManager) Utils.createSuperObject(open_manager2_node, SuperObjectType.OPEN_MANAGER);

    } catch (Exception e) {
        throw new RuntimeException("Exception creating Permission Open Manager!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:24,代碼來源:PermissionOpenManager.java

示例10: getInternalValue

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
private <T> E getInternalValue(T storageHandler) {
    if (storageHandler instanceof ConfigurationNode) {
        ConfigurationNode node = ((ConfigurationNode) storageHandler).getNode(this.key.get());

        if (node.isVirtual()) {
            this.modified = true;
        }

        if (this.comment != null && node instanceof CommentedConfigurationNode) {
            ((CommentedConfigurationNode) node).setComment(this.comment);
        }

        try {
            if (this.valueTypeToken != null) {
                return node.getValue(this.valueTypeToken, this.defaultValue);
            } else {
                return node.getValue(new TypeToken<E>(this.defaultValue.getClass()) {}, this.defaultValue);
            }
        } catch (Exception e) {
            return this.defaultValue;
        }
    }
    return null;
}
 
開發者ID:ichorpowered,項目名稱:elderguardian,代碼行數:25,代碼來源:StorageValue.java

示例11: createConfig

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
/**
 * Creates a config object of the specified type
 *
 * @param file The {@link Path} where the config file will be created
 * @param clazz The {@link Class} of the object that is being retrieved
 * @param loader The {@link ConfigurationLoader} that this config will use
 * @param <M> The type of object which will be created
 * @return The created config object, or null if an exception was thrown
 */
@SuppressWarnings("unchecked")
public <M extends BaseConfig> M createConfig(Path file, Class<M> clazz, ConfigurationLoader loader) {
    try {
        if (!Files.exists(file)) {
            Files.createFile(file);
        }

        TypeToken<M> token = TypeToken.of(clazz);
        ConfigurationNode node = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(this.factory));
        M config = node.getValue(token, clazz.newInstance());
        config.init(loader, node, token);
        config.save();
        return config;
    } catch (IOException | ObjectMappingException | IllegalAccessException | InstantiationException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:NucleusPowered,項目名稱:Phonon,代碼行數:28,代碼來源:Phonon.java

示例12: loadConfig

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
private void loadConfig() {
    try {
        if (!Files.exists(defaultConfig, LinkOption.NOFOLLOW_LINKS)) {
            URL jarConfigFile = this.getClass().getResource("default.conf");
            ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setURL(jarConfigFile).build();
            configManager.save(loader.load());
        }

        ConfigurationNode node = configManager.load();
        node.getOptions().setShouldCopyDefaults(true);

        String user = node.getNode("jdbc-username").getString("root");
        String password = node.getNode("jdbc-password").getString("password");
        String jdbcUrl = node.getNode("jdbc-url").getString("jdbc:mysql://localhost:3306/minecraft");

        databaseManager = new DatabaseManager(jdbcUrl, user, password);
        databaseManager.connect();

        for (Map.Entry<Object, ? extends ConfigurationNode> definitionKey : node.getNode("definitions").getChildrenMap().entrySet()) {
            int priority = definitionKey.getValue().getNode("priority").getInt(1);
            ImageType type = ImageType.valueOf(definitionKey.getValue().getNode("type").getString(ImageType.OVERLAY.name()));
            String permission = definitionKey.getValue().getNode("permission").getString();
            List<String> images = definitionKey.getValue().getNode("images").getList(new TypeToken<String>() {});

            SpongeImageDetails imageDetails = new SpongeImageDetails(priority, type, permission, images);
            imageHandler.addImage(imageDetails);
        }

        configManager.save(node);
    } catch (IOException | ObjectMappingException e) {
        e.printStackTrace();
    }
}
 
開發者ID:me4502,項目名稱:AdvancedServerListIcons,代碼行數:34,代碼來源:AdvancedServerListIconsSponge.java

示例13: getMinNameLength

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
public static int getMinNameLength()
{
    ConfigurationNode minLengthNode = ConfigAccess.getConfig(mainConfig).getNode("eaglefactions", "name", "minlength");

    int minLength = minLengthNode.getInt();

    return minLength;
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:9,代碼來源:MainLogic.java

示例14: save

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
@Override
public void save() {
    super.save();
    try {
        ConfigurationNode node = getNode();
        ConfigurationNode child_drop_node = node.getNode("CHILD_DROP");
        ConfigurationNode delay_node = node.getNode("DELAY");
        child_drop_node.setValue(child_drop_panel.getNode());
        delay_node.setValue(delay_field.hasText() ? delay_field.getText() : null);
    } catch (Exception e) {
        throw new RuntimeException("Exception saving Delay Drop Configuration Dialog!", e);
    }
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:14,代碼來源:DelayDropConfigurationDialog.java

示例15: get

import ninja.leaping.configurate.ConfigurationNode; //導入依賴的package包/類
@Nonnull
public T get(@Nonnull final ConfigurationNode node) {
    try {
        return (T) node.getNode(this.key).getValue(this.def);
    } catch (final ClassCastException e) {
        LOGGER.error("Improper value type for \"{}\"!", this.key, e);
        return this.def;
    }
}
 
開發者ID:FerusTech,項目名稱:Amicus,代碼行數:10,代碼來源:ConfigKey.java


注:本文中的ninja.leaping.configurate.ConfigurationNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。