• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClickAction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongepowered.api.text.action.ClickAction的典型用法代码示例。如果您正苦于以下问题:Java ClickAction类的具体用法?Java ClickAction怎么用?Java ClickAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClickAction类属于org.spongepowered.api.text.action包,在下文中一共展示了ClickAction类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: callback

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
protected ClickAction.ExecuteCallback callback(Chunk chunk) {
    return TextActions.executeCallback((commandSource -> {
        if (commandSource instanceof ConsoleSource) {
            commandSource.sendMessage(Text.of(TextColors.RED + "Silly console, you can't teleport."));
            return;
        }
        Player player = (Player) commandSource;
        Location<World> a = new Location<>(chunk.getWorld(), chunk.getPosition());
        Location<World> b = new Location<>(a.getExtent(), a.getX() * 16, a.getExtent().getBlockMax().getY(), a.getZ() * 16);
        Optional<BlockRayHit<World>> c = BlockRay.from(b).stopFilter(BlockRay.onlyAirFilter()).to(a.getPosition().sub(b.getX(), 1, b.getZ()))
                .end();

        if (c.isPresent()) {
            BlockRayHit<World> d = c.get();
            player.setLocation(d.getLocation());
        } else {
            commandSource.sendMessage(Text.of("Could not send you to: " + a.getX() + "," + a.getZ()));
        }
    }));
}
 
开发者ID:Time6628,项目名称:CatClearLag,代码行数:21,代码来源:LaggyChunksCommand.java


