(Important) Welcome message clickable

Discussion in 'BungeeCord Plugin Development' started by erikgamer07, Jan 10, 2018.

  1. Hello! Im trying to make a plugin BungeeCord and I have a problem with the TextComponent and the ComponentBuilder to make a clickable text(welcome message when a player join). I don't want to do JSON texts.

    The plugin returns me this:



    Code (Text):
        public void onServerConnect(PostLoginEvent e) {
            ProxiedPlayer p = (ProxiedPlayer) e.getPlayer();
            // TIENDA
            TextComponent tienda = new TextComponent(ChatAPI.cc(" &3&ltienda.HandiMine.ga"));
            tienda.setClickEvent(new ClickEvent(Action.OPEN_URL, "tienda.HandiMine.ga"));
            tienda.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click para ir a nuestra tienda").create()));
            // PAGINA WEB
            TextComponent pweb = new TextComponent(ChatAPI.cc(" &3&lwww.HandiMine.ga"));
            pweb.setClickEvent(new ClickEvent(Action.OPEN_URL, "www.HandiMine.ga"));
            pweb.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("&eClick para ir a nuestra web&r").create()));
            p.sendMessage(ChatAPI.cc("   &6&lĀ”Bienvenido a&a&l Handi&b&lMine&9&l Network!"));
            p.sendMessage(ChatAPI.cc("&6 "));
            p.sendMessage(ChatAPI.cc("&c&l - &e&lTienda:&r" + tienda));
            p.sendMessage(ChatAPI.cc("&c&l - &e&lPagina web:&r" + pweb));
  2. Once you pass in your tienda and pweb objects in to your ChatAPI.cc (which i am assuming) takes in a string argument, Java automatically casts that object to a string, which is why you are getting a JSON instead of a string.

    A simple fix would be to move those TextComponent objects out of that method call.
    Code (Text):
    p.sendMessage(ChatAPI.cc("&c&l - &e&lTienda:&r") + tienda);
    p.sendMessage(ChatAPI.cc("&c&l - &e&Pagina web:&r") + pweb);
    • Agree Agree x 1
  3. Thanks! It Works depc.

Share This Page