net.kyori.text.event.HoverEvent Java Examples
The following examples show how to use
net.kyori.text.event.HoverEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandClaimInfo.java From GriefDefender with MIT License | 7 votes |
public Component getClickableInfoText(CommandSender src, Claim claim, int titleId, Component infoText) { Component onClickText = MessageCache.getInstance().CLAIMINFO_UI_CLICK_TOGGLE; boolean hasPermission = true; if (src instanceof Player) { Component denyReason = ((GDClaim) claim).allowEdit((Player) src); if (denyReason != null) { onClickText = denyReason; hasPermission = false; } } TextComponent.Builder textBuilder = TextComponent.builder() .append(infoText) .hoverEvent(HoverEvent.showText(onClickText)); if (hasPermission) { textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimInfoConsumer(src, claim, titleId)))); } return textBuilder.build(); }
Example #2
Source File: ChatCaptureUtil.java From GriefDefender with MIT License | 6 votes |
public Component getRecordChatClickableInfoText(CommandSource src, GDClaim claim, Component clickText, Component infoText, String command) { boolean hasPermission = true; if (claim != null && src instanceof Player) { Component denyReason = claim.allowEdit((Player) src); if (denyReason != null) { clickText = denyReason; hasPermission = false; } } TextComponent.Builder textBuilder = TextComponent.builder() .append(infoText) .hoverEvent(HoverEvent.showText(clickText)); if (hasPermission) { textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createChatInfoConsumer(src, claim, command)))); } return textBuilder.build(); }
Example #3
Source File: CommandManager.java From LuckPerms with MIT License | 6 votes |
private void sendCommandUsage(Sender sender, String label) { Message.BLANK.send(sender, "&2Running &b" + AbstractLuckPermsPlugin.getPluginName() + " v" + this.plugin.getBootstrap().getVersion() + "&2."); this.mainCommands.values().stream() .filter(Command::shouldDisplay) .filter(c -> c.isAuthorized(sender)) .forEach(c -> { String permission = c.getPermission().map(CommandPermission::getPermission).orElse("None"); TextComponent component = TextUtils.fromLegacy("&3> &a" + String.format(c.getUsage(), label), TextUtils.AMPERSAND_CHAR) .toBuilder().applyDeep(comp -> { comp.hoverEvent(HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "&bCommand: &2" + c.getName(), "&bDescription: &2" + c.getDescription(), "&bUsage: &2" + String.format(c.getUsage(), label), "&bPermission: &2" + permission, " ", "&7Click to auto-complete." ), TextUtils.AMPERSAND_CHAR))); comp.clickEvent(ClickEvent.suggestCommand(String.format(c.getUsage(), label))); }).build(); sender.sendMessage(component); }); }
Example #4
Source File: SearchCommand.java From LuckPerms with MIT License | 6 votes |
private static Consumer<ComponentBuilder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, NodeEntry<?, ?> perm, LuckPermsPlugin plugin) { HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "&3> " + (perm.getNode().getValue() ? "&a" : "&c") + perm.getNode().getKey(), " ", "&7Click to remove this node from " + holderName ), TextUtils.AMPERSAND_CHAR)); boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); String command = "/" + label + " " + NodeCommandFactory.undoCommand(perm.getNode(), holderName, holderType, explicitGlobalContext); ClickEvent clickEvent = ClickEvent.suggestCommand(command); return component -> { component.hoverEvent(hoverEvent); component.clickEvent(clickEvent); }; }
Example #5
Source File: MetaInfo.java From LuckPerms with MIT License | 6 votes |
private static Consumer<ComponentBuilder<?, ?>> makeFancy(PermissionHolder holder, String label, MetaNode node) { String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName(); if (!location.equals(holder.getObjectName())) { // inherited. Group group = holder.getPlugin().getGroupManager().getIfLoaded(location); if (group != null) { holder = group; } } HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "§3> §r" + node.getMetaKey() + " §7- §r" + node.getMetaValue(), " ", "§7Click to remove this meta pair from " + holder.getPlainDisplayName() ), '§')); String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); ClickEvent clickEvent = ClickEvent.suggestCommand(command); return component -> { component.hoverEvent(hoverEvent); component.clickEvent(clickEvent); }; }
Example #6
Source File: CommandClaimInfo.java From GriefDefender with MIT License | 6 votes |
public Component getClickableInfoText(CommandSource src, Claim claim, int titleId, Component infoText) { Component onClickText = MessageCache.getInstance().CLAIMINFO_UI_CLICK_TOGGLE; boolean hasPermission = true; if (src instanceof Player) { Component denyReason = ((GDClaim) claim).allowEdit((Player) src); if (denyReason != null) { onClickText = denyReason; hasPermission = false; } } TextComponent.Builder textBuilder = TextComponent.builder() .append(infoText) .hoverEvent(HoverEvent.showText(onClickText)); if (hasPermission) { textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createClaimInfoConsumer(src, claim, titleId)))); } return textBuilder.build(); }
Example #7
Source File: MetaInfo.java From LuckPerms with MIT License | 6 votes |
private static Consumer<ComponentBuilder<?, ?>> makeFancy(PermissionHolder holder, String label, ChatMetaNode<?, ?> node) { String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName(); if (!location.equals(holder.getObjectName())) { // inherited. Group group = holder.getPlugin().getGroupManager().getIfLoaded(location); if (group != null) { holder = group; } } HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "§3> §a" + node.getPriority() + " §7- §r" + node.getMetaValue(), " ", "§7Click to remove this " + node.getMetaType().name().toLowerCase() + " from " + holder.getPlainDisplayName() ), '§')); String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); ClickEvent clickEvent = ClickEvent.suggestCommand(command); return component -> { component.hoverEvent(hoverEvent); component.clickEvent(clickEvent); }; }
Example #8
Source File: PermissionInfo.java From LuckPerms with MIT License | 6 votes |
private static Consumer<ComponentBuilder<?, ?>> makeFancy(PermissionHolder holder, String label, Node node) { HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "§3> " + (node.getValue() ? "§a" : "§c") + node.getKey(), " ", "§7Click to remove this node from " + holder.getPlainDisplayName() ), '§')); String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); ClickEvent clickEvent = ClickEvent.suggestCommand(command); return component -> { component.hoverEvent(hoverEvent); component.clickEvent(clickEvent); }; }
Example #9
Source File: CommandEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerChatPost(AsyncPlayerChatEvent event) { final Player player = event.getPlayer(); final Iterator<Player> iterator = event.getRecipients().iterator(); while (iterator.hasNext()) { final Player receiver = iterator.next(); if (receiver == player) { continue; } final GDPlayerData receiverData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(receiver.getWorld(), receiver.getUniqueId()); if (receiverData.isRecordingChat()) { iterator.remove(); final String s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); final Component message = LegacyComponentSerializer.legacy().deserialize(s, '&'); final Component component = TextComponent.builder() .append(TextComponent.builder() .append(message) .hoverEvent(HoverEvent.showText(TextComponent.of(formatter.format(Instant.now())))) .build()) .build(); receiverData.chatLines.add(component); } } }
Example #10
Source File: CommandHelper.java From GriefDefender with MIT License | 6 votes |
public static Component getClickableText(CommandSender src, GDPermissionHolder subject, String subjectName, Set<Context> contexts, GDClaim claim, Flag flag, Tristate flagValue, String source, MenuType type) { Component onClickText = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TOGGLE_VALUE, ImmutableMap.of("type", "flag")); boolean hasPermission = true; if (type == MenuType.INHERIT) { onClickText = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.FLAG_UI_INHERIT_PARENT, ImmutableMap.of("name", claim.getFriendlyNameType())); hasPermission = false; } else if (src instanceof Player) { Component denyReason = claim.allowEdit((Player) src); if (denyReason != null) { onClickText = denyReason; hasPermission = false; } } TextComponent.Builder textBuilder = TextComponent.builder(flagValue.toString().toLowerCase()) .hoverEvent(HoverEvent.showText(TextComponent.builder("") .append(onClickText) .append("\n") .append(UIHelper.getPermissionMenuTypeHoverText(type)).build())); if (hasPermission) { textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createFlagConsumer(src, subject, subjectName, contexts, claim, flag, flagValue, source)))); } return textBuilder.build(); }
Example #11
Source File: MapPoll.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
private Component getMapBookComponent(MatchPlayer viewer, MapInfo map) { boolean voted = votes.get(map).contains(viewer.getId()); return TextComponent.builder() .append( voted ? SYMBOL_VOTED : SYMBOL_IGNORE, voted ? TextColor.DARK_GREEN : TextColor.DARK_RED) .append( TextComponent.of(" ").decoration(TextDecoration.BOLD, !voted)) // Fix 1px symbol diff .append(map.getName() + "\n", TextColor.GOLD, TextDecoration.BOLD) .hoverEvent( HoverEvent.showText( TextComponent.of( map.getTags().stream().map(MapTag::toString).collect(Collectors.joining(" ")), TextColor.YELLOW))) .clickEvent(ClickEvent.runCommand("/votenext -o " + map.getName())) .build(); }
Example #12
Source File: ParentInfo.java From LuckPerms with MIT License | 6 votes |
private static Consumer<ComponentBuilder<? ,?>> makeFancy(PermissionHolder holder, String label, InheritanceNode node) { HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "&3> &f" + node.getGroupName(), " ", "&7Click to remove this parent from " + holder.getPlainDisplayName() ), TextUtils.AMPERSAND_CHAR)); String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); ClickEvent clickEvent = ClickEvent.suggestCommand(command); return component -> { component.hoverEvent(hoverEvent); component.clickEvent(clickEvent); }; }
Example #13
Source File: ChatCaptureUtil.java From GriefDefender with MIT License | 6 votes |
public Component getRecordChatClickableInfoText(CommandSender src, GDClaim claim, Component clickText, Component infoText, String command) { boolean hasPermission = true; if (claim != null && src instanceof Player) { Component denyReason = claim.allowEdit((Player) src); if (denyReason != null) { clickText = denyReason; hasPermission = false; } } TextComponent.Builder textBuilder = TextComponent.builder() .append(infoText) .hoverEvent(HoverEvent.showText(clickText)); if (hasPermission) { textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createChatInfoConsumer(src, claim, command)))); } return textBuilder.build(); }
Example #14
Source File: CommandHelper.java From GriefDefender with MIT License | 6 votes |
public static Component getClickableText(CommandSource src, GDPermissionHolder subject, String subjectName, Set<Context> contexts, GDClaim claim, Flag flag, Tristate flagValue, String source, MenuType type) { Component onClickText = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIMLIST_UI_CLICK_TOGGLE_VALUE, ImmutableMap.of("type", "flag")); boolean hasPermission = true; if (type == MenuType.INHERIT) { onClickText = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.FLAG_UI_INHERIT_PARENT, ImmutableMap.of("name", claim.getFriendlyNameType())); hasPermission = false; } else if (src instanceof Player) { Component denyReason = claim.allowEdit((Player) src); if (denyReason != null) { onClickText = denyReason; hasPermission = false; } } TextComponent.Builder textBuilder = TextComponent.builder(flagValue.toString().toLowerCase()) .hoverEvent(HoverEvent.showText(TextComponent.builder("") .append(onClickText) .append("\n") .append(UIHelper.getPermissionMenuTypeHoverText(type)).build())); if (hasPermission) { textBuilder.clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createFlagConsumer(src, subject, subjectName, contexts, claim, flag, flagValue, source)))); } return textBuilder.build(); }
Example #15
Source File: CommandClaimDeleteAllAdmin.java From GriefDefender with MIT License | 5 votes |
@CommandAlias("deletealladmin") @Description("Deletes all administrative claims.") @Subcommand("delete alladmin") public void execute(Player player, @Optional String worldName) { WorldProperties worldProperties = null; if (worldName != null) { worldProperties = Sponge.getServer().getWorldProperties(worldName).orElse(null); if (worldProperties == null) { TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_WORLD_NOT_FOUND, ImmutableMap.of("world", worldName))); return; } } Component message = null; if (worldProperties != null) { message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_ALL_TYPE_WARNING_WORLD, ImmutableMap.of( "type", TextComponent.of("ADMIN").color(TextColor.RED), "world", worldProperties.getWorldName())); } else { message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_ALL_TYPE_WARNING, ImmutableMap.of( "type", TextComponent.of("ADMIN").color(TextColor.RED))); } final Component confirmationText = TextComponent.builder("") .append(message) .append(TextComponent.builder() .append("\n[") .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN)) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player, worldProperties), true))) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build()) .build(); TextAdapter.sendComponent(player, confirmationText); }
Example #16
Source File: CommandRestoreClaim.java From GriefDefender with MIT License | 5 votes |
private static void displayConfirmationConsumer(CommandSource src, GDClaim claim) { final Component schematicConfirmationText = TextComponent.builder("") .append("Are you sure you want to restore this claim?") .append("\n[") .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN)) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, claim), true))) .hoverEvent(HoverEvent.showText(TextComponent.of("Clicking confirm will restore ENTIRE claim back to default world gen state. Use cautiously!"))).build(); GriefDefenderPlugin.sendMessage(src, schematicConfirmationText); }
Example #17
Source File: CommandTrustList.java From GriefDefender with MIT License | 5 votes |
private static Consumer<CommandSource> createInputConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, List<Component> messages, Component returnCommand) { return consumer -> { if (messages == null || messages.isEmpty()) { playerData.commandInputTimestamp = Instant.now(); playerData.commandConsumer = createAddConsumer(src, claim, playerData, type, returnCommand); } messages.add(TextComponent.builder() .append(TextComponent.of("Do you want to add a ") .append(TextComponent.builder() .append(MessageCache.getInstance().LABEL_PLAYER.color(TextColor.GOLD)) .clickEvent(ClickEvent.suggestCommand("player <name>")) .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_ADD_TARGET, ImmutableMap.of("target", "player")))) .build()) .append(TextComponent.of(" or ")) .append(TextComponent.builder() .append(MessageCache.getInstance().LABEL_GROUP.color(TextColor.AQUA)) .clickEvent(ClickEvent.suggestCommand("group <name>")) .hoverEvent(HoverEvent.showText(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_ADD_TARGET, ImmutableMap.of("target", "group")))) .build())) .append(" ? ") .append("[") .append(TextComponent.builder() .append(MessageCache.getInstance().LABEL_CANCEL.color(TextColor.RED)) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand( createCancelConsumer(src, claim, playerData, type, returnCommand)))) .build()) .append("]") .build()); showTrustList(src, claim, playerData, type, messages, returnCommand); }; }
Example #18
Source File: ClaimFlagBase.java From GriefDefender with MIT License | 5 votes |
private Component getFlagText(Flag flag, Set<Context> contexts) { boolean customContext = UIHelper.containsCustomContext(contexts); final Component baseFlagText = TextComponent.builder().color(customContext ? TextColor.YELLOW : TextColor.GREEN).append(flag.getName() + " ") .hoverEvent(HoverEvent.showText(TextComponent.builder() .append(flag.getDescription()) .build())).build(); return baseFlagText; }
Example #19
Source File: CommandClaimSchematic.java From GriefDefender with MIT License | 5 votes |
private static Consumer<CommandSource> displayConfirmationConsumer(CommandSource src, Claim claim, ClaimSchematic schematic) { return confirm -> { final Component schematicConfirmationText = TextComponent.builder("") .append("\n[") .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN)) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, claim, schematic), true))) .hoverEvent(HoverEvent.showText(GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.SCHEMATIC_RESTORE_CONFIRMATION))).build(); TextAdapter.sendComponent(src, schematicConfirmationText); }; }
Example #20
Source File: CommandClaimFlagReset.java From GriefDefender with MIT License | 5 votes |
@CommandAlias("cfr") @Description("Resets a claim to flag defaults.") @Subcommand("flag reset") public void execute(Player player) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_CLAIM_RESET_FLAGS, ImmutableMap.of( "type", claim.getType().getName())); if (claim.isWilderness()) { if (!player.hasPermission(GDPermissions.MANAGE_WILDERNESS)) { GriefDefenderPlugin.sendMessage(player, message); return; } } else if (claim.isAdminClaim()) { if (!player.getUniqueId().equals(claim.getOwnerUniqueId()) && !player.hasPermission(GDPermissions.COMMAND_ADMIN_CLAIMS)) { GriefDefenderPlugin.sendMessage(player, message); return; } } else if (!player.hasPermission(GDPermissions.COMMAND_ADMIN_CLAIMS) && (claim.isBasicClaim() || claim.isSubdivision()) && !player.getUniqueId().equals(claim.getOwnerUniqueId())) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().PERMISSION_CLAIM_RESET_FLAGS_SELF); return; } final Component confirmationText = TextComponent.builder() .append(MessageCache.getInstance().FLAG_RESET_WARNING) .append(TextComponent.builder() .append("\n[") .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN)) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player, claim), true))) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build()) .build(); TextAdapter.sendComponent(player, confirmationText); }
Example #21
Source File: CommandClaimDelete.java From GriefDefender with MIT License | 5 votes |
@CommandAlias("deleteclaim") @Description("Deletes the claim you're standing in, even if it's not your claim.") @Subcommand("delete claim") public void execute(Player player) { final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(player.getLocation()); if (claim.isWilderness()) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().CLAIM_NOT_FOUND); return; } final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.PERMISSION_CLAIM_DELETE, ImmutableMap.of( "type", claim.getType().getName())); if (claim.isAdminClaim() && !player.hasPermission(GDPermissions.DELETE_CLAIM_ADMIN)) { GriefDefenderPlugin.sendMessage(player, message); return; } if (claim.isBasicClaim() && !player.hasPermission(GDPermissions.DELETE_CLAIM_BASIC)) { GriefDefenderPlugin.sendMessage(player, message); return; } final Component confirmationText = TextComponent.builder() .append(GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.DELETE_CLAIM_WARNING, ImmutableMap.of("player", claim.getOwnerDisplayName().color(TextColor.AQUA)))) .append(TextComponent.builder() .append("\n[") .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN)) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(player, createConfirmationConsumer(player, claim, deleteTopLevelClaim), true))) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build()) .build(); TextAdapter.sendComponent(player, confirmationText); }
Example #22
Source File: ClaimOptionBase.java From GriefDefender with MIT License | 5 votes |
private Component getOptionText(Option option, Set<Context> contexts) { boolean customContext = this.containsCustomContext(option, contexts); final Component optionText = TextComponent.builder().color(customContext ? TextColor.YELLOW : TextColor.GREEN).append(option.getName() + " ") .hoverEvent(HoverEvent.showText(TextComponent.builder() .append(option.getDescription()) .build())).build(); return optionText; }
Example #23
Source File: PlayerComponent.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
static TextComponent.Builder formatTeleport(TextComponent.Builder username, String name) { return username .hoverEvent( HoverEvent.of( Action.SHOW_TEXT, TranslatableComponent.of("misc.teleportTo", TextColor.GRAY, username.build()))) .clickEvent(ClickEvent.runCommand("/tp " + name)); }
Example #24
Source File: ModerationCommand.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
private Component formatAltAccountBroadcast(BannedAccountInfo info, MatchPlayer player) { Component message = TranslatableComponent.of( "moderation.similarIP.loginEvent", player.getName(NameStyle.FANCY), TextComponent.of(info.getUserName(), TextColor.DARK_AQUA)); return message.hoverEvent(HoverEvent.of(Action.SHOW_TEXT, info.getHoverMessage())); }
Example #25
Source File: MapCommand.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
private Component createTagsComponent(Collection<MapTag> tags) { checkNotNull(tags); Builder result = TextComponent.builder().append(mapInfoLabel("map.info.tags")); MapTag[] mapTags = tags.toArray(new MapTag[0]); for (int i = 0; i < mapTags.length; i++) { if (i != 0) { result.append(TextComponent.space()); } String mapTag = mapTags[i].getId(); Component tag = TextComponent.builder() .append("#") .append(mapTag) .clickEvent(ClickEvent.runCommand("/maps -t " + mapTag)) .hoverEvent( HoverEvent.showText( TranslatableComponent.of( "map.info.mapTag.hover", TextColor.GRAY, TextComponent.of(mapTag, TextColor.GOLD)))) .build(); result.append(tag); } return result.color(TextColor.GOLD).build(); }
Example #26
Source File: GamemodeTool.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
private Component getToggleMessage() { Component command = TextComponent.of("/tools", TextColor.AQUA) .hoverEvent( HoverEvent.showText( TranslatableComponent.of("setting.gamemode.hover", TextColor.GRAY))) .clickEvent(ClickEvent.runCommand("/tools")); return TranslatableComponent.of("setting.gamemode.warning", TextColor.GRAY, command); }
Example #27
Source File: VelocityCommand.java From Velocity with MIT License | 5 votes |
private TextComponent componentForPlugin(PluginDescription description) { String pluginInfo = description.getName().orElse(description.getId()) + description.getVersion().map(v -> " " + v).orElse(""); TextComponent.Builder hoverText = TextComponent.builder(pluginInfo); description.getUrl().ifPresent(url -> { hoverText.append(TextComponent.newline()); hoverText.append(TextComponent.of("Website: " + url)); }); if (!description.getAuthors().isEmpty()) { hoverText.append(TextComponent.newline()); if (description.getAuthors().size() == 1) { hoverText.append(TextComponent.of("Author: " + description.getAuthors().get(0))); } else { hoverText.append(TextComponent.of("Authors: " + Joiner.on(", ") .join(description.getAuthors()))); } } description.getDescription().ifPresent(pdesc -> { hoverText.append(TextComponent.newline()); hoverText.append(TextComponent.newline()); hoverText.append(TextComponent.of(pdesc)); }); return TextComponent.of(description.getId(), TextColor.GRAY) .hoverEvent(HoverEvent.showText(hoverText.build())); }
Example #28
Source File: GroupListMembers.java From LuckPerms with MIT License | 5 votes |
private static Consumer<ComponentBuilder<? ,?>> makeFancy(String holderName, HolderType holderType, String label, NodeEntry<?, ?> perm, LuckPermsPlugin plugin) { HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( "&3> &b" + ((InheritanceNode) perm.getNode()).getGroupName(), " ", "&7Click to remove this parent from " + holderName ), TextUtils.AMPERSAND_CHAR)); boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); String command = "/" + label + " " + NodeCommandFactory.undoCommand(perm.getNode(), holderName, holderType, explicitGlobalContext); ClickEvent clickEvent = ClickEvent.suggestCommand(command); return component -> { component.hoverEvent(hoverEvent); component.clickEvent(clickEvent); }; }
Example #29
Source File: CommandRestoreClaim.java From GriefDefender with MIT License | 5 votes |
private static void displayConfirmationConsumer(CommandSender src, GDClaim claim) { final Component schematicConfirmationText = TextComponent.builder("") .append("Are you sure you want to restore this claim?") .append("\n[") .append(MessageCache.getInstance().LABEL_CONFIRM.color(TextColor.GREEN)) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(src, createConfirmationConsumer(src, claim), true))) .hoverEvent(HoverEvent.showText(TextComponent.of("Clicking confirm will restore ENTIRE claim back to default world gen state. Use cautiously!"))).build(); GriefDefenderPlugin.sendMessage(src, schematicConfirmationText); }
Example #30
Source File: PermissionsExProvider.java From GriefDefender with MIT License | 5 votes |
private Component textForError(Throwable t) { // TODO: is this already done somewhere else in GD? TextComponent.Builder build = TextComponent.builder(t.getMessage(), TextColor.RED); TextComponent.Builder stackTrace = TextComponent.builder(); for (StackTraceElement el : t.getStackTrace()) { stackTrace.append(el.toString()).append("\n"); } build.hoverEvent(HoverEvent.showText(stackTrace.build())); return build.build(); }