use of net.kyori.text.event.ClickEvent in project VoxelGamesLibv2 by VoxelGamesLib.
the class WorldCreator method author.
@Subcommand("author")
@CommandPermission("%admin")
public void author(@Nonnull User sender, @Nonnull String author) {
if (step != 5) {
Lang.msg(sender, LangKey.WORLD_CREATOR_WRONG_STEP, step, 5);
return;
}
this.author = author;
Lang.msg(sender, LangKey.WORLD_CREATOR_AUTHOR_SET, author);
for (GameMode mode : gameHandler.getGameModes()) {
sender.sendMessage(TextComponent.of(mode.getName() + " ").color(TextColor.YELLOW).clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/worldcreator gamemode " + mode.getName())));
}
Lang.msg(sender, LangKey.WORLD_CREATOR_DONE_QUERY, "/worldcreator gamemode done");
step = 6;
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class SearchCommand 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> " + (perm.asNode().getValuePrimitive() ? "&a" : "&c") + perm.asNode().getPermission(), " ", "&7Click to remove this node 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 TreeCommand method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
String selection = ".";
String player = null;
if (!args.isEmpty()) {
selection = args.get(0);
}
if (args.size() > 1) {
player = args.get(1);
}
User user;
if (player != null) {
UUID u = Uuids.parseNullable(player);
if (u != null) {
user = plugin.getUserManager().getIfLoaded(u);
} else {
user = plugin.getUserManager().getByUsername(player);
}
if (user == null) {
Message.USER_NOT_ONLINE.send(sender, player);
return CommandResult.STATE_ERROR;
}
} else {
user = null;
}
TreeView view = new TreeView(plugin.getPermissionVault(), selection);
if (!view.hasData()) {
Message.TREE_EMPTY.send(sender);
return CommandResult.FAILURE;
}
Message.TREE_UPLOAD_START.send(sender);
PermissionCache permissionData = user == null ? null : user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts()));
String id = view.uploadPasteData(sender, user, permissionData);
String url = plugin.getConfiguration().get(ConfigKeys.TREE_VIEWER_URL_PATTERN) + "?" + id;
Message.TREE_URL.send(sender);
Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(url))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the tree view.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class VerboseCommand method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
if (args.isEmpty()) {
sendUsage(sender, label);
return CommandResult.INVALID_ARGS;
}
String mode = args.get(0).toLowerCase();
if (mode.equals("on") || mode.equals("true") || mode.equals("record")) {
List<String> filters = new ArrayList<>();
if (args.size() != 1) {
filters.addAll(args.subList(1, args.size()));
}
String filter = filters.isEmpty() ? "" : filters.stream().collect(Collectors.joining(" "));
VerboseFilter parsedFilter;
try {
parsedFilter = VerboseFilter.parse(filter);
} catch (InvalidFilterException e) {
e.printStackTrace();
Message.VERBOSE_INVALID_FILTER.send(sender, filter);
return CommandResult.FAILURE;
}
boolean notify = !mode.equals("record");
plugin.getVerboseHandler().registerListener(sender, parsedFilter, notify);
if (notify) {
if (!filter.equals("")) {
Message.VERBOSE_ON_QUERY.send(sender, filter);
} else {
Message.VERBOSE_ON.send(sender);
}
} else {
if (!filter.equals("")) {
Message.VERBOSE_RECORDING_ON_QUERY.send(sender, filter);
} else {
Message.VERBOSE_RECORDING_ON.send(sender);
}
}
return CommandResult.SUCCESS;
}
if (mode.equals("off") || mode.equals("false") || mode.equals("paste") || mode.equals("upload")) {
VerboseListener listener = plugin.getVerboseHandler().unregisterListener(sender.getUuid());
if (mode.equals("paste") || mode.equals("upload")) {
if (listener == null) {
Message.VERBOSE_OFF.send(sender);
} else {
Message.VERBOSE_UPLOAD_START.send(sender);
String id = listener.uploadPasteData();
String url = plugin.getConfiguration().get(ConfigKeys.VERBOSE_VIEWER_URL_PATTERN) + "?" + id;
Message.VERBOSE_RESULTS_URL.send(sender);
Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(url))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the results page.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
} else {
Message.VERBOSE_OFF.send(sender);
}
return CommandResult.SUCCESS;
}
sendUsage(sender, label);
return CommandResult.INVALID_ARGS;
}
use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.
the class DebugCommand method execute.
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
Message.DEBUG_START.send(sender);
StringBuilder sb = new StringBuilder();
sb.append("LuckPerms Debug Output\n\n\n");
BiConsumer<String, JObject> builder = (name, content) -> {
sb.append("-- ").append(name).append(" --\n");
sb.append(GSON.toJson(content.toJson()));
sb.append("\n\n");
};
builder.accept("platform.json", getPlatformData(plugin));
builder.accept("storage.json", getStorageData(plugin));
builder.accept("context.json", getContextData(plugin));
builder.accept("players.json", getPlayersData(plugin));
Pastebin.Paste paste = StandardPastebin.HASTEBIN.postPlain(sb.toString());
Message.DEBUG_URL.send(sender);
Component message = TextComponent.builder(paste.url()).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(paste.url()))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the debugging data.").color(TextColor.GRAY))).build();
sender.sendMessage(message);
return CommandResult.SUCCESS;
}
Aggregations