本文整理汇总了Java中ninja.leaping.configurate.commented.CommentedConfigurationNode.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java CommentedConfigurationNode.setValue方法的具体用法?Java CommentedConfigurationNode.setValue怎么用?Java CommentedConfigurationNode.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ninja.leaping.configurate.commented.CommentedConfigurationNode
的用法示例。
在下文中一共展示了CommentedConfigurationNode.setValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void save(@NotNull Object object) throws DataHandlingException {
try {
String header = getComments(object.getClass(), true);
CommentedConfigurationNode node = SimpleCommentedConfigurationNode.root(ConfigurationOptions.defaults().setHeader(header));
Object serialized = SerializableConfig.serialize(object, serializerSet);
node = node.setValue(serialized);
if (commentsEnabled) {
node = addComments(FieldMapper.getFieldMap(object.getClass()), node);
}
getLoader().save(node);
} catch (IOException e) {
throw new DataHandlingException(e);
}
}
示例2: execute
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
String id = args.<String>getOne("id").get();
CommentedConfigurationNode ticket = plugin.getTickets().get(id);
if (ticket.isVirtual()) {
src.sendMessage(Text.of(RED, "That ticket does not exist!"));
return CommandResult.success();
}
if(!ticket.getNode("completed").getBoolean())
Sponge.getServer().getPlayer(UUID.fromString(ticket.getNode("player").getString()))
.ifPresent(player -> player.sendMessage(Text.of(GREEN, "Your ticket has been completed by ",
WHITE, src.getName()))
);
boolean completed = ticket.getNode("completed").getBoolean();
ticket.setValue(null);
src.sendMessage(Text.of(GREEN, completed ? "Ticket deleted." : "Ticket completed & deleted."));
return CommandResult.success();
}
示例3: registerWorld
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void registerWorld(String world) {
boolean save = false;
for (String collection : this.getCollections()) {
if (!this.getWorld(collection, world).isPresent()) {
CommentedConfigurationNode config = this.get("collections." + collection).getNode(EPConfig.DEFAULT);
try {
List<String> worlds = new ArrayList<String>();
worlds.addAll(config.getList(TypeToken.of(String.class)));
worlds.add(world);
config.setValue(worlds);
save = true;
} catch (ObjectMappingException e) {}
}
}
if (save) this.save(true);
}
示例4: mergeConfigs
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
/**
* Merge default values into a existing config, adding only the values that don't exist yet.
* @param node The node that receives any missing default values
* @param def The default configuration
* @param restoreDefaults True if missing values in the config marked with _DEFAULT_ in the comment of the default config should be added.
*/
public static void mergeConfigs(CommentedConfigurationNode node, CommentedConfigurationNode def, boolean restoreDefaults) {
if (def.getComment().isPresent() && def.getComment().get().contains("_EXAMPLE_") && !restoreDefaults) {
return;
}
if (node.isVirtual()) {
node.setValue(def);
return;
}
if (!def.hasMapChildren()) {
return;
}
Map<Object, ? extends CommentedConfigurationNode> map = def.getChildrenMap();
for (Map.Entry<Object, ? extends CommentedConfigurationNode> entry : map.entrySet()) {
CommentedConfigurationNode subNode = node.getNode(entry.getKey());
mergeConfigs(subNode, entry.getValue(), restoreDefaults);
}
}
示例5: loadConfig
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void loadConfig() {
try {
config = confLoader.load();
} catch (IOException e) {
logger.error("Error while loading config", e);
config = confLoader.createEmptyNode();
}
CommentedConfigurationNode playerSettings = config.getNode("player-settings");
if (playerSettings.isVirtual()) {
playerSettings.setValue(Collections.emptyMap());
}
}
示例6: ensureString
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void ensureString(CommentedConfigurationNode node, String def)
{
if (node.getString() == null)
{
node.setValue(def);
}
}
示例7: ensurePositiveNumber
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void ensurePositiveNumber(CommentedConfigurationNode node, Number def)
{
if (!(node.getValue() instanceof Number) || node.getDouble(-1) < 0)
{
node.setValue(def);
}
}
示例8: ensureBoolean
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void ensureBoolean(CommentedConfigurationNode node, boolean def)
{
if (!(node.getValue() instanceof Boolean))
{
node.setValue(def);
}
}