Java Code Examples for ninja.leaping.configurate.ConfigurationNode#setValue()
The following examples show how to use
ninja.leaping.configurate.ConfigurationNode#setValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigEditTab.java From ChatUI with MIT License | 6 votes |
@Override public void onTextInput(PlayerChatView view, Text input) { if (this.nodeBuilder != null) { this.nodeBuilder.recieveInput(view, input.toPlain()); return; } if (this.control.getActiveEntry() == null) { return; } ConfigurationNode node = this.control.getNode().getNode(this.control.getActiveEntry().key); Object value = this.control.getActiveEntry().value.onSetValue(input.toPlain()); node.setValue(value); this.control.onNodeChanged(node); this.control.closeActiveEntry(); view.update(); }
Example 2
Source File: Settings.java From FlexibleLogin with MIT License | 6 votes |
private <T> void loadMapper(ObjectMapper<T>.BoundInstance mapper, Path file, ConfigurationOptions options) { ConfigurationNode rootNode; if (mapper != null) { HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setPath(file).build(); try { rootNode = loader.load(options.setShouldCopyDefaults(true)); ConfigurationNode hashNode = rootNode.getNode("hashAlgo"); if ("bcrypt".equalsIgnoreCase(hashNode.getString())) { hashNode.setValue("BCrypt"); } //load the config into the object mapper.populate(rootNode); //add missing default values loader.save(rootNode); } catch (ObjectMappingException objMappingExc) { logger.error("Error loading the configuration", objMappingExc); } catch (IOException ioExc) { logger.error("Error saving the default configuration", ioExc); } } }
Example 3
Source File: SecurityService.java From Web-API with MIT License | 6 votes |
/** * Adds the given permission tree as a config node to the passed base node. * @param config The base config node, at which the permissions tree is added * @param perms The permissions tree which is parsed to a config node */ public static void permissionTreeToConfig(ConfigurationNode config, TreeNode perms) { if (perms == null) { return; } Collection<TreeNode> children = perms.getChildren(); if (children.size() == 0) { config.setValue(perms.getValue()); return; } if (!perms.getValue()) { config.getNode(".").setValue(false); } for (TreeNode child : children) { permissionTreeToConfig(config.getNode(child.getKey()), child); } }
Example 4
Source File: PartiesFileDispatcher.java From Parties with GNU Affero General Public License v3.0 | 6 votes |
@Override public void renameParty(String before, String now) { ConfigurationNode oldNode = database.getRootNode().getNode("parties", before); ConfigurationNode newNode = database.getRootNode().getNode("parties", now); newNode.setValue(oldNode.getValue()); oldNode.setValue(null); Function<Object, String> f = o -> (String) o; for (String id : newNode.getNode("members").getList(f)) { database.getRootNode().getNode("players", id, "party").setValue(now); } try { database.saveFile(); } catch (IOException ex) { plugin.getLoggerManager().printErrorStacktrace(Constants.DEBUG_DB_FILE_ERROR, ex); } }
Example 5
Source File: GsonTypeSerializer.java From helper with MIT License | 6 votes |
@Override public void serialize(TypeToken<?> type, JsonElement from, ConfigurationNode to) throws ObjectMappingException { if (from.isJsonPrimitive()) { JsonPrimitive primitive = from.getAsJsonPrimitive(); to.setValue(GsonConverters.IMMUTABLE.unwarpPrimitive(primitive)); } else if (from.isJsonNull()) { to.setValue(null); } else if (from.isJsonArray()) { JsonArray array = from.getAsJsonArray(); // ensure 'to' is a list node to.setValue(ImmutableList.of()); for (JsonElement element : array) { serialize(TYPE, element, to.getAppendedNode()); } } else if (from.isJsonObject()) { JsonObject object = from.getAsJsonObject(); // ensure 'to' is a map node to.setValue(ImmutableMap.of()); for (Map.Entry<String, JsonElement> ent : object.entrySet()) { serialize(TYPE, ent.getValue(), to.getNode(ent.getKey())); } } else { throw new ObjectMappingException("Unknown element type: " + from.getClass()); } }
Example 6
Source File: WebHookSerializer.java From Web-API with MIT License | 5 votes |
private <T> void setValueAndComment(ConfigurationNode node, TypeToken<T> type, T value, String comment) throws ObjectMappingException { node.setValue(type, value); if (node instanceof CommentedConfigurationNode) { ((CommentedConfigurationNode) node).setComment(comment); } }
Example 7
Source File: FeatureManager.java From ChatUI with MIT License | 5 votes |
private boolean canLoad(String featureId) { ConfigurationNode enabled = Config.getRootNode().getNode("features", featureId, "enabled"); if (enabled.isVirtual()) { enabled.setValue(true); } return enabled.getBoolean(true); }
Example 8
Source File: BukkitTypeSerializer.java From helper with MIT License | 5 votes |
@Override public void serialize(TypeToken<?> type, ConfigurationSerializable from, ConfigurationNode to) throws ObjectMappingException { Map<String, Object> serialized = from.serialize(); Map<String, Object> map = new LinkedHashMap<>(serialized.size() + 1); map.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(from.getClass())); map.putAll(serialized); to.setValue(map); }
Example 9
Source File: ComponentConfigSerializer.java From GriefDefender with MIT License | 5 votes |
@Override public void serialize(TypeToken<?> type, Component obj, ConfigurationNode node) throws ObjectMappingException { if (obj == TextComponent.empty()) { node.setValue(""); } else { node.setValue(LegacyComponentSerializer.legacy().serialize(obj, '&')); } }
Example 10
Source File: JsonTreeTypeSerializer.java From helper with MIT License | 5 votes |
@Override public void serialize(TypeToken<?> typeToken, DataTree dataTree, ConfigurationNode node) throws ObjectMappingException { if (dataTree instanceof GsonDataTree) { node.setValue(JSON_ELEMENT_TYPE, ((GsonDataTree) dataTree).getElement()); } else if (dataTree instanceof ConfigurateDataTree) { node.setValue(((ConfigurateDataTree) dataTree).getNode()); } else { throw new ObjectMappingException("Unknown type: " + dataTree.getClass().getName()); } }
Example 11
Source File: TextTypeSerializer.java From helper with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> typeToken, Component component, ConfigurationNode node) throws ObjectMappingException { JsonElement element = DELEGATE.serialize(component, typeToken.getType(), new GsonContext()); node.setValue(TypeToken.of(JsonElement.class), element); }
Example 12
Source File: WebHookSerializer.java From Web-API with MIT License | 4 votes |
private void setValueAndComment(ConfigurationNode node, Object value, String comment) { node.setValue(value); if (node instanceof CommentedConfigurationNode) { ((CommentedConfigurationNode) node).setComment(comment); } }
Example 13
Source File: SerializableTransformSerializer.java From UltimateCore with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, SerializableTransform loc, ConfigurationNode node) throws ObjectMappingException { node.setValue(loc.getNode()); }
Example 14
Source File: ColoredStringTypeSerializer.java From helper with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, String s, ConfigurationNode node) { node.setValue(Text.decolorize(s)); }
Example 15
Source File: GameModeTypeSerializer.java From GriefDefender with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, GameModeType obj, ConfigurationNode node) throws ObjectMappingException { node.setValue(obj.getName()); }
Example 16
Source File: WeatherTypeSerializer.java From GriefDefender with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, WeatherType obj, ConfigurationNode node) throws ObjectMappingException { node.setValue(obj.getName()); }
Example 17
Source File: CreateModeTypeSerializer.java From GriefDefender with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, CreateModeType obj, ConfigurationNode node) throws ObjectMappingException { node.setValue(obj.getName()); }
Example 18
Source File: WeatherTypeSerializer.java From GriefDefender with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, WeatherType obj, ConfigurationNode node) throws ObjectMappingException { node.setValue(obj.getName()); }
Example 19
Source File: CreateModeTypeSerializer.java From GriefDefender with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, CreateModeType obj, ConfigurationNode node) throws ObjectMappingException { node.setValue(obj.getName()); }
Example 20
Source File: ClaimTypeSerializer.java From GriefDefender with MIT License | 4 votes |
@Override public void serialize(TypeToken<?> type, ClaimType obj, ConfigurationNode node) throws ObjectMappingException { node.setValue(obj.getName()); }