本文整理汇总了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));
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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;
}
}