use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class GroupListMembers method makeFancy.
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline("&3> &b" + perm.asNode().getGroupName(), " ", "&7Click to remove this parent from " + holderName), CommandManager.AMPERSAND_CHAR));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, holderType, false);
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> {
component.hoverEvent(hoverEvent);
component.clickEvent(clickEvent);
};
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class MetaInfo method makeFancy.
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(ChatMetaType type, PermissionHolder holder, String label, LocalizedNode node) {
if (!node.getLocation().equals(holder.getObjectName())) {
// inherited.
Group group = holder.getPlugin().getGroupManager().getIfLoaded(node.getLocation());
if (group != null) {
holder = group;
}
}
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline("¥3> ¥a" + type.getEntry(node).getKey() + " ¥7- ¥r" + type.getEntry(node).getValue(), " ", "¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFriendlyName()), '¥'));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false);
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> {
component.hoverEvent(hoverEvent);
component.clickEvent(clickEvent);
};
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class MetaInfo method makeFancy.
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(PermissionHolder holder, String label, LocalizedNode node) {
if (!node.getLocation().equals(holder.getObjectName())) {
// inherited.
Group group = holder.getPlugin().getGroupManager().getIfLoaded(node.getLocation());
if (group != null) {
holder = group;
}
}
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline("¥3> ¥r" + node.getMeta().getKey() + " ¥7- ¥r" + node.getMeta().getValue(), " ", "¥7Click to remove this meta pair from " + holder.getFriendlyName()), '¥'));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false);
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> {
component.hoverEvent(hoverEvent);
component.clickEvent(clickEvent);
};
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class PermissionInfo method makeFancy.
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(PermissionHolder holder, String label, Node node) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline("¥3> " + (node.getValuePrimitive() ? "¥a" : "¥c") + node.getPermission(), " ", "¥7Click to remove this node from " + holder.getFriendlyName()), '¥'));
String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFriendlyName(), holder.getType(), false);
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return component -> {
component.hoverEvent(hoverEvent);
component.clickEvent(clickEvent);
};
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class HolderEditor method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T holder, List<String> args, String label) {
if (ArgumentPermissions.checkViewPerms(plugin, sender, getPermission().get(), holder)) {
Message.COMMAND_NO_PERMISSION.send(sender);
return CommandResult.NO_PERMISSION;
}
Message.EDITOR_START.send(sender);
// form the payload data
JsonObject payload = WebEditor.formPayload(Collections.singletonList(holder), sender, label, plugin);
// upload the payload data to gist
String pasteId = StandardPastebin.BYTEBIN.postJson(payload, true).id();
if (pasteId == null) {
Message.EDITOR_UPLOAD_FAILURE.send(sender);
return CommandResult.STATE_ERROR;
}
// form a url for the editor
String url = plugin.getConfiguration().get(ConfigKeys.WEB_EDITOR_URL_PATTERN) + "?" + pasteId;
Message.EDITOR_URL.send(sender);
Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the editor.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
Aggregations