Solved Bukkit & Bungee Plugin Messaging Channel using Bukkit Runnable()

Discussion in 'Spigot Plugin Development' started by HotDoctor, Apr 5, 2019.

Thread Status:
Not open for further replies.
  1. Hi all! Well, it's my first time posting in this forum, since I just got out of my Skript's time and I've decided to learn about Java. You see, I'm trying to make an AFK plugin, and in this, within a certain time, send it to another server, which in this case is the server exclusively for users who are afk. something like the Limp of Hypixel. The point is that I can not continue since I get the following error in Eclipse:

    Code (Text):

    The method sendPluginMessage(Plugin, String, byte[]) in the type PluginMessageRecipient is not applicable for the arguments (new BukkitRunnable(){}, String, byte[])
     
    Any help?
    Here's my code.


    Code (Text):

            }else if(config.getString("mode").equalsIgnoreCase("Lobby")) {
                afkPlayers = new HashMap<UUID,Integer>();
                new BukkitRunnable() {

                    @Override
                    public void run() {
                        for (Player player : Bukkit.getOnlinePlayers()) {
                            if (afkPlayers.containsKey(player.getUniqueId())) {
                                if(!(afkpeople.contains(player))) {
                                    int current = afkPlayers.get(player.getUniqueId());
                                    if(current == timebungee) {
                                        afkpeople.add(player);
                                        Random rand = new Random();
                                        String randomServer = afks.get(rand.nextInt(afks.size()));
                                        ByteArrayDataOutput out = ByteStreams.newDataOutput();
                                        out.writeUTF("ConnectOther");
                                        out.writeUTF(player.getName());
                                        out.writeUTF(randomServer);
                                        player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
                                    }else{
                                        current++;
                                        afkPlayers.remove(player.getUniqueId());
                                        afkPlayers.put(player.getUniqueId(), current);
                                    }
                             
                                }
                         
                            }else {
                                afkPlayers.put(player.getUniqueId(), 0);
                            }
                     
                        }
                 
                    }
               
                }.runTaskTimer(this, 0, 20);
         
            }
        }
     






    Solved:
    I've just created a method
    Code (Text):


        private String teleport(Player player, String server){
            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF("ConnectOther");
            out.writeUTF(player.getName());
            out.writeUTF(server);
            player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
            return server;
        }

    [CODE]
     
    #1 HotDoctor, Apr 5, 2019
    Last edited: Apr 5, 2019
Thread Status:
Not open for further replies.