net.kyori.text.Component Java Examples
The following examples show how to use
net.kyori.text.Component.
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: UIHelper.java From GriefDefender with MIT License | 6 votes |
public static Component getFriendlyContextString(Claim claim, Set<Context> contexts) { if (contexts.isEmpty()) { return TextComponent.of("[]", TextColor.WHITE); } TextComponent.Builder builder = TextComponent.builder(); final Iterator<Context> iterator = contexts.iterator(); while (iterator.hasNext()) { final Context context = iterator.next(); builder.append("\n[", TextColor.WHITE) .append(context.getKey(), TextColor.GREEN) .append("=", TextColor.GRAY) .append(context.getValue(), TextColor.WHITE); if (iterator.hasNext()) { builder.append("], "); } else { builder.append("]"); } } return builder.build(); }
Example #3
Source File: CommandClaimFlagDebug.java From GriefDefender with MIT License | 6 votes |
@CommandAlias("cfdebug") @Description("Toggles claim flag debug mode.") @Subcommand("claim debug") 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 GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(player); final Component result = claim.allowEdit(user, true); if (result != null) { GriefDefenderPlugin.sendMessage(player, result); return; } playerData.debugClaimPermissions = !playerData.debugClaimPermissions; if (!playerData.debugClaimPermissions) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().COMMAND_CLAIMFLAGDEBUG_DISABLED); } else { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().COMMAND_CLAIMFLAGDEBUG_ENABLED); } }
Example #4
Source File: SignUtil.java From GriefDefender with MIT License | 6 votes |
private static Consumer<CommandSender> createSaleConfirmationConsumer(CommandSender src, Claim claim, Sign sign, double price) { return confirm -> { claim.getEconomyData().setSalePrice(price); claim.getEconomyData().setForSale(true); claim.getEconomyData().setSaleSignPosition(VecHelper.toVector3i(sign.getLocation())); claim.getData().save(); List<String> lines = new ArrayList<>(4); lines.add(ChatColor.translateAlternateColorCodes('&', "&7[&bGD&7-&1sell&7]")); lines.add(ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacy().serialize(MessageCache.getInstance().ECONOMY_SIGN_SELL_DESCRIPTION))); lines.add(ChatColor.translateAlternateColorCodes('&', "&4$" + String.format("%.2f", price))); lines.add(ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacy().serialize(MessageCache.getInstance().ECONOMY_SIGN_SELL_FOOTER))); for (int i = 0; i < lines.size(); i++) { sign.setLine(i, lines.get(i)); } sign.update(); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_SALE_CONFIRMED, ImmutableMap.of("amount", price)); GriefDefenderPlugin.sendMessage(src, message); }; }
Example #5
Source File: SignUtil.java From GriefDefender with MIT License | 6 votes |
public static void setClaimForSale(Claim claim, Player player, Sign sign, double price) { if (claim.isWilderness()) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().ECONOMY_CLAIM_NOT_FOR_SALE); return; } // if not owner of claim, validate perms if (((GDClaim) claim).allowEdit(player) != null || !player.hasPermission(GDPermissions.COMMAND_CLAIM_INFO_OTHERS)) { TextAdapter.sendComponent(player, MessageCache.getInstance().CLAIM_NOT_YOURS); return; } final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_SALE_CONFIRMATION, ImmutableMap.of( "amount", price)); GriefDefenderPlugin.sendMessage(player, message); final Component saleConfirmationText = TextComponent.builder("") .append("\n[") .append("Confirm", TextColor.GREEN) .append("]\n") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createSaleConfirmationConsumer(player, claim, sign, price)))) .build(); GriefDefenderPlugin.sendMessage(player, saleConfirmationText); }
Example #6
Source File: MapInfoImpl.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@Override public Component getStyledName(MapNameStyle style) { TextComponent.Builder name = TextComponent.builder(getName()); if (style.isColor) name.color(TextColor.GOLD); if (style.isHighlight) name.decoration(TextDecoration.UNDERLINED, true); if (style.showAuthors) { return TranslatableComponent.of( "misc.authorship", TextColor.DARK_PURPLE, name.build(), TextFormatter.list( getAuthors().stream() .map(c -> c.getName(NameStyle.PLAIN).color(TextColor.RED)) .collect(Collectors.toList()), TextColor.DARK_PURPLE)); } return name.build(); }
Example #7
Source File: TextFormatter.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
/** * Appends formatted page number to end of provided text * * @param text Component to apply page to * @param page The current page number * @param pages The total number of pages * @param mainColor The color of the text * @param pageColor The color of the page numbers * @param simple Whether to include 'Page' in wording * @return A message with page information appended. */ public static Component paginate( Component text, int page, int pages, TextColor mainColor, TextColor pageColor, boolean simple) { return TextComponent.builder() .append(text) .append(" ") .append("(", mainColor) .append( TranslatableComponent.of( simple ? "command.simplePageHeader" : "command.pageHeader", TextColor.DARK_AQUA) .args(TextComponent.of(page, pageColor), TextComponent.of(pages, pageColor))) .append(")", mainColor) .build(); }
Example #8
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 #9
Source File: MessageDataConfig.java From GriefDefender with MIT License | 6 votes |
public Component getMessage(String message, Map<String, Object> paramMap) { String rawMessage = this.messageMap.get(message); if (rawMessage == null) { // Should never happen but in case it does, return empty return TextComponent.empty(); } for (Map.Entry<String, Object> entry : paramMap.entrySet()) { final String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Component) { value = LegacyComponentSerializer.legacy().serialize((Component) value, '&'); } rawMessage = rawMessage.replace("{" + key + "}", value.toString()); } return LegacyComponentSerializer.legacy().deserialize(rawMessage, '&'); }
Example #10
Source File: CommandClaimSell.java From GriefDefender with MIT License | 5 votes |
private static Consumer<CommandSource> createSaleConfirmationConsumer(CommandSource src, Claim claim, double price) { return confirm -> { claim.getEconomyData().setSalePrice(price); claim.getEconomyData().setForSale(true); claim.getData().save(); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_SALE_CONFIRMED, ImmutableMap.of("amount", price)); GriefDefenderPlugin.sendMessage(src, message); }; }
Example #11
Source File: MapPoolCommand.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"skip"}, desc = "Skip the next map", usage = "[positions]", perms = Permissions.SETNEXT) public static void skip( Audience viewer, CommandSender sender, MapOrder mapOrder, @Default("1") int positions) throws CommandException { if (positions < 0) { viewer.sendWarning(TranslatableComponent.of("pool.skip.negative")); return; } MapPool pool = getMapPoolManager(sender, mapOrder).getActiveMapPool(); if (!(pool instanceof Rotation)) { viewer.sendWarning(TranslatableComponent.of("pool.noRotation")); return; } ((Rotation) pool).advance(positions); Component message = TextComponent.builder() .append("[", TextColor.WHITE) .append(TranslatableComponent.of("pool.name", TextColor.GOLD)) .append("] [", TextColor.WHITE) .append(pool.getName(), TextColor.AQUA) .append("]", TextColor.WHITE) .append( TranslatableComponent.of( "pool.skip", TextColor.GREEN, TextComponent.of(positions, TextColor.AQUA))) .build(); viewer.sendMessage(message); }
Example #12
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 #13
Source File: ChatCaptureUtil.java From GriefDefender with MIT License | 5 votes |
public Consumer<CommandSource> createChatSettingsConsumer(Player player, GDClaim claim, String command, Component returnComponent) { return settings -> { PaginationList.Builder paginationBuilder = PaginationList.builder() .title(TextComponent.of("RECORD-CHAT").color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(generateChatSettings(player, claim, command, returnComponent)); paginationBuilder.sendTo(player); }; }
Example #14
Source File: DeathMessageBuilder.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public Component getMessage() { Component message = TranslatableComponent.of(key, getArgs()); if (predicted) message = message .append(TextComponent.space()) .append(TranslatableComponent.of("death.predictedSuffix")); return message; }
Example #15
Source File: ChatCaptureUtil.java From GriefDefender with MIT License | 5 votes |
public Consumer<CommandSender> createChatSettingsConsumer(Player player, GDClaim claim, String command, Component returnComponent) { return settings -> { PaginationList.Builder paginationBuilder = PaginationList.builder() .title(TextComponent.of("RECORD-CHAT").color(TextColor.AQUA)).padding(TextComponent.of(" ").decoration(TextDecoration.STRIKETHROUGH, true)).contents(generateChatSettings(player, claim, command, returnComponent)); paginationBuilder.sendTo(player); }; }
Example #16
Source File: GDFlag.java From GriefDefender with MIT License | 5 votes |
private Component createDescription() { final Component description = GriefDefenderPlugin.getInstance().messageData.getMessage("flag-description-" + this.name.toLowerCase()); if (description != null) { return description; } return TextComponent.of("Not defined."); }
Example #17
Source File: CommandClaimName.java From GriefDefender with MIT License | 5 votes |
@CommandAlias("claimname") @Syntax("<name>|clear") @Description("Sets the name of your claim.") @Subcommand("claim name") public void execute(Player player, String name) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); final Component result = claim.allowEdit(player); if (result != null) { GriefDefenderPlugin.sendMessage(player, result); return; } if (!player.hasPermission(GDPermissions.USE_RESERVED_CLAIM_NAMES)) { final GriefDefenderConfig<?> activeConfig = GriefDefenderPlugin.getActiveConfig(player.getWorld().getUID()); for (String str : activeConfig.getConfig().claim.reservedClaimNames) { if (FilenameUtils.wildcardMatch(name, str)) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().CLAIM_RESERVED_NAME); return; } } } final TextComponent text = LegacyComponentSerializer.legacy().deserialize(name, '&'); if (text == TextComponent.empty() || text.content().equals("clear")) { claim.getInternalClaimData().setName(null); } else { claim.getInternalClaimData().setName(text); } claim.getInternalClaimData().setRequiresSave(true); claim.getInternalClaimData().save(); final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.CLAIM_NAME, ImmutableMap.of( "name", text)); GriefDefenderPlugin.sendMessage(player, message); }
Example #18
Source File: CommandClaimAbandonWorld.java From GriefDefender with MIT License | 5 votes |
@CommandCompletion("@gdworlds @gddummy") @CommandAlias("abandonworld") @Description("Special admin command used to abandon ALL user claims in world") @Subcommand("abandon world") @Syntax("[<world>]") public void execute(Player player, @Optional String worldName) { WorldProperties world = player.getWorld().getProperties(); if (worldName != null) { world = Sponge.getServer().getWorldProperties(worldName).orElse(null); if (world == null) { TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_WORLD_NOT_FOUND, ImmutableMap.of("world", worldName))); return; } } final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(player.getWorld().getUniqueId()); if (claimWorldManager.getWorldClaims().size() == 0) { try { throw new CommandException(MessageCache.getInstance().CLAIM_NO_CLAIMS); } catch (CommandException e) { TextAdapter.sendComponent(player, e.getText()); return; } } final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ABANDON_WORLD_WARNING, ImmutableMap.of( "world", TextComponent.of(world.getWorldName()))); 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, world), true))) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().UI_CLICK_CONFIRM)).build()) .build(); TextAdapter.sendComponent(player, confirmationText); }
Example #19
Source File: CommandTrustList.java From GriefDefender with MIT License | 5 votes |
private static Consumer<CommandSender> createRemoveGroupConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand, IClaimData data, List<String> trustList, String group) { return consumer -> { trustList.remove(group); data.setRequiresSave(true); data.save(); showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); }; }
Example #20
Source File: CommandGDVersion.java From GriefDefender with MIT License | 5 votes |
@CommandAlias("gdversion") @Description("Displays GriefDefender's version information.") @Subcommand("version") public void execute(CommandSource src) { final String spongePlatform = Sponge.getPlatform().getContainer(org.spongepowered.api.Platform.Component.IMPLEMENTATION).getName(); Component gpVersion = TextComponent.builder("") .append(GriefDefenderPlugin.GD_TEXT) .append("Running ") .append("GriefDefender " + GriefDefenderPlugin.IMPLEMENTATION_VERSION, TextColor.AQUA) .build(); Component spongeVersion = TextComponent.builder("") .append(GriefDefenderPlugin.GD_TEXT) .append("Running ") .append(spongePlatform + " " + GriefDefenderPlugin.SPONGE_VERSION, TextColor.YELLOW) .build(); String permissionPlugin = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getId(); String permissionVersion = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin().getVersion().orElse("unknown"); Component permVersion = TextComponent.builder("") .append(GriefDefenderPlugin.GD_TEXT) .append("Running ") .append(permissionPlugin + " " + permissionVersion, TextColor.GREEN) .build(); TextAdapter.sendComponent(src, TextComponent.builder("") .append(gpVersion) .append("\n") .append(spongeVersion) .append("\n") .append(permVersion) .build()); }
Example #21
Source File: ChatCaptureUtil.java From GriefDefender with MIT License | 5 votes |
public List<Component> generateChatSettings(Player player, GDClaim claim, String command, Component returnComponent) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); List<Component> textList = new ArrayList<>(); Component returnToClaimInfo = null; if (command.equals("claiminfo")) { returnToClaimInfo = TextComponent.builder() .append("[") .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, ImmutableMap.of("command", command))) .append("]") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(player, command, claim.getUniqueId().toString())))).build(); } else if (command.equals("trustlist")) { returnToClaimInfo = TextComponent.builder() .append("[") .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, ImmutableMap.of("command", command))) .append("]") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(createTrustListConsumer(player, claim, playerData, TrustTypes.NONE, returnComponent)))).build(); } else { returnToClaimInfo = TextComponent.builder() .append("[") .append(MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.UI_CLICK_RETURN_COMMAND, ImmutableMap.of("command", command))) .append("]") .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(CommandHelper.createCommandConsumer(player, command, "")))).build(); } textList.add(returnToClaimInfo); for (Component chatLine : playerData.chatLines) { textList.add(chatLine); } int fillSize = 20 - (textList.size() + 2); for (int i = 0; i < fillSize; i++) { textList.add(TextComponent.of(" ")); } return textList; }
Example #22
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 #23
Source File: CommandTrustList.java From GriefDefender with MIT License | 5 votes |
private static Consumer<CommandSource> createCancelConsumer(Player src, GDClaim claim, GDPlayerData playerData, TrustType type, Component returnCommand) { return consumer -> { playerData.commandInputTimestamp = null; playerData.commandConsumer = null; showTrustList(src, claim, playerData, type, new ArrayList<>(), returnCommand); }; }
Example #24
Source File: BanCategory.java From GriefDefender with MIT License | 5 votes |
public Component getItemBanReason(String id) { if (id == null) { return null; } if (!id.contains(":")) { id = "minecraft:" + id; } return this.items.get(id); }
Example #25
Source File: MatchAnnouncer.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onMatchEnd(final MatchFinishEvent event) { Match match = event.getMatch(); // broadcast match finish message for (MatchPlayer viewer : match.getPlayers()) { Component title, subtitle = TextComponent.empty(); if (event.getWinner() == null) { title = TranslatableComponent.of("broadcast.gameOver"); } else { title = TranslatableComponent.of( event.getWinner().isNamePlural() ? "broadcast.gameOver.teamWinners" : "broadcast.gameOver.teamWinner", event.getWinner().getName()); if (event.getWinner() == viewer.getParty()) { // Winner viewer.playSound(SOUND_MATCH_WIN); if (viewer.getParty() instanceof Team) { subtitle = TranslatableComponent.of("broadcast.gameOver.teamWon", TextColor.GREEN); } } else if (viewer.getParty() instanceof Competitor) { // Loser viewer.playSound(SOUND_MATCH_LOSE); if (viewer.getParty() instanceof Team) { subtitle = TranslatableComponent.of("broadcast.gameOver.teamLost", TextColor.RED); } } else { // Observer viewer.playSound(SOUND_MATCH_WIN); } } viewer.showTitle(title, subtitle, 0, 40, 40); viewer.sendMessage(title); if (subtitle != null) viewer.sendMessage(subtitle); } }
Example #26
Source File: CommandTownTag.java From GriefDefender with MIT License | 5 votes |
@CommandAlias("towntag") @Description("Sets the tag of your town.") @Syntax("<tag>") @Subcommand("town tag") public void execute(Player player, String tag) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); final GDClaim claim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (claim == null || !claim.isInTown()) { GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().TOWN_NOT_IN); return; } final GDClaim town = claim.getTownClaim(); final Component result = town.allowEdit(player); if (result != null) { GriefDefenderPlugin.sendMessage(player, result); return; } TextComponent name = LegacyComponentSerializer.legacy().deserialize(tag, '&'); if (name == TextComponent.empty() || name.content().equals("clear")) { town.getTownData().setTownTag(null); } else { town.getTownData().setTownTag(name); } town.getInternalClaimData().setRequiresSave(true); Component resultMessage = null; if (!claim.getTownData().getTownTag().isPresent()) { resultMessage = MessageCache.getInstance().TOWN_TAG_CLEAR; } else { resultMessage = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.TOWN_TAG, ImmutableMap.of( "tag", name)); } TextAdapter.sendComponent(player, resultMessage); }
Example #27
Source File: MatchAnnouncer.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onMatchBegin(final MatchStartEvent event) { Match match = event.getMatch(); match.sendMessage(TranslatableComponent.of("broadcast.matchStart", TextColor.GREEN)); Component go = TranslatableComponent.of("broadcast.go", TextColor.GREEN); for (MatchPlayer player : match.getParticipants()) { player.showTitle(go, TextComponent.empty(), 0, 5, 15); } match.playSound(SOUND_MATCH_START); }
Example #28
Source File: KickedFromServerEvent.java From Velocity with MIT License | 5 votes |
/** * Creates a {@code KickedFromServerEvent} instance. * @param player the player affected * @param server the server the player disconnected from * @param originalReason the reason for being kicked, optional * @param duringServerConnect whether or not the player was kicked during the connection process * @param fancyReason a fancy reason for being disconnected, used for the initial result */ public KickedFromServerEvent(Player player, RegisteredServer server, @Nullable Component originalReason, boolean duringServerConnect, Component fancyReason) { this.player = Preconditions.checkNotNull(player, "player"); this.server = Preconditions.checkNotNull(server, "server"); this.originalReason = originalReason; this.duringServerConnect = duringServerConnect; this.result = new Notify(fancyReason); }
Example #29
Source File: FreeForAllTabEntry.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@Override public BaseComponent getContent(TabView view) { Component content = TextComponent.builder() .append(String.valueOf(match.getParticipants().size()), TextColor.WHITE) .append("/", TextColor.DARK_GRAY) .append(String.valueOf(match.getMaxPlayers()), TextColor.GRAY) .append(" ") .append( TranslatableComponent.of( "match.info.players", TextColor.YELLOW, TextDecoration.BOLD)) .build(); return TextTranslations.toBaseComponent(content, view.getViewer()); }
Example #30
Source File: CommandHelper.java From GriefDefender with MIT License | 5 votes |
public static Consumer<CommandSource> createReturnClaimListConsumer(CommandSource src, Consumer<CommandSource> returnCommand) { return consumer -> { Component claimListReturnCommand = TextComponent.builder("") .append("\n[") .append(MessageCache.getInstance().CLAIMLIST_UI_RETURN_CLAIMSLIST.color(TextColor.AQUA)) .append("]\n", TextColor.WHITE) .clickEvent(ClickEvent.runCommand(GDCallbackHolder.getInstance().createCallbackRunCommand(returnCommand))).build(); TextAdapter.sendComponent(src, claimListReturnCommand); }; }