Java Code Examples for net.kyori.text.TextComponent#of()
The following examples show how to use
net.kyori.text.TextComponent#of() .
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: CycleCountdown.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@Override protected Component formatText() { Component mapName = nextMap == null ? null : TextComponent.of(nextMap.getName(), TextColor.AQUA); TranslatableComponent cycleComponent; if (remaining.isZero()) { cycleComponent = mapName != null ? TranslatableComponent.of("map.cycledMap", mapName) : TranslatableComponent.of("map.cycled"); } else { Component secs = secondsRemaining(TextColor.DARK_RED); cycleComponent = mapName != null ? TranslatableComponent.of("map.cycleMap", mapName, secs) : TranslatableComponent.of("map.cycle", secs); } return cycleComponent.color(TextColor.DARK_AQUA); }
Example 2
Source File: PlayerUtil.java From GriefDefender with MIT License | 6 votes |
public Component getClaimTypeComponentFromShovel(ShovelType shovelMode, boolean upper) { if (shovelMode == ShovelTypes.ADMIN) { if (upper) { return TextComponent.of(ClaimTypes.ADMIN.getName().toUpperCase(), TextColor.RED); } return TextComponent.of("Admin", TextColor.RED); } if (shovelMode == ShovelTypes.TOWN) { if (upper) { return TextComponent.of(ClaimTypes.TOWN.getName().toUpperCase(), TextColor.GREEN); } return TextComponent.of("Town", TextColor.GREEN); } if (shovelMode == ShovelTypes.SUBDIVISION) { if (upper) { return TextComponent.of(ClaimTypes.SUBDIVISION.getName().toUpperCase(), TextColor.AQUA); } return TextComponent.of("Subdivision", TextColor.AQUA); } if (upper) { return TextComponent.of(ClaimTypes.BASIC.getName().toUpperCase(), TextColor.YELLOW); } return TextComponent.of("Basic", TextColor.YELLOW); }
Example 3
Source File: GDOption.java From GriefDefender with MIT License | 5 votes |
private Component createDescription() { final Component description = GriefDefenderPlugin.getInstance().messageData.getMessage("option-description-" + this.name.toLowerCase()); if (description != null) { return description; } return TextComponent.of("Not defined."); }
Example 4
Source File: GDClaim.java From GriefDefender with MIT License | 5 votes |
public Component allowEdit(GDPermissionUser holder, boolean forced) { if (this.isUserTrusted(holder, TrustTypes.MANAGER, null, forced)) { return null; } // Owners are not trusted while renting if (!holder.getInternalPlayerData().canIgnoreClaim(this) && this.getEconomyData() != null && this.getEconomyData().isRented() && holder.getUniqueId().equals(this.ownerUniqueId)) { return TextComponent.of(""); } if (PermissionUtil.getInstance().holderHasPermission(holder, GDPermissions.COMMAND_DELETE_CLAIMS)) { return null; } if (this.parent != null && this.getData().doesInheritParent()) { return this.parent.allowEdit(holder); } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(this.getWorldUniqueId(), holder.getUniqueId()); if (playerData.canIgnoreClaim(this)) { return null; } final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_OWNER_ONLY, ImmutableMap.of( "player", this.getOwnerDisplayName())); return message; }
Example 5
Source File: GDClaim.java From GriefDefender with MIT License | 5 votes |
public Component getFriendlyNameType(ClaimType claimType, boolean upper) { if (claimType == ClaimTypes.ADMIN) { if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.RED); } return TextComponent.of("Admin", TextColor.RED); } if (claimType == ClaimTypes.BASIC) { if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.YELLOW); } return TextComponent.of("Basic", TextColor.YELLOW); } if (claimType == ClaimTypes.SUBDIVISION) { if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.AQUA); } return TextComponent.of("Subdivision", TextColor.AQUA); } if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.GREEN); } return TextComponent.of("Town", TextColor.GREEN); }
Example 6
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 7
Source File: Team.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@Override public Component getChatPrefix() { if (chatPrefix == null) { this.chatPrefix = TextComponent.of("(" + getShortName() + ") ", TextFormatter.convert(getColor())); } return chatPrefix; }
Example 8
Source File: CommandHelper.java From GriefDefender with MIT License | 5 votes |
public static Consumer<CommandSender> createFlagConsumer(CommandSender src, GDClaim claim, Subject subject, Set<Context> contexts, Flag flag, Tristate flagValue, MenuType flagType) { return consumer -> { Tristate newValue = Tristate.UNDEFINED; if (flagValue == Tristate.TRUE) { newValue = Tristate.FALSE; } else if (flagValue == Tristate.UNDEFINED) { newValue = Tristate.TRUE; } Component flagTypeText = TextComponent.empty(); if (flagType == MenuType.OVERRIDE) { flagTypeText = TextComponent.of("OVERRIDE", TextColor.RED); } else if (flagType == MenuType.DEFAULT) { flagTypeText = TextComponent.of("DEFAULT", TextColor.LIGHT_PURPLE); } else if (flagType == MenuType.CLAIM) { flagTypeText = TextComponent.of("CLAIM", TextColor.GOLD); } Set<Context> newContexts = new HashSet<>(contexts); PermissionUtil.getInstance().setPermissionValue(GriefDefenderPlugin.DEFAULT_HOLDER, flag, newValue, newContexts); TextAdapter.sendComponent(src, TextComponent.builder("") .append("Set ", TextColor.GREEN) .append(flagTypeText) .append(" permission ") .append(flag.getName().toLowerCase(), TextColor.AQUA) .append("\n to ", TextColor.GREEN) .append(getClickableText(src, (GDClaim) claim, subject, newContexts, flag, newValue, flagType).color(TextColor.LIGHT_PURPLE)) .append(" for ", TextColor.GREEN) .append(subject.getFriendlyName(), TextColor.GOLD).build()); }; }
Example 9
Source File: ClaimOptionBase.java From GriefDefender with MIT License | 5 votes |
private void appendContexts(TextComponent.Builder builder, Set<Context> contexts) { // check source/target Component source = null; Component target = null; final Component whiteOpenBracket = TextComponent.of("[", TextColor.WHITE); final Component whiteCloseBracket = TextComponent.of("]", TextColor.WHITE); for (Context context : contexts) { if (context.getKey().equals(ContextKeys.SOURCE)) { source = TextComponent.builder() .append(whiteOpenBracket) .append("s", TextColor.GREEN) .append("=", TextColor.WHITE) .append(context.getValue().replace("minecraft:", ""), TextColor.GOLD) .append(whiteCloseBracket) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().LABEL_SOURCE)) .build(); builder.append(" ").append(source); } else if (context.getKey().equals(ContextKeys.TARGET)) { target = TextComponent.builder() .append(whiteOpenBracket) .append("t", TextColor.GREEN) .append("=", TextColor.WHITE) .append(context.getValue().replace("minecraft:", ""), TextColor.GOLD) .append(whiteCloseBracket) .hoverEvent(HoverEvent.showText(MessageCache.getInstance().LABEL_TARGET)) .build(); builder.append(" ").append(target); } } }
Example 10
Source File: GDClaim.java From GriefDefender with MIT License | 5 votes |
@Override public Component getOwnerDisplayName() { if (this.isAdminClaim() || this.isWilderness()) { return MessageCache.getInstance().OWNER_ADMIN; } if (this.getOwnerPlayerData() == null) { return TextComponent.of("[unknown]"); } return TextComponent.of(this.getOwnerPlayerData().getName()); }
Example 11
Source File: GDClaim.java From GriefDefender with MIT License | 5 votes |
public Component allowEdit(GDPermissionUser holder, boolean forced) { if (this.isUserTrusted(holder, TrustTypes.MANAGER, null, forced)) { return null; } // Owners are not trusted while renting if (!holder.getInternalPlayerData().canIgnoreClaim(this) && this.getEconomyData() != null && this.getEconomyData().isRented() && holder.getUniqueId().equals(this.ownerUniqueId)) { return TextComponent.of(""); } if (PermissionUtil.getInstance().holderHasPermission(holder, GDPermissions.COMMAND_DELETE_CLAIMS)) { return null; } if (this.parent != null && this.getData().doesInheritParent()) { return this.parent.allowEdit(holder); } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(this.getWorldUniqueId(), holder.getUniqueId()); if (playerData.canIgnoreClaim(this)) { return null; } final Component message = MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.CLAIM_OWNER_ONLY, ImmutableMap.of( "player", this.getOwnerDisplayName())); return message; }
Example 12
Source File: GDClaim.java From GriefDefender with MIT License | 5 votes |
public Component getFriendlyNameType(ClaimType claimType, boolean upper) { if (claimType == ClaimTypes.ADMIN) { if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.RED); } return TextComponent.of("Admin", TextColor.RED); } if (claimType == ClaimTypes.BASIC) { if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.YELLOW); } return TextComponent.of("Basic", TextColor.YELLOW); } if (claimType == ClaimTypes.SUBDIVISION) { if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.AQUA); } return TextComponent.of("Subdivision", TextColor.AQUA); } if (upper) { return TextComponent.of(claimType.getName().toUpperCase(), TextColor.GREEN); } return TextComponent.of("Town", TextColor.GREEN); }
Example 13
Source File: Team.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@Override public Component getName(NameStyle style) { if (componentName == null) { this.componentName = TextComponent.of(getNameLegacy(), TextFormatter.convert(getColor())); } return componentName; }
Example 14
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 15
Source File: TimeLimit.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@Override public Component getDescription(Match match) { Component time = TextComponent.of(TimeUtils.formatDuration(duration)); if (result == null) { return TranslatableComponent.of("match.timeLimit.generic", time); } else { return TranslatableComponent.of("match.timeLimit.result", result.getDescription(match), time); } }
Example 16
Source File: Flag.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public Component getComponentName() { return TextComponent.of(getName(), getChatColor()); }
Example 17
Source File: ModerationCommand.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Command( aliases = {"ipban", "banip", "ipb"}, usage = "<player|ip address> <reason> -s (silent)", desc = "IP Ban a player from the server", flags = "s", perms = Permissions.BAN) public void ipBan( Audience viewer, CommandSender sender, MatchManager manager, String target, @Text String reason, @Switch('s') boolean silent) throws CommandException { silent = checkSilent(silent, sender); Player targetPlayer = Bukkit.getPlayerExact(target); String address = target; // Default address to what was input if (targetPlayer != null) { // If target is a player, fetch their IP and use that address = targetPlayer.getAddress().getAddress().getHostAddress(); } else if (getBanWithMatchingName(target).isPresent()) { address = getBanWithMatchingName(target).get().getAddress(); } // Validate if the IP is a valid IP if (InetAddresses.isInetAddress(address)) { // Special method for IP Ban Bukkit.getBanList(BanList.Type.IP) .addBan( address, reason, null, TextTranslations.translateLegacy( UsernameFormatUtils.formatStaffName(sender, manager.getMatch(sender)), sender)); int onlineBans = 0; // Check all online players to find those with same IP. for (Player player : Bukkit.getOnlinePlayers()) { MatchPlayer matchPlayer = manager.getPlayer(player); if (player.getAddress().getAddress().getHostAddress().equals(address)) { // Kick players with same IP if (punish(PunishmentType.BAN, matchPlayer, sender, reason, silent)) { // Ban username to prevent rejoining banPlayer( player.getName(), reason, UsernameFormatUtils.formatStaffName(sender, matchPlayer.getMatch()), null); player.kickPlayer( formatPunishmentScreen( PunishmentType.BAN, UsernameFormatUtils.formatStaffName(sender, manager.getMatch(sender)), reason, null)); onlineBans++; } } } Component formattedTarget = TextComponent.of(target, TextColor.DARK_AQUA); if (onlineBans > 0) { viewer.sendWarning( TranslatableComponent.of( "moderation.ipBan.bannedWithAlts", formattedTarget, TextComponent.of( Integer.toString( targetPlayer == null ? onlineBans : Math.max(0, onlineBans - 1)), TextColor.AQUA))); } else { viewer.sendMessage( TranslatableComponent.of("moderation.ipBan.banned", TextColor.RED, formattedTarget)); } } else { viewer.sendMessage( TranslatableComponent.of( "moderation.ipBan.invalidIP", TextColor.GRAY, TextComponent.of(address, TextColor.RED, TextDecoration.ITALIC))); } }
Example 18
Source File: TextException.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public static TextException outOfRange(String text, Range<?> range) { return new TextException(null, null, "error.outOfRange", TextComponent.of(text), format(range)); }
Example 19
Source File: TextException.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
private static Component format(Range<?> range) { return TextComponent.of(range.toString().replace("∞", "oo").replace("‥", ", ")); }
Example 20
Source File: MonumentWoolFactory.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public static Component makeComponentName(DyeColor color) { return TextComponent.of( makeName(color), TextFormatter.convert((BukkitUtils.dyeColorToChatColor(color)))); }