#Listening to 'foreign' custom event - Not listed as registered listener

1 messages · Page 1 of 1 (latest)

west ember
#


Bukkit.getScheduler().runTask(BattlePlugin.getPlugin(), () -> {
                            var config = TeamConfigWrapper.toTeamConfig(TeamConfigSerializer.loadData());
                            var battleData = getBattleData(name, category);
                            Bukkit.getPluginManager().callEvent(new BattleStartedEvent(config, battleData));
                        });

#

    @Override
    public void onEnable() {
        // Plugin startup logic
        Bukkit.getLogger().info("HookPlugin - started!");
        Bukkit.getPluginManager().registerEvents(this, this);
    }



    @EventHandler
    public void listenTest(BattleStartedEvent ddos) {
        Bukkit.broadcastMessage("Received start");
    }```

The foreign plugin
#

I also had a separate event listener class but same result of not being present on the server as registered listener.

BlockPlaceEvent for example is called fine from this class

silent tendon
#

can you show the error ?

west ember
#

There is no error logged as far as I am aware, at least not into console. It is just not present

silent tendon
#

then i dont understand the problem rightr

west ember
#

The listener from TestPluginHook is not called at all, which is a separate plugin. Only Listeners from the plugin that calls the event are called.

#

This prevents me from being able to create addon plugins for my main plugin that are easily expandable

silent tendon
#

how does the extend plugin looks like ?

west ember
silent tendon
#

and the plugin runs correctly ?

west ember
#

it is called, the on enable is logged into the server

silent tendon
#

and in the schedular calling the event works too ?

west ember
#

yes

#

other listeners to the event are notified

#

So my guess was/is that the reason that the TestPluginHook one is in a separate jar and I need to do something different there

silent tendon
west ember
#

That's exactly what I do

#

But for some reason TestPluginHook Handler is not present as registered listener when calling the event even though registerEvents is called and no error gets logged

silent tendon
#

you could check the Handler List if it gets modified or smth added to it

west ember
#

how would I do that exactly? I tried a breakpoint there but got overwhelmed by the amount of calls

silent tendon
#

there are methods on HandlerList-Obj tto chheck how many things are registered i guess

west ember
#

It gets registered also... but there is also only 1 listener registered

#

so it seems that for some reason my class has 2 existences since BattleStartedEvent.getHandlerList() returns different handlerslors map on each plugin

silent tendon
#

do you have 2 classes of the same name?

#

BattleStartedEvent.getHandlerList() should not return different handler maps

west ember
#

seems like it, trying to compare the class objects of the eventClass of the executor right now

#

both log the exact same class, getHandlerList and getHandlers return the same static HandlerList field

#

I have no clue anymore

#

For some reason the events are still registered separately

silent tendon
#

dependency correct ?

#

import correct ?

#

what if you remove the event-owening plugin

west ember
silent tendon
#

can you create the event at onEnable on the extending plugin ?

#

this should at least work or throw exception

west ember
#

Found the issue

#

It was indeed 2 instances

#

I provided the reproducable thingy the api with <scope>provided</scope> and now it works

#

so there really seemed to exist 2 different classes, maybe ecause they were living in different modules and then the add on plugin matched this instead?

#

Not that deep into java logic

#

Thanks a lot for your help mate!

silent tendon
#

^^