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 ?
#[KubeJSPlugin] Event not fired
76 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
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
You need to post the event
EventHandlers.YOUR_EVENT.post(...)
Also please use an IDE 😭
That looks like Notepad++ 😭
yes 🥲 some image is from the script file inside kubejs
could you help ? i dont know how to register it 😂
that's a first for me to use kubejs plugin :x
Yeah, one moment
You need to register the event group in registerEvents
(I linked an example)
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();
}
}```
I really need a AddRarity.post() ?
@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
problem is EventGroupRegistry don't exist for me :x
Ohhhh wait, I'm sorry, I was getting code from 1.21.1 😭
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
EventHandler.GROUP.register(); is what you do inside the register evetn
public void registerEvents() {
EventHandler.RarityJS.register();
}
Why is it not on the server?
??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.
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!```
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???"
You need to do YOUR_EVENT.post(whatever)
Kube just won't run events if it's not told to run
and what i enter inside post() ?
Is it asking for something?
no :x
There are many ways to post an event
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
What's your event group looking like?
[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!```
Paste version of latest.log from @boreal iron
Paste version of debug.log from @boreal iron
debug.log is the same stuff as latest.log but with more info as far as I know for diffrence
okay then i will only post debug 🙂
this is filling up the log 😭
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
there without the spam
Paste version of debug.log from @boreal iron
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
Okay will try when i return 👍
alrighty
