#[KubeJSPlugin] Event not fired

76 messages · Page 1 of 1 (latest)

boreal iron
#

Sorry to ask but it's not really documented how to do that, all images should explain what happen, the register is called but the script event not, does anyone have any idea ?

wanton daggerBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

boreal iron
#

I want to port my mod to kubejs so it's easy to add new rarity and set it instead of doing it through config file

narrow cradle
#

You need to post the event

#

EventHandlers.YOUR_EVENT.post(...)

#

Also please use an IDE 😭

boreal iron
#

I use eclipse that's an IDE 😂

#

thanks will try 🙂

narrow cradle
boreal iron
#

yes 🥲 some image is from the script file inside kubejs

boreal iron
#

that's a first for me to use kubejs plugin :x

narrow cradle
#

Yeah, one moment

#

(I linked an example)

boreal iron
#

I already do that here: ```cpp
@Override
// In plugin
public void registerEvents() {
super.registerEvents();
EventHandlers.register();
}

public interface EventHandlers {
static final Logger LOGGER = LogUtils.getLogger();
EventGroup RarityJS = EventGroup.of("RarityJSEvents");

EventHandler AddRarity = RarityJS.startup("addRarity", () -> AddRarityEventJS.class);
EventHandler SetRarity = RarityJS.server("setRarity", () -> SetRarityEventJS.class);

static void register()
{
    RarityJS.register();
}

}```

narrow cradle
#

Doing super.registerEvents(); is unnessary

#

(the orignal function is blank)

boreal iron
#

I really need a AddRarity.post() ?

narrow cradle
#
@Override
public void registerEvents(@NotNull EventGroupRegistry registry) {
    registry.register(EventHandlers.RarityJS);
}

would be for your case inside the class that has the kube plugin stuff

boreal iron
#

problem is EventGroupRegistry don't exist for me :x

narrow cradle
#

Ohhhh wait, I'm sorry, I was getting code from 1.21.1 😭

boreal iron
#

that's why i call RarityJS.register(); 🙂

#

through i dont think it do something

#

i did check AddRarity.isEmpty() and it return true before and after register

narrow cradle
#

EventHandler.GROUP.register(); is what you do inside the register evetn

#
public void registerEvents() {
  EventHandler.RarityJS.register();
}
boreal iron
#

that's what RarityJS.register(); do hmmm

#

it's called by EventHandlers.register();

narrow cradle
#

Why is it not on the server?

narrow cradle
tender brookBOT
# narrow cradle ??log server

Please send your KubeJS server log. It can be found at /minecraft/logs/kubejs/server.log.
If you are on 1.18 or 1.16 it will be called server.txt.
Please send the file directly, without links or snippets.

boreal iron
#

it's in server now

#
[12:34:29] [INIT] KubeJS 2001.6.5-build.19; MC 2001 forge
[12:34:29] [INIT] Loaded plugins:
[12:34:29] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgePlugin
[12:34:29] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgeClientPlugin
[12:34:29] [INIT] - net.tokyosu.raritymod.plugin.RarityKubeJS
[12:34:29] [INFO] Loaded script server_scripts:set_rarity.js in 0.0 s
[12:34:29] [INFO] Loaded 1/1 KubeJS server scripts in 0.008 s with 0 errors and 0 warnings
[12:34:29] [INFO] Scripts loaded
[12:34:30] [INFO] Server resource reload complete!```
narrow cradle
#

What about debug.log

#

[12:34:29] [INIT] - net.tokyosu.raritymod.plugin.RarityKubeJS
Your plugin is registered

#

It is registering your events

#

not saying "what's this event???"

boreal iron
#

yes but the event is not called 😢

#

it dont print using console or doing what i want

narrow cradle
#

You need to do YOUR_EVENT.post(whatever)

#

Kube just won't run events if it's not told to run

boreal iron
#

and what i enter inside post() ?

narrow cradle
#

Is it asking for something?

boreal iron
#

no :x

boreal iron
#

okay now the AddRarity is called, but SetRarity nope, it's probably because it's server sided, i call it from here: cpp @SubscribeEvent static void onCompleteSetup(FMLDedicatedServerSetupEvent event) { if (EventHandlers.SetRarity.hasListeners()) { EventResult result = EventHandlers.SetRarity.post(new RaritySetter()); if (result.error()) LOGGER.error("SetRarity post failed !"); if (result.pass()) LOGGER.info("SetRarity success !"); } }

#

I also tried FMLLoadCompleteEvent

#

No success

narrow cradle
#

What's your event group looking like?

boreal iron
#

dont mind the try catch, i will remove it later

narrow cradle
#

There's no need for a try/catch...

#

ah alright

#

Logs?

boreal iron
#
[14:26:50] [INIT] KubeJS 2001.6.5-build.19; MC 2001 forge
[14:26:50] [INIT] Loaded plugins:
[14:26:50] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgePlugin
[14:26:50] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgeClientPlugin
[14:26:50] [INIT] - net.tokyosu.raritymod.plugin.RarityKubeJS
[14:26:50] [INFO] Loaded script server_scripts:set_rarity.js in 0.0 s
[14:26:50] [INFO] Loaded 1/1 KubeJS server scripts in 0.007 s with 0 errors and 0 warnings
[14:26:50] [INFO] Scripts loaded
[14:26:52] [INFO] Server resource reload complete!```
tender brookBOT
#

Paste version of latest.log from @boreal iron

boreal iron
tender brookBOT
#

Paste version of debug.log from @boreal iron

narrow cradle
#

debug.log is the same stuff as latest.log but with more info as far as I know for diffrence

boreal iron
#

okay then i will only post debug 🙂

narrow cradle
#

this is filling up the log 😭

boreal iron
#

a yes, that's to know if the script worked, it's from the getRarity item class sorry :x

#

as you can see, addRarity worked, but not setRarity

narrow cradle
#

14512 lines of the same stuff 😭

#

hmmmm

boreal iron
tender brookBOT
#

Paste version of debug.log from @boreal iron

narrow cradle
#
public static void onServerReload(@NotNull AddReloadListenerEvent event) {
    event.addListener((preparationBarrier, resourceManager, profilerFiller, profilerFiller1, executor, gameExecutor) -> CompletableFuture.runAsync(() -> {
        CompletableFuture.runAsync(() -> {
            // Post your event here
        }).thenCompose(preparationBarrier::wait).thenAcceptAsync((__) -> {}, gameExecutor);
    }));
}

Post your event in there. This is called on the server starting and on /reload

boreal iron
#

Okay will try when i return 👍

narrow cradle
#

alrighty

boreal iron
#

since it's only for client, i did switch from server to client, but it work for both thanks 🙂