BGHDDevelopment / PlayerBalancer

The repository for the plugin PlayerBalancer
https://www.spigotmc.org/resources/55011/
MIT License
28 stars 24 forks source link

How to use reiterative option #21

Closed kit8379 closed 3 years ago

kit8379 commented 3 years ago

I can't make it work. Any example on it? I want players to connect to the last server they are online within a section. When the player connect to that section. It will redirect to it.

kit8379 commented 3 years ago
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onDisconnect(PlayerDisconnectEvent event) {
        ProxiedPlayer player = event.getPlayer();
        PlayerLocker.unlock(player);

        ServerAssignRegistry.clearAsssignedServers(player);
    }

I saw this event. Is it means that all assigned server for reiterative section will be cleared after players disconnect from the server?

jamezrin commented 3 years ago
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onDisconnect(PlayerDisconnectEvent event) {
        ProxiedPlayer player = event.getPlayer();
        PlayerLocker.unlock(player);

        ServerAssignRegistry.clearAsssignedServers(player);
    }

I saw this event. Is it means that all assigned server for reiterative section will be cleared after players disconnect from the server?

Yeah, exactly. The assigned server is only meant to be kept as long as the player is online. It's working as intended, but I see the point of your use case.

I'm not actively developing this plugin anymore, but you can remove this event handler limit somehow the amount of entries in the ServerAssignRegistry map (taking care of memory leaks).