Bukkit runnable issue

Discussion in 'Plugin Development' started by Praxounet, Jan 15, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    Praxounet

    Hi guys,

    I've seen a video about custom tablists, and I've tried to reproduce the same code as he did. But my code isnt working, and my console if sending my errors :

    yeygcb.PNG


    The video link :

    My code:

    Code:
    private boolean titlechanged;
        @Override
        public void onEnable() {
            getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "\n\n[HUB] plugin by Praxounet has been activated.\n");
            getServer().getPluginManager().registerEvents(new EventsClass(), this);
         
            new BukkitRunnable() {
    
                @Override
                public void run() {
                    PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
                    Object header = new ChatComponentText("yo");
                    Object footer = new ChatComponentText("too");
                    try {
                        Field a = packet.getClass().getDeclaredField("a");
                        a.setAccessible(true);
                        Field b = packet.getClass().getDeclaredField("b");
                        b.setAccessible(true);
                     
                        a.set(packet, header);
                        b.set(packet, footer);
                     
                        if(Bukkit.getOnlinePlayers().size() == 0) return;
                        for (Player player : Bukkit.getOnlinePlayers()) {
                            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
                        }
                     
                     
                    } catch (NoSuchFieldException | IllegalAccessException e) {
                        e.printStackTrace();
                    }
                 
                 
                }
             
    
             
             
            }.runTaskTimer(this, 0, 20);
     
         
         
         
         
         
         
            }
    Any ideas ?
     

    Attached Files:

  2. Offline

    Chr0mosom3

    Yea, the error pointed to the part of the catchphrase, I have 2 ideas. change it to catch ((No SouchFieldException | IllegalAccessException) e) or just double look at the code.

    Another problem might be version specific, what version you using?
     
  3. @Praxounet

    It looks like the video uses very dirty reflection. You are trying to use variables that do not exist in your bukkit/minecraft environment.
    Are you using the same bukkit version as the video?
     
  4. Offline

    Praxounet

    Hmm I'm not sure to be honest. I'll ask people on his discord.
     
Thread Status:
Not open for further replies.

Share This Page