当前位置: 首页>>代码示例>>Java>>正文


Java CommentedConfigurationNode.isVirtual方法代码示例

本文整理汇总了Java中ninja.leaping.configurate.commented.CommentedConfigurationNode.isVirtual方法的典型用法代码示例。如果您正苦于以下问题:Java CommentedConfigurationNode.isVirtual方法的具体用法?Java CommentedConfigurationNode.isVirtual怎么用?Java CommentedConfigurationNode.isVirtual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ninja.leaping.configurate.commented.CommentedConfigurationNode的用法示例。


在下文中一共展示了CommentedConfigurationNode.isVirtual方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:xDotDash,项目名称:HelpTicketsOld,代码行数:23,代码来源:CommandTicketDelete.java

示例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(TextColors.RED, "That ticket does not exist!"));
        return CommandResult.success();
    }

    if(ticket.getNode("completed").getBoolean()) {
        src.sendMessage(Text.of(TextColors.RED, "That ticket is already completed."));
        return CommandResult.success();
    } else {
        Sponge.getServer().getPlayer(UUID.fromString(ticket.getNode("player").getString()))
                .ifPresent(player -> player.sendMessage(Text.of(TextColors.GREEN, "Your ticket has been completed by ",
                        TextColors.WHITE, src.getName()))
                );
    }

    ticket.getNode("completed").setValue(true);
    plugin.getTickets().save();

    src.sendMessage(Text.of(TextColors.GREEN, "Ticket completed."));
    return CommandResult.success();
}
 
开发者ID:xDotDash,项目名称:HelpTicketsOld,代码行数:27,代码来源:CommandTicketComplete.java

示例3: 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);
    }
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:27,代码来源:Util.java

示例4: execute

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if(!(src instanceof Player)) {
        src.sendMessage(Text.of(TextColors.RED, "You must be a player to use that command."));
        return CommandResult.success();
    }

    Player player = (Player) src;
    String id = args.<String>getOne("id").get();

    CommentedConfigurationNode ticket = plugin.getTickets().get(id);

    if (ticket.isVirtual()) {
        src.sendMessage(Text.of(TextColors.RED, "That ticket does not exist!"));
        return CommandResult.success();
    }

    String[] locSplit = ticket.getNode("location").getString().split(":");
    Location<World> loc = new Location<>(Sponge.getGame().getServer().getWorld(UUID.fromString(locSplit[0])).get(),
            Double.valueOf(locSplit[1]), Double.valueOf(locSplit[2]), Double.valueOf(locSplit[3]));
    player.setLocation(loc);

    String[] rotSplit = ticket.getNode("rotation").getString().split(":");
    Vector3d rot = new Vector3d(Double.valueOf(rotSplit[0]), Double.valueOf(rotSplit[1]),
            Double.valueOf(rotSplit[2]));
    player.setRotation(rot);

    player.sendMessage(Text.of(TextColors.GREEN, "Teleported to location of ticket."));
    player.sendMessage(Text.of(TextColors.GRAY, "Ticket message: ", TextColors.WHITE,
            ticket.getNode("message").getString()));

    return CommandResult.success();
}
 
开发者ID:xDotDash,项目名称:HelpTicketsOld,代码行数:34,代码来源:CommandTicketTeleport.java

示例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());
    }
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:13,代码来源:Config.java

示例6: playerConfig

import ninja.leaping.configurate.commented.CommentedConfigurationNode; //导入方法依赖的package包/类
public static ConfigurationNode playerConfig(UUID uuid) {
    CommentedConfigurationNode settings = config.getNode("player-settings", uuid.toString());
    if (settings.isVirtual()) {
        settings.getNode("enabled").setValue(true);
    }
    return settings;
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:8,代码来源:Config.java

示例7: 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);
            }
        }
    }
}
 
开发者ID:GameModsBR,项目名称:MyChunks,代码行数:35,代码来源:MyChunks.java

示例8: 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(TextColors.RED, "That ticket does not exist!"));
        return CommandResult.success();
    }

    String[] locSplit = ticket.getNode("location").getString().split(":");
    String[] rotSplit = ticket.getNode("rotation").getString().split(":");

    String player = MiscUtil.uuidToName(ticket.getNode("player").getString());
    String message = ticket.getNode("message").getString();
    String created = ticket.getNode("created").getString();
    String world = Sponge.getServer().getWorld(UUID.fromString(locSplit[0])).get().getName();
    String x = locSplit[1], y = locSplit[2], z = locSplit[3];
    String pitch = rotSplit[0], yaw = rotSplit[1], roll = rotSplit[2];
    boolean completed = ticket.getNode("completed").getBoolean();

    plugin.getPagination().builder()
            .contents(
                    info.apply("Id", id),
                    info.apply("Player", player),
                    info.apply("Message", message),
                    info.apply("Created-At", created),
                    Text.of(TextColors.GRAY, "--------------------"),
                    info.apply("World", world),
                    info.apply("X", x),
                    info.apply("Y", y),
                    info.apply("Z", z),
                    Text.of(TextColors.GRAY, "--------------------"),
                    info.apply("Pitch", pitch),
                    info.apply("Yaw", yaw),
                    info.apply("Roll", roll),
                    Text.of(TextColors.GRAY, "--------------------"),
                    info.apply("Completed", completed ? "YES" : "NO")
            )
            .title(Text.of(GRAY, "Ticket Info"))
            .paddingString("=")
            .sendTo(src);

    return CommandResult.success();
}
 
开发者ID:xDotDash,项目名称:HelpTicketsOld,代码行数:46,代码来源:CommandTicketInfo.java

示例9: 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;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:48,代码来源:ItemCategoryManager.java


注:本文中的ninja.leaping.configurate.commented.CommentedConfigurationNode.isVirtual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。