本文整理汇总了Java中ninja.leaping.configurate.commented.CommentedConfigurationNode.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java CommentedConfigurationNode.getValue方法的具体用法?Java CommentedConfigurationNode.getValue怎么用?Java CommentedConfigurationNode.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ninja.leaping.configurate.commented.CommentedConfigurationNode
的用法示例。
在下文中一共展示了CommentedConfigurationNode.getValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadConfig
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public boolean loadConfig() {
try {
File file = new File(plugin.getConfigDir(), "catclearlag.conf");
if (!file.exists()) {
file.createNewFile();
}
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
CommentedConfigurationNode config = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(plugin.getFactory()).setShouldCopyDefaults(true));
cclConfig = config.getValue(TypeToken.of(CCLConfig.class), new CCLConfig());
loader.save(config);
return true;
} catch (Exception e) {
plugin.getLogger().error("Could not load config.", e);
return false;
}
}
示例2: loadMessages
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public boolean loadMessages() {
try {
File file = new File(plugin.getConfigDir(), "messages.conf");
if (!file.exists()) {
file.createNewFile();
}
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
CommentedConfigurationNode config = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(plugin.getFactory()).setShouldCopyDefaults(true));
messagesConfig = config.getValue(TypeToken.of(MessagesConfig.class), new MessagesConfig());
loader.save(config);
return true;
} catch (Exception e) {
plugin.getLogger().error("Could not load config.", e);
return false;
}
}
示例3: scanDir
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private Map<String, VirtualChestInventory> scanDir(File file)
{
Map<String, VirtualChestInventory> newInventories = new LinkedHashMap<>();
if (file.isDirectory() || file.mkdirs())
{
for (File f : Optional.ofNullable(file.listFiles()).orElse(new File[0]))
{
String fileName = f.getName();
if (fileName.endsWith(".conf"))
{
String chestName = fileName.substring(0, fileName.lastIndexOf(".conf"));
try
{
HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setFile(f).build();
CommentedConfigurationNode menuRoot = loader.load().getNode(VirtualChestPlugin.PLUGIN_ID);
VirtualChestInventory inventory = menuRoot.getValue(TypeToken.of(VirtualChestInventory.class));
newInventories.put(chestName, Objects.requireNonNull(inventory));
}
catch (Exception e)
{
this.logger.warn("Find error when reading a file (" + f.getAbsolutePath() +
"). Don't worry, we will skip this one and continue to read others", e);
}
}
}
}
return newInventories;
}
示例4: saveConfig
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void saveConfig(CCLConfig newConfig) {
try {
File file = new File(plugin.getConfigDir(), "catclearlag.conf");
if (!file.exists()) {
file.createNewFile();
}
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
CommentedConfigurationNode config = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(plugin.getFactory()).setShouldCopyDefaults(true));
config.getValue(TypeToken.of(CCLConfig.class), newConfig);
loader.save(config);
} catch (Exception e) {
plugin.getLogger().error("Could not load config.", e);
}
}
示例5: 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);
}
}
示例6: ensureBoolean
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static void ensureBoolean(CommentedConfigurationNode node, boolean def)
{
if (!(node.getValue() instanceof Boolean))
{
node.setValue(def);
}
}
示例7: addDefault
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void addDefault(final String paths, final Object value, final String comment){
CommentedConfigurationNode node = get(paths);
if (node.getValue() == null){
node.setComment(comment).setValue(value);
this.setModified(true);
}
}
示例8: addComment
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void addComment(final String paths, final String... comments){
CommentedConfigurationNode node = get(paths);
if (node.getValue() == null){
node.setComment(String.join("\n", comments));
this.setModified(true);
}
}
示例9: loadWorldConfig
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private void loadWorldConfig(@Nullable PublicContext context, CommentedConfigurationNode parentNode, boolean wild)
{
for(Permission permission : values())
{
CommentedConfigurationNode node = parentNode.getNode(permission.toString().toLowerCase());
boolean def = wild? permission.isAllowedByDefaultOnTheWild() : permission.isAllowedByDefault();
node.setComment(permission.getDescription() + " [Default:" + def + "]");
if(context != null)
{
if(!node.isVirtual())
{
Object value = node.getValue();
if(value instanceof Boolean)
{
context.setPublicPermission(permission, Tristate.fromBoolean((boolean) value));
context.setModified(false);
}
}
}
else
{
boolean val = node.getBoolean(def);
if (val != def)
{
if (wild)
permission.setAllowedByDefaultOnTheWild(val);
else
permission.setAllowedByDefault(val);
permission.setModified(false);
}
}
}
}
示例10: loadConfig
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private void loadConfig(){
try {
CommentedConfigurationNode node = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(factory).setShouldCopyDefaults(true));
config = node.getValue(TypeToken.of(NoXrayConfig.class), new NoXrayConfig());
loader.save(node);
} catch (IOException | ObjectMappingException e) {
e.printStackTrace();
}
}
示例11: NucleusMixinConfig
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private NucleusMixinConfig() {
Config config;
try {
Path path = Paths.get("config", "nucleus", "mixins.conf");
ConfigurationLoader<CommentedConfigurationNode> ccn = HoconConfigurationLoader.builder().setPath(path).build();
CommentedConfigurationNode node = ccn.load();
node.mergeValuesFrom(SimpleCommentedConfigurationNode.root().setValue(TypeToken.of(Config.class), new Config()));
ccn.save(node);
config = node.getValue(TypeToken.of(Config.class));
} catch (Exception e) {
config = new Config();
}
this.config = config;
}