private void parseArg(LiteralText source, List<Object> into) throws ObjectMappingException { String name = unwrap(source.getContent()); boolean optional = this.root.getNode(NODE_ARGS, name, NODE_OPT).getBoolean(); Text defaultValue = this.root.getNode(NODE_ARGS, name, NODE_DEF_VAL).getValue(TypeToken.of(Text.class)); TextFormat format = source.getFormat(); into.add(TextTemplate.arg(name).format(format).optional(optional).defaultValue(defaultValue).build()); }
@Override public TextFormat deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException { TextColor color = TextColors.NONE; GameRegistry registry = Sponge.getRegistry(); String colorId = value.getNode(NODE_COLOR).getString(); if (colorId != null) { color = registry.getType(TextColor.class, colorId).orElseThrow(() -> new ObjectMappingException("Color not found: " + colorId)); } TextStyle style = TextStyles.NONE; ConfigurationNode styleNode = value.getNode(NODE_STYLE); for (TextStyle.Base component : registry.getAllOf(TextStyle.Base.class)) { if (styleNode.getNode(component.getId().toLowerCase()).getBoolean()) { style = style.and(component); } } return TextFormat.NONE.color(color).style(style); }
/** * Gets the value typed using the appropriate type conversion from {@link Types} * * @see #getValue() * @return The appropriate type conversion, false if no appropriate value is available */ default boolean getBoolean() { return getBoolean(false); }
/** * Gets the value typed using the appropriate type conversion from {@link Types} * * @see #getValue() * @return The appropriate type conversion, false if no appropriate value is available */ default boolean getBoolean() { return getBoolean(false); }
/** * Gets the value typed using the appropriate type conversion from {@link Types} * * @see #getValue() * @return The appropriate type conversion, false if no appropriate value is available */ default boolean getBoolean() { return getBoolean(false); }
@Override public Boolean deserialize(TypeToken<?> type, ConfigurationNode value) throws InvalidTypeException { return value.getBoolean(); }
@Override public boolean isReplaceParticles() { return rootNode.getNode("replace-particles").getBoolean(false); } });
@Override public boolean isReplaceAdventureMode() { return rootNode.getNode("replace-adventure").getBoolean(false); }
@Override public Boolean deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws InvalidTypeException { return value.getBoolean(); }
@Override public Boolean deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws InvalidTypeException { return value.getBoolean(); }
public Listening() { BREAK = Prism.getInstance().getConfiguration().getNode("events", "break").getBoolean(); DEATH = Prism.getInstance().getConfiguration().getNode("events", "death").getBoolean(); DECAY = Prism.getInstance().getConfiguration().getNode("events", "decay").getBoolean(); DROP = Prism.getInstance().getConfiguration().getNode("events", "drop").getBoolean(); GROW = Prism.getInstance().getConfiguration().getNode("events", "grow").getBoolean(); JOIN = Prism.getInstance().getConfiguration().getNode("events", "join").getBoolean(); PICKUP = Prism.getInstance().getConfiguration().getNode("events", "pickup").getBoolean(); PLACE = Prism.getInstance().getConfiguration().getNode("events", "place").getBoolean(); QUIT = Prism.getInstance().getConfiguration().getNode("events", "quit").getBoolean(); } }
if (Prism.getInstance().getConfiguration().getNode("defaults", "enabled").getBoolean()) {
@Listener public void onInitialization(GameInitializationEvent event) { Connection db; // This is a sanity check you should always do. Don't try to connect to an unconfigured database. if (this.config.getNode("DB", "Configured").getBoolean() != true) { getLogger().info("You haven't configured the database. Exiting."); // TODO We should probably do more 'formal' shutdown on the mod here. return; } getLogger().info("In InitializationEvent."); // This is an example of calling another method with only parts of the config, rather than passing // the entire config, of which maybe 3-4 parameters will be used. In this case, only the attributes // in the "DB" section of the config is passed to DB.getConnection. // Note that here, we do not actually assign a connection to the variable db, in case you are just // testing this. If you have a mySQL database handy, add "db =" in front of DB.getConnection. DatabaseUtils.getConnection(this.config.getNode("DB")); getLogger().info("I should now have a database connection."); } }
/** * Returns a permissions tree representing the passed configuration node * @param config The configuration node which represents a permission set * @return A tree structure representing the config node */ public static TreeNode permissionTreeFromConfig(ConfigurationNode config) { if (config == null || config.getValue() == null) { return new TreeNode(false); } if (!config.hasMapChildren()) { if (config.getValue().getClass() == Boolean.class) return new TreeNode(config.getKey().toString(), config.getBoolean()); else { TreeNode node = new TreeNode(config.getKey().toString(), true); node.addChild(new TreeNode("*", true)); return node; } } TreeNode root = new TreeNode(config.getKey().toString(), true); for (Map.Entry<Object, ? extends ConfigurationNode> entry : config.getChildrenMap().entrySet()) { if (entry.getKey().toString().equalsIgnoreCase(".")) { root.setValue(entry.getValue().getBoolean()); continue; } root.addChild(permissionTreeFromConfig(entry.getValue())); } return root; }
boolean enabled = value.getNode("enabled").getBoolean(); String method = value.getNode("method").getString(); WebHook.WebHookDataType dataType = value.getNode("dataType").getValue(TypeToken.of(WebHook.WebHookDataType.class)); boolean form = value.getNode("form").getBoolean(); List<WebHookHeader> headers = value.getNode("headers").getList(TypeToken.of(WebHookHeader.class)); boolean details = value.getNode("details").getBoolean();
private void parseArg(LiteralText source, List<Object> into) throws ObjectMappingException { String name = unwrap(source.getContent()); boolean optional = this.root.getNode(NODE_ARGS, name, NODE_OPT).getBoolean(); Text defaultValue = this.root.getNode(NODE_ARGS, name, NODE_DEF_VAL).getValue(TypeToken.of(Text.class)); TextFormat format = source.getFormat(); into.add(TextTemplate.arg(name).format(format).optional(optional).defaultValue(defaultValue).build()); }
@Override public TextFormat deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException { TextColor color = TextColors.NONE; GameRegistry registry = Sponge.getRegistry(); String colorId = value.getNode(NODE_COLOR).getString(); if (colorId != null) { color = registry.getType(TextColor.class, colorId).orElseThrow(() -> new ObjectMappingException("Color not found: " + colorId)); } TextStyle style = TextStyles.NONE; ConfigurationNode styleNode = value.getNode(NODE_STYLE); for (TextStyle.Base component : registry.getAllOf(TextStyle.Base.class)) { if (styleNode.getNode(component.getId().toLowerCase()).getBoolean()) { style = style.and(component); } } return TextFormat.NONE.color(color).style(style); }
ConfigurationNode defaultNode = valueAtPath.getNode("options", "default"); if (!defaultNode.isVirtual()) { if (defaultNode.getBoolean()) { ConfigurationNode addToNode = null; final ConfigurationNode defaultsParent = valueAtPath.getParent().getParent().getParent().getNode("systems", "default");