/** * Creates a TextComponent with formatting and text from the passed * component * * @param textComponent the component to copy from */ public TextComponent(TextComponent textComponent) { super( textComponent ); setText( textComponent.getText() ); }
/** * Creates a TextComponent with blank text and the extras set to the passed * array * * @param extras the extras to set */ public TextComponent(BaseComponent... extras) { setText( "" ); setExtra( new ArrayList<BaseComponent>( Arrays.asList( extras ) ) ); }
@Override public TextComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { TextComponent component = new TextComponent(); JsonObject object = json.getAsJsonObject(); deserialize( object, component, context ); component.setText( object.get( "text" ).getAsString() ); return component; }
old.setText( builder.toString() ); builder = new StringBuilder(); components.add( old ); old.setText( builder.toString() ); builder = new StringBuilder(); components.add( old ); component = new TextComponent( old ); String urlString = message.substring( i, pos ); component.setText( urlString ); component.setClickEvent( new ClickEvent( ClickEvent.Action.OPEN_URL, urlString.startsWith( "http" ) ? urlString : "http://" + urlString ) ); component.setText( builder.toString() ); components.add( component );
/** * Creates a TextComponent with formatting and text from the passed * component * * @param textComponent the component to copy from */ public TextComponent(TextComponent textComponent) { super( textComponent ); setText( textComponent.getText() ); }
/** * Creates a TextComponent with blank text and the extras set to the passed * array * * @param extras the extras to set */ public TextComponent(BaseComponent... extras) { setText( "" ); setExtra( new ArrayList<BaseComponent>( Arrays.asList( extras ) ) ); }
@Override public TextComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { TextComponent component = new TextComponent(); JsonObject object = json.getAsJsonObject(); deserialize( object, component, context ); component.setText( object.get( "text" ).getAsString() ); return component; }
/** * Appends the text to the builder and makes it the current target for * formatting. You can specify the amount of formatting retained. * * @param text the text to append * @param retention the formatting to retain * @return this ComponentBuilder for chaining */ public ComponentBuilder append(String text, FormatRetention retention) { parts.add( current ); current = new TextComponent( current ); current.setText( text ); retain( retention ); return this; }
@Override public void execute(CommandSender sender, String[] strings) { TextComponent textComponent = new TextComponent(); textComponent.setText("All server IDs: " + Joiner.on(", ").join(RedisBungee.getApi().getAllServers())); textComponent.setColor(ChatColor.YELLOW); sender.sendMessage(textComponent); } }
@Override public void execute(CommandSender sender, String[] args) { if (args.length > 0) { String command = Joiner.on(" ").skipNulls().join(args); RedisBungee.getApi().sendProxyCommand(command); TextComponent message = new TextComponent(); message.setColor(ChatColor.GREEN); message.setText("Sent the command /" + command + " to all proxies."); sender.sendMessage(message); } else { sender.sendMessage(NO_COMMAND_SPECIFIED); } } }
TextComponent old = component; component = new TextComponent(old); old.setText(builder.toString()); builder = new StringBuilder(); components.add(old); TextComponent old = component; component = new TextComponent(old); old.setText(builder.toString()); builder = new StringBuilder(); components.add(old); component = new TextComponent(old); String urlString = message.substring(i, pos); component.setText(urlString); component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, urlString.startsWith("http") ? urlString : "http://" + urlString)); component.setText(builder.toString()); components.add(component);
@Override public void run() { if (args.length > 0) { UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true); if (uuid == null) { sender.sendMessage(PLAYER_NOT_FOUND); return; } long secs = RedisBungee.getApi().getLastOnline(uuid); TextComponent message = new TextComponent(); if (secs == 0) { message.setColor(ChatColor.GREEN); message.setText(args[0] + " is currently online."); } else if (secs != -1) { message.setColor(ChatColor.BLUE); message.setText(args[0] + " was last online on " + new SimpleDateFormat().format(secs) + "."); } else { message.setColor(ChatColor.RED); message.setText(args[0] + " has never been online."); } sender.sendMessage(message); } else { sender.sendMessage(NO_PLAYER_SPECIFIED); } } });
@Override public void run() { int count = RedisBungee.getApi().getPlayerCount(); BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW) .append(playerPlural(count) + " currently online.").create(); if (args.length > 0 && args[0].equals("showall")) { Multimap<String, UUID> serverToPlayers = RedisBungee.getApi().getServerToPlayers(); Multimap<String, String> human = HashMultimap.create(); for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) { human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false)); } for (String server : new TreeSet<>(serverToPlayers.keySet())) { TextComponent serverName = new TextComponent(); serverName.setColor(ChatColor.GREEN); serverName.setText("[" + server + "] "); TextComponent serverCount = new TextComponent(); serverCount.setColor(ChatColor.YELLOW); serverCount.setText("(" + serverToPlayers.get(server).size() + "): "); TextComponent serverPlayers = new TextComponent(); serverPlayers.setColor(ChatColor.WHITE); serverPlayers.setText(Joiner.on(", ").join(human.get(server))); sender.sendMessage(serverName, serverCount, serverPlayers); } sender.sendMessage(playersOnline); } else { sender.sendMessage(playersOnline); sender.sendMessage(new ComponentBuilder("To see all players online, use /glist showall.").color(ChatColor.YELLOW).create()); } } });
@Override public void execute(CommandSender sender, String[] args) { TextComponent textComponent = new TextComponent(); textComponent.setText("You are on " + RedisBungee.getApi().getServerId() + "."); textComponent.setColor(ChatColor.YELLOW); sender.sendMessage(textComponent); } }
TextComponent serverName = new TextComponent(); serverName.setColor(ChatColor.RED); serverName.setText("[" + server + "] "); TextComponent serverCount = new TextComponent(); serverCount.setColor(ChatColor.YELLOW); serverCount.setText("(" + human.get(server).size() + "): "); TextComponent serverPlayers = new TextComponent(); serverPlayers.setColor(ChatColor.WHITE); serverPlayers.setText(Joiner.on(", ").join(human.get(server))); sender.sendMessage(serverName, serverCount, serverPlayers);
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) { TextComponent unlockMessage = new TextComponent(""); unlockMessage.setText(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType))); unlockMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, getSubSkillHoverComponent(player, subSkillType))); unlockMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/"+subSkillType.getParentSkill().toString().toLowerCase())); return unlockMessage; } }
@Override public void run() { if (args.length > 0) { UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true); if (uuid == null) { sender.sendMessage(PLAYER_NOT_FOUND); return; } InetAddress ia = RedisBungee.getApi().getPlayerIp(uuid); if (ia != null) { TextComponent message = new TextComponent(); message.setColor(ChatColor.GREEN); message.setText(args[0] + " is connected from " + ia.toString() + "."); sender.sendMessage(message); } else { sender.sendMessage(PLAYER_NOT_FOUND); } } else { sender.sendMessage(NO_PLAYER_SPECIFIED); } } });
@Override public void run() { if (args.length > 0) { UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true); if (uuid == null) { sender.sendMessage(PLAYER_NOT_FOUND); return; } String proxy = RedisBungee.getApi().getProxy(uuid); if (proxy != null) { TextComponent message = new TextComponent(); message.setColor(ChatColor.GREEN); message.setText(args[0] + " is connected to " + proxy + "."); sender.sendMessage(message); } else { sender.sendMessage(PLAYER_NOT_FOUND); } } else { sender.sendMessage(NO_PLAYER_SPECIFIED); } } });
@Override public void run() { if (args.length > 0) { UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0], true); if (uuid == null) { sender.sendMessage(PLAYER_NOT_FOUND); return; } ServerInfo si = RedisBungee.getApi().getServerFor(uuid); if (si != null) { TextComponent message = new TextComponent(); message.setColor(ChatColor.BLUE); message.setText(args[0] + " is on " + si.getName() + "."); sender.sendMessage(message); } else { sender.sendMessage(PLAYER_NOT_FOUND); } } else { sender.sendMessage(NO_PLAYER_SPECIFIED); } } });