示例2: raw

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
public static RawAction raw(ClickAction<?> clickAction) {
    if (clickAction instanceof ClickAction.ChangePage) {
        return new RawAction("change_page", ((ClickAction.ChangePage) clickAction).getResult().toString());
    } else if (clickAction instanceof ClickAction.OpenUrl) {
        final URL url = ((ClickAction.OpenUrl) clickAction).getResult();
        final String scheme = url.getProtocol();
        final String host = url.getProtocol();
        if ("file".equalsIgnoreCase(scheme) && (host == null || host.equals(""))) {
            return new RawAction("open_file", url.getFile());
        } else {
            return new RawAction("open_url", url.toExternalForm());
        }
    } else if (clickAction instanceof ClickAction.ExecuteCallback) {
        final UUID uniqueId = LanternClickActionCallbacks.get().getOrCreateIdForCallback(
                ((ClickAction.ExecuteCallback) clickAction).getResult());
        return new RawAction("run_command", LanternClickActionCallbacks.COMMAND_BASE + uniqueId.toString());
    } else if (clickAction instanceof ClickAction.RunCommand) {
        return new RawAction("run_command", ((ClickAction.RunCommand) clickAction).getResult());
    } else if (clickAction instanceof ClickAction.SuggestCommand) {
        return new RawAction("suggest_command", ((ClickAction.SuggestCommand) clickAction).getResult());
    } else {
        throw new IllegalArgumentException("Unknown click action type: " + clickAction.getClass().getName());
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:LanternTextHelper.java


示例3: createClickAction

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
@Override
protected ClickAction<?> createClickAction(ConfigEntry entry, ConfigEditTab boundTab) {
    if (!boundTab.control.options.canEdit) {
        return null;
    }
    return this.type.createClickAction(this.value, entry, boundTab);
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:8,代码来源:ConfigEntry.java


示例4: onClick

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
private ClickAction<?> onClick(Runnable callback) {
    return Utils.execClick(view -> {
        if (!ChatUI.isTabActive(view, this.tab) || this.tab.nodeBuilder != this) {
            return;
        }
        callback.run();
        view.update();
    });
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:10,代码来源:NodeBuilder.java


示例5: clickAction

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
public static ClickAction<?> clickAction(Runnable action, Tab tab) {
    return clickAction(view -> {
        action.run();
        return true;
    }, tab);
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:7,代码来源:ExtraUtils.java


示例6: command

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
public static ClickAction<?> command(String subcommand) {
    return TextActions.runCommand("/chatui " + subcommand);
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:4,代码来源:ChatUILib.java


示例7: drawTextArea

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
void drawTextArea(PlayerContext ctx, LineFactory lineFactory) {
    int remaining = ctx.height;
    int largestLineNum = Math.min(this.lines.size(), this.viewOffset + ctx.height);
    int largestNumWidth = ctx.utils().getStringWidth(String.valueOf(largestLineNum), false);
    char sp = ' ';
    int spWidth = ctx.utils().getWidth(sp, false);

    for (int i = this.viewOffset; i < this.lines.size(); i++) {
        String line = this.lines.get(i);
        List<String> splitLines = ctx.utils().splitLines(line, ctx.width - largestNumWidth - spWidth);

        Text.Builder lineBuilder = Text.builder();

        ClickAction<?> lineClick;
        if (this.activeLine == i) {
            lineClick = TextActions.suggestCommand(line);
            lineBuilder.style(TextStyles.UNDERLINE);
        } else {
            lineClick = Utils.execClick(setActiveLine(i, false));

        }
        lineBuilder.onClick(lineClick);

        for (int j = 0; j < splitLines.size(); j++) {
            String outputLine = splitLines.get(j);

            StringBuilder sideLine = new StringBuilder();
            if (j == 0) {
                String ourLine = String.valueOf(i + 1); // + 1 for 1-indexed
                TextUtils.padSpaces(sideLine, largestNumWidth - ctx.utils().getStringWidth(ourLine, false));
                sideLine.append(ourLine);
            } else {
                TextUtils.padSpaces(sideLine, largestNumWidth);
            }
            sideLine.append(sp);
            lineBuilder.append(Text.builder(sideLine.toString()).color(TextColors.GRAY).build());
            lineBuilder.append(Text.of(outputLine));
            lineFactory.appendNewLine(lineBuilder.build(), ctx);
            lineBuilder.removeAll();
            remaining--;
            if (remaining == 0) {
                break;
            }
        }
        if (remaining == 0) {
            break;
        }
    }
    if (remaining > 0) {
        Text newlineButton = Text.builder("*").color(TextColors.GRAY)
                .onClick(Utils.execClick(setActiveLine(this.lines.size(), remaining < 2)))
                .build();
        lineFactory.appendNewLine(newlineButton, ctx);
    }
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:56,代码来源:TextEditorWindow.java


示例8: execClick

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
public static ClickAction<?> execClick(Consumer<PlayerChatView> handler) {
    return TextActions.runCommand(ClickCallback.generateCommand(handler));
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:4,代码来源:Utils.java


示例9: sendClickableMessage

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
public Text sendClickableMessage(String path, ClickAction<?> action){
	return Text.builder(TextSerializers.FORMATTING_CODE.replaceCodes(configNode.getNode(path).getString(), '&'))
			.onClick(action).build();
}
 
开发者ID:NamelessMC,项目名称:Nameless-Plugin,代码行数:5,代码来源:MessagesUtil.java


示例10: execute

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
@Override
public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    try {
        if (args.hasAny("username")) {
            String username = args.<String>getOne("username").get();
            Profile profile = profileResolver.findByName(username);
            if (profile == null) {
                src.sendMessage(Texts.of(TextColors.RED,"Sorry failed to find a profile for that username."));
                return CommandResult.empty();
            }
            src.sendMessage(Texts.of(TextColors.GREEN, "Found a profile for the provided username."));
            ClickAction.SuggestCommand clickAction = new ClickAction.SuggestCommand(profile.getUniqueId().toString());
            Text clickableUUID = Texts.builder()
                    .append(Texts.of(TextColors.GREEN, profile.getUniqueId().toString()))
                    .onClick(clickAction).build();
            src.sendMessage(Texts.of(TextColors.BLUE, profile.getName(), TextColors.GRAY, ": ", clickableUUID));

            MinecraftSkin skin = game.getServiceManager().provideUnchecked(SkinResolverService.class).getSkin(profile.getUniqueId());
            if (skin == null) {
                src.sendMessage(Texts.of(TextColors.RED, "Failed to resolve skin for the profile."));
            } else {
                src.sendMessage(Texts.of(TextColors.GREEN, "Skin type: ", skin.type));
                ColorMapping mapping = ColorMapping.matchColor(new Color(skin.texture.getRGB(12, 12)));
                String message = String.format("The matching block was %s and the color was %s", mapping.equivalentBlock.toString(), mapping.dyeColor.orNull() == null ? "null" : mapping.dyeColor.toString());

                if (src instanceof Player) {
                    Player player = (Player) src;
                    Vector3d rot = player.getRotation();
                    int value = floor_double((double)(rot.getX() * 4.0F / 360.0F) + 0.5D) & 3;
                    System.out.println(value);
                    player.sendMessage(Texts.of((rot.getX() * 4.0F / 360.0F) + 0.5D));
                    player.sendMessage(Texts.of(rot.getX() * 4.0F / 360.0F));
                    player.sendMessage(Texts.of(value));
                    int pos = ((value < 0 ? -value : value) % 4);
                    Direction buildDirection = null;
                    switch (pos) {
                        case 0:
                            // South
                            System.out.println("SOUTH");
                            player.sendMessage(Texts.of("SOUTH"));
                            buildDirection = Direction.SOUTH;
                            break;
                        case 1:
                            // WEST
                            System.out.println("WEST");
                            player.sendMessage(Texts.of("WEST"));
                            buildDirection = Direction.WEST;
                            break;
                        case 2:
                            // NORTH
                            System.out.println("NORTH");
                            player.sendMessage(Texts.of("NORTH"));
                            buildDirection = Direction.NORTH;
                            break;
                        case 3:
                            // EAST
                            System.out.println("EAST");
                            player.sendMessage(Texts.of("EAST"));
                            buildDirection = Direction.EAST;
                            break;
                    }

                }
            }
            return CommandResult.success();
        }
        return CommandResult.empty();
    } catch (Throwable th) {
        th.printStackTrace();
        return CommandResult.empty();
    }
}
 
开发者ID:modwizcode,项目名称:Statue,代码行数:73,代码来源:TestResolveCommand.java


示例11: prepare

import org.spongepowered.api.text.action.ClickAction; //导入依赖的package包/类
public static Message.Text prepare(final InfluxManager<?> manager, final SpongeHelpEntry helpEntry, String message, int maxDescLength) {
    int aliases = helpEntry.getController().getCommand().getAliases().size();
    MessageBuilder.Text result = Messages.builder("");

    int next = 0;
    Matcher matcher = Pattern.compile("<(.+?)>").matcher(message);
    while (next < message.length()) {
        if (matcher.find()) {
            if (matcher.start() > next) {
                result.append(Messages.of(manager.getResponder().format(message.substring(matcher.start(), next))));
            }
            next = matcher.end() + 1;
            switch (matcher.group(1)) {
                case "command":
                    result.append(Messages.of(manager.getResponder().format(manager.getCommandPrefix() + helpEntry.getController().getCommand().getAcceptedStringSyntax(), false)))
                            .style(TextStyles.UNDERLINE)
                            .onHover(new HoverAction.ShowText() {
                                @Override
                                public String getId() {
                                    return "auto-complete";
                                }

                                @Override
                                public Message getResult() {
                                    return Messages.of(manager.getResponder().format("{c2}Click to auto-complete"));
                                }
                            })
                            .onClick(new ClickAction.SuggestCommand() {
                                @Override
                                public String getId() {
                                    return "entry-command";
                                }

                                @Override
                                public String getResult() {
                                    return helpEntry.getController().getCommand().getAcceptedStringSyntax();
                                }
                            });
                    break;
                case "alias_num":
                    result.append(Messages.of(aliases + " alias" + (aliases == 1 ? "" : "es") + ""));
                    if (aliases > 1) {
                        result.onHover(new HoverAction.ShowText() {
                            @Override
                            public String getId() {
                                return "aliases";
                            }

                            @Override
                            public Message getResult() {
                                return Messages.of(manager.getResponder().format(StringUtil.combine("{c1}, {c2}", helpEntry.getController().getCommand().getReadableStringAliases())));
                            }
                        });
                    }
                    break;
                case "short_desc":
                case "long_desc":
                    String desc = matcher.group(1).equals("short_desc") ? helpEntry.getShortDescription() : StringUtil.combineArray("\n", helpEntry.getLongDescription()[0]);
                    if (maxDescLength > 0) {
                        desc = desc.length() > maxDescLength ? desc.substring(0, maxDescLength - 3) + "..." : desc;
                    }
                    result.append(Messages.of(desc));
                    break;
                default:
                    result.append(Messages.of(manager.getResponder().format(matcher.group(0), false)));
                    break;
            }
        } else {
            // We're done
            result.append(Messages.of(message.substring(next)));
            break;
        }
    }

    return result.build();
}
 
开发者ID:DSH105,项目名称:Influx,代码行数:77,代码来源:SpongeHelpProvider.java



注:本文中的org.spongepowered.api.text.action.ClickAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TernaryValue类代码示例发布时间:2022-05-23
下一篇:
Java RubyNumeric类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap