#Listening to 'foreign' custom event - Not listed as registered listener
1 messages · Page 1 of 1 (latest)
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
can you show the error ?
There is no error logged as far as I am aware, at least not into console. It is just not present
then i dont understand the problem rightr
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
how does the extend plugin looks like ?
#1130491625748058162 message It's just this atm
and the plugin runs correctly ?
it is called, the on enable is logged into the server
and in the schedular calling the event works too ?
yes
other listeners to the event are notified
This one as an example, and I don't do anything different there
Plugin to host HungerGames style battles on a Minecraft Server - JoKrus/dj-battle-plugin
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
you can take a look here: https://www.spigotmc.org/wiki/using-the-event-api/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
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
you could check the Handler List if it gets modified or smth added to it
how would I do that exactly? I tried a breakpoint there but got overwhelmed by the amount of calls
there are methods on HandlerList-Obj tto chheck how many things are registered i guess
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
do you have 2 classes of the same name?
BattleStartedEvent.getHandlerList() should not return different handler maps
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
dependency correct ?
import correct ?
what if you remove the event-owening plugin
No difference sadly
can you create the event at onEnable on the extending plugin ?
this should at least work or throw exception
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!
^^