Discussion in 'BungeeCord Plugin Development' started by longroad, May 23, 2016.

  1. Hey Guys, I am coding a report plugin for my BungeeCord Server.
    Code (Text):
    ProxiedPlayer p = (ProxiedPlayer) cs;
            ProxiedPlayer t = ProxyServer.getInstance().getPlayer(args[1]);
            ProxiedPlayer all = (ProxiedPlayer) ProxyServer.getInstance().getPlayers().iterator();
            String msg = "";
            for(int i = 1; i < args.length; i++){
                msg = msg + " " + args[i];
            TextComponent raw = new TextComponent(t.getName()).color(ChatColor.RED).append(" wurde von ")
                    .color(ChatColor.DARK_GRAY).append(p.getName()).color(ChatColor.AQUA).append(" mit dem Grund ")
                    .color(ChatColor.DARK_GRAY).append(msg).color(ChatColor.RED).append(" reportet.").color(ChatColor.DARK_GRAY);
    The message means something like "Player(t) was reported by Player(p) with the message: msg".
    But at the first "color" in my code, there is an error "The method color(ChatColor) is undefined for the type TextComponent" with two quick fixes: "Change to 'setColor'", don't workes because it turnes the whole line into red, and "Add cast to methode receiver" which casts the part "new textComponent(t.getName())" to "Object". I don't know where is the mistake and how to fix it... Please help me, thanks:)
  2. Having multiple text components with different colours and adding them together using
    Code (Text):
    seems to be the way.

    Alternatively you can use
    Code (Text):
    and then you could make your message just like you would in bukkit ("Some " + ChatColor.GOLD + " coloured text!")
  3. I usually use the ComponentBuilder, when combining component parts.

    For example:

    Code (Text):
                    target.sendMessage(new ComponentBuilder("[ACCEPT]")
                            .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent("§aClick to accept the request.")}))
                            .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend accept " + p.getName()))
                            .append(" ")
                            .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent("§cClick to deny the request.")}))
                            .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend deny " + p.getName()))