EssentialsX

EssentialsX

2M Downloads

EssentialsXDiscordLink service dissapears after server fully starts.

Fami6Xx opened this issue ยท 0 comments

commented

Type of bug

Other unexpected behaviour

/ess dump all output

https://essentialsx.net/dump.html?bytebin=rRrJMrySek

Error log (if applicable)

https://paste.gg/p/anonymous/95e9a4c8a79c43158f0805934c0b0523

Bug description

I'm creating a plugin which whitelists only specified players that have specified role.
In onEnable, where i'm using discordService (normal) it functions normally.
All of the plugins load without an error.

Code for getting service classes:

    public static DiscordService getDiscordService() {
        DiscordService service = Bukkit.getServicesManager().load(DiscordService.class);
        if (service == null) {
            getInstance().getLogger().severe("Discord service not found!");
            throw new RuntimeException("Discord service not found!");
        }
        return service;
    }

    public static DiscordLinkService getDiscordLinkService() {
        DiscordLinkService service = Bukkit.getServicesManager().load(DiscordLinkService.class);
        if (service == null) {
            getInstance().getLogger().severe("DiscordLink service not found!");
            throw new RuntimeException("DiscordLink service not found!");
        }
        return service;
    }

Code that is throwing errors:

    public static String getDiscordId(final Player player) {
        final String discordId = getDiscordLinkService().getDiscordId(player.getUniqueId());
        if (discordId == null) {
            return null;
        }

        final InteractionMember member = getDiscordService().getMemberById(discordId).join();
        return member == null ? null : member.getId();
    }

Steps to reproduce

Latest snapshot, use the code.

Expected behaviour

Get the service without it being null.

Actual behaviour

The servicesmanager from bukkit returns null for discordLinkService, don't know if for discordService too.

Additional Information

Code: https://github.com/Fami6Xx/BlockyWhitelist
Server: Paper 1.20.4
Java version: 21