本文整理汇总了Java中ninja.leaping.configurate.commented.CommentedConfigurationNode.getNode方法的典型用法代码示例。如果您正苦于以下问题:Java CommentedConfigurationNode.getNode方法的具体用法?Java CommentedConfigurationNode.getNode怎么用?Java CommentedConfigurationNode.getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ninja.leaping.configurate.commented.CommentedConfigurationNode
的用法示例。
在下文中一共展示了CommentedConfigurationNode.getNode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: getPlayerChunkPosition
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static Vector3i getPlayerChunkPosition(UUID playerUUID)
{
Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") + "/" + playerUUID.toString() + ".conf");
try
{
ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();
CommentedConfigurationNode playerNode = configLoader.load();
ConfigurationNode chunkPositionNode = playerNode.getNode("chunkPosition");
if(chunkPositionNode.getValue() != null)
{
String object = chunkPositionNode.getString();
String vectors[] = object.replace("(", "").replace(")", "").replace(" ", "").split(",");
int x = Integer.valueOf(vectors[0]);
int y = Integer.valueOf(vectors[1]);
int z = Integer.valueOf(vectors[2]);
Vector3i chunk = Vector3i.from(x, y, z);
return chunk;
}
else
{
return new Vector3i(0,0,0);
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
return null;
}
示例3: gameInit
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
@Listener
public void gameInit(GamePreInitializationEvent event){
logger = LoggerFactory.getLogger(pC.getName());
instance = this;
huskyAPI = new HuskyAPI();
forceStopIDs.clear();
for(PluginContainer pc: Sponge.getPluginManager().getPlugins()){
if(pc.getId().equalsIgnoreCase("inventorytweaks")||pc.getId().equalsIgnoreCase("inventorysorter")||pc.getId().equalsIgnoreCase("mousetweaks")){
forceStopIDs.add(pc.getName() + "(" + pc.getId() + ")");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error(pc.getName() + " is loaded! This plugin or mod is on a blacklist for HuskyCrates, and as a result, HuskyCrates is not starting. ");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
forceStop = true;
}
}
if(forceStop)
return;
CommentedConfigurationNode conf = null;
try {
conf = crateConfig.load();
if(!conf.getNode("lang").isVirtual()) {
langData = new LangData(conf.getNode("lang"));
}else
logger.info("Using default lang settings.");
} catch (Exception e) {
crateUtilities.exceptionHandler(e);
}
//logger.info("Let's not init VCrates here anymore. ://)");
}
示例4: Settings
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public Settings(String path) throws IOException, ObjectMappingException {
ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setPath(Paths.get(path)).build(); // Create the loader
CommentedConfigurationNode node = loader.load();
CommentedConfigurationNode account = node.getNode("account");
username = account.getNode("username").getString();
password = account.getNode("password").getString();
osuApi = account.getNode("osu-api-key").getString();
CommentedConfigurationNode general = node.getNode("general");
operatorIds = general.getNode("operators").getList(TypeToken.of(Integer.class));
infoText = general.getNode("info-text").getString();
helpText = general.getNode("help-text").getString();
CommentedConfigurationNode room = node.getNode("room");
roomName = room.getNode("name").getString();
roomPassword = room.getNode("password").getString();
roomSlots = room.getNode("slots").getInt();
CommentedConfigurationNode criteria = node.getNode("beatmap-criteria");
minDifficulty = criteria.getNode("min-difficulty").getDouble();
maxDifficulty = criteria.getNode("max-difficulty").getDouble();
maxLength = criteria.getNode("max-length").getInt();
gamemode = criteria.getNode("gamemode").getInt();
allowGraveyard = criteria.getNode("allow-graveyard").getBoolean();
if (gamemode < 0 || gamemode > 3) {
throw new IllegalArgumentException("Invalid gamemode \"" + gamemode + "\".");
}
}
示例5: 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);
}
}
}
}
示例6: save
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public void save(Path directory) {
Path configPath = directory.resolve(FILE_NAME);
ConfigurationLoader<CommentedConfigurationNode> loader =
HoconConfigurationLoader.builder().setPath(configPath).build();
ConfigurationOptions options = CustomItemLibrary.getInstance().getDefaultConfigurationOptions();
CommentedConfigurationNode rootNode = loader.createEmptyNode(options);
CommentedConfigurationNode modelIdsNode = rootNode.getNode(NODE_MODEL_IDS);
modelIdsNode.setComment("DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ARE ABSOLUTELY SURE ABOUT WHAT YOU ARE DOING!");
for (Map.Entry<DurabilityIdentifier, Identifier> entry : durabilityIdToModelId.entrySet()) {
DurabilityIdentifier durability = entry.getKey();
Identifier modelId = entry.getValue();
modelIdsNode.getNode(durability.toString()).setValue(modelId.toString());
}
try {
Files.createDirectories(configPath.getParent());
if (Files.exists(configPath))
Files.delete(configPath);
Files.createFile(configPath);
loader.save(rootNode);
} catch (IOException e) {
e.printStackTrace();
CustomItemLibrary.getInstance().getLogger()
.warn("Could not save the custom tool registry: " + e.getLocalizedMessage());
}
}
示例7: loadWorldContext
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
private WorldFallbackContext loadWorldContext(World world) throws IOException
{
Path worldPath = configDir.resolve("world");
Path configPath = worldPath.resolve(world.getName().replaceAll("[^a-zA-Z0-9-]", "_") + ".conf");
if(!Files.isDirectory(worldPath))
Files.createDirectory(worldPath);
HoconConfigurationLoader loader = HoconConfigurationLoader.builder().setPath(configPath).build();
CommentedConfigurationNode main = loader.load(
ConfigurationOptions.defaults()
.setShouldCopyDefaults(true)
.setHeader("Default wild permissions on the world " + world.getName() + " with dimension " +
world.getDimension().getName() + " and unique id: " + world.getUniqueId())
);
CommentedConfigurationNode wildPerms = main.getNode("wild-permissions");
wildPerms.setComment(
"The permissions that affects unclaimed chunks on this world. Null values are inherited from the default-world-permissions declared on the default-permissions.conf file"
);
CommentedConfigurationNode defaultPerms = main.getNode("fallback-permissions");
defaultPerms.setComment(
"The fallback permissions that will be used when a claimed chunk or a zone does not define the permission, this will take priority over the default defined on the defailt-permission.conf file"
);
WorldFallbackContext worldContext = new WorldFallbackContext(world.getUniqueId());
loadWorldConfig(worldContext, defaultPerms, false);
loadWorldConfig(worldContext.getWilderness(), wildPerms, true);
try
{
loader.save(main);
}
catch(Exception e)
{
logger.error("Failed to save the world config file for " + world.getName() + " DIM:" +
world.getDimension().getName(), e);
}
return worldContext;
}
示例8: load
import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public ItemCategoryManager load() {
categoryToItemIds.clear();
CustomItemLibrary plugin = CustomItemLibrary.getInstance();
Path path = plugin.getConfigPath();
ConfigurationOptions options = plugin.getDefaultConfigurationOptions();
HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
.setDefaultOptions(options).setPath(path).build();
try {
CommentedConfigurationNode root = loader.load();
CommentedConfigurationNode nodeCategories = root.getNode(NODE_ITEM_CATEGORIES);
nodeCategories.setComment("Categories are used to determine the mining speed of blocks. Here you can add items from mods.");
if(nodeCategories.isVirtual()) {
defaultCategory(nodeCategories, "shovel", ItemTypes.WOODEN_SHOVEL, ItemTypes.STONE_SHOVEL,
ItemTypes.IRON_SHOVEL, ItemTypes.GOLDEN_SHOVEL, ItemTypes.DIAMOND_SHOVEL);
defaultCategory(nodeCategories, "hoe", ItemTypes.WOODEN_HOE, ItemTypes.STONE_HOE,
ItemTypes.IRON_HOE, ItemTypes.GOLDEN_HOE, ItemTypes.DIAMOND_HOE);
defaultCategory(nodeCategories, "pickaxe", ItemTypes.WOODEN_PICKAXE, ItemTypes.STONE_PICKAXE,
ItemTypes.IRON_PICKAXE, ItemTypes.GOLDEN_PICKAXE, ItemTypes.DIAMOND_PICKAXE);
defaultCategory(nodeCategories, "axe", ItemTypes.WOODEN_AXE, ItemTypes.STONE_AXE,
ItemTypes.IRON_AXE, ItemTypes.GOLDEN_AXE, ItemTypes.DIAMOND_AXE);
defaultCategory(nodeCategories, "shears", ItemTypes.SHEARS);
}
nodeCategories.getChildrenMap().forEach((rawCategory, rawItemIds) -> {
String category = Objects.toString(rawCategory);
List<String> itemIds = rawItemIds.getList(Objects::toString);
Set<Identifier> identifiers = itemIds.stream().map(itemId -> {
if(Identifier.isParseable(itemId))
return Identifier.parse(itemId);
else
return new Identifier("minecraft", itemId);
}).collect(Collectors.toSet());
categoryToItemIds.putAll(category, identifiers);
});
loader.save(root);
} catch (IOException e) {
e.printStackTrace();
}
return this;
}