From a547aba72d2ce30d6089cc11ed6e994857b768d2 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 1 Jul 2024 15:27:24 +0100 Subject: [PATCH 1/4] chore: updated for KubeJS 2100.7.0 Note: Stages support has not been re-added. Support in KJS is still WIP. --- common/build.gradle | 2 - .../kubejs/FTBChunksKubeJSEvents.java | 12 -- .../kubejs/CustomFilterEventJS.java | 22 ---- .../ftbfiltersystem/kubejs/FFSEvents.java | 11 -- .../kubejs/FFSKubeJSPlugin.java | 23 ---- .../kubejs/FTBQuestsKubeJSEvents.java | 16 --- .../ftbquests/kubejs/KubeJSIntegration.java | 92 --------------- .../gamestages/KubeJSStageProvider.java | 33 ------ .../generic/gamestages/StagesSetup.java | 15 ++- .../src/main/resources/kubejs.classfilter.txt | 3 - common/src/main/resources/kubejs.plugins.txt | 4 - .../gamestages/fabric/StagesSetupImpl.java | 7 ++ gradle.properties | 6 +- neoforge/build.gradle | 5 +- .../neoforge/KubeJSStageProvider.java | 33 ++++++ .../gamestages/neoforge/StagesSetupImpl.java | 11 ++ .../mods/ftbxmodcompat/kubejs/KJSUtil.java | 24 ++++ .../ftbchunks/kubejs/AfterEventJS.java | 18 +-- .../ftbchunks/kubejs/BeforeEventJS.java | 12 +- .../kubejs/FTBChunksKubeJSEvents.java | 15 +++ .../kubejs/FTBChunksKubeJSPlugin.java | 27 +++-- .../kubejs/CustomFilterKubeEvent.java | 16 +++ .../ftbfiltersystem/kubejs/FFSEvents.java | 12 ++ .../kubejs/FFSKubeJSPlugin.java | 25 +++++ .../kubejs/CustomFilterItemKubeEvent.java | 8 +- .../kubejs/CustomRewardKubeEvent.java | 8 +- .../ftbquests/kubejs/CustomTaskKubeEvent.java | 8 +- .../kubejs/FTBQuestsKubeJSEvents.java | 21 ++++ .../kubejs/FTBQuestsKubeJSPlayerData.java | 2 +- .../kubejs/FTBQuestsKubeJSPlugin.java | 105 ++++++++++++++++++ .../kubejs/FTBQuestsKubeJSTeamData.java | 6 +- .../FTBQuestsKubeJSTeamDataWrapper.java | 2 +- .../kubejs/FTBQuestsKubeJSWrapper.java | 2 +- .../kubejs/QuestObjectCompletedKubeEvent.java | 17 +-- .../kubejs/QuestObjectStartedKubeEvent.java | 16 +-- .../ftbteams/kubejs/FTBTeamsKubeJSEvents.java | 6 +- .../ftbteams/kubejs/FTBTeamsKubeJSPlugin.java | 15 +-- .../ftbteams/kubejs/KJSTeamWrapper.java | 2 +- .../ftbteams/kubejs/PlayerTeamKubeEvent.java | 8 +- .../resources/META-INF/neoforge.mods.toml | 4 +- .../src/main/resources/kubejs.classfilter.txt | 4 + .../src/main/resources/kubejs.plugins.txt | 4 + 42 files changed, 373 insertions(+), 309 deletions(-) delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSEvents.java delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java delete mode 100644 common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/KubeJSStageProvider.java delete mode 100644 common/src/main/resources/kubejs.classfilter.txt delete mode 100644 common/src/main/resources/kubejs.plugins.txt create mode 100644 fabric/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/fabric/StagesSetupImpl.java create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/KubeJSStageProvider.java create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/kubejs/KJSUtil.java rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbchunks/kubejs/AfterEventJS.java (56%) rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbchunks/kubejs/BeforeEventJS.java (64%) create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSEvents.java rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java (58%) create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/CustomFilterKubeEvent.java create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSEvents.java create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java rename common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomFilterItemKubeEvent.java (62%) rename common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomRewardEventJS.java => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomRewardKubeEvent.java (64%) rename common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomTaskEventJS.java => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomTaskKubeEvent.java (71%) create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSEvents.java rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java (89%) create mode 100644 neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlugin.java rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java (92%) rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java (86%) rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java (96%) rename common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectCompletedEventJS.java => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectCompletedKubeEvent.java (69%) rename common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectStartedEventJS.java => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectStartedKubeEvent.java (69%) rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbteams/kubejs/FTBTeamsKubeJSEvents.java (68%) rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java (58%) rename {common/src/main/java/dev/ftb/mods/ftbxmodcompat => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge}/ftbteams/kubejs/KJSTeamWrapper.java (87%) rename common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/PlayerTeamEventJS.java => neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/PlayerTeamKubeEvent.java (70%) create mode 100644 neoforge/src/main/resources/kubejs.classfilter.txt create mode 100644 neoforge/src/main/resources/kubejs.plugins.txt diff --git a/common/build.gradle b/common/build.gradle index eff0154..17cd88c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -25,8 +25,6 @@ dependencies { modCompileOnly("mezz.jei:jei-${rootProject.minecraft_version}-common-api:${rootProject.jei_version}") compileOnly("net.luckperms:api:${rootProject.luckperms_api_version}") - - modCompileOnlyApi "dev.latvian.mods:kubejs-neoforge:${rootProject.kubejs_version}" } publishing { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSEvents.java deleted file mode 100644 index c79cf8f..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSEvents.java +++ /dev/null @@ -1,12 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs; - -import dev.latvian.mods.kubejs.event.EventGroup; -import dev.latvian.mods.kubejs.event.EventHandler; -import dev.latvian.mods.kubejs.event.Extra; - -public interface FTBChunksKubeJSEvents { - EventGroup EVENT_GROUP = EventGroup.of("FTBChunksEvents"); - - EventHandler BEFORE = EVENT_GROUP.server("before", () -> BeforeEventJS.class).extra(Extra.REQUIRES_STRING).hasResult(); - EventHandler AFTER = EVENT_GROUP.server("after", () -> AfterEventJS.class).extra(Extra.REQUIRES_STRING); -} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java deleted file mode 100644 index 9207253..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/CustomFilterEventJS.java +++ /dev/null @@ -1,22 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; - -import dev.latvian.mods.kubejs.event.EventJS; -import net.minecraft.world.item.ItemStack; - -public class CustomFilterEventJS extends EventJS { - private final ItemStack stack; - private final String data; - - public CustomFilterEventJS(ItemStack stack, String data) { - this.stack = stack; - this.data = data; - } - - public ItemStack getStack() { - return stack; - } - - public String getData() { - return data; - } -} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java deleted file mode 100644 index 89fcf65..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSEvents.java +++ /dev/null @@ -1,11 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; - -import dev.latvian.mods.kubejs.event.EventGroup; -import dev.latvian.mods.kubejs.event.EventHandler; -import dev.latvian.mods.kubejs.event.Extra; - -public interface FFSEvents { - EventGroup EVENT_GROUP = EventGroup.of("FTBFilterSystemEvents"); - - EventHandler CUSTOM_FILTER = EVENT_GROUP.server("customFilter", () -> CustomFilterEventJS.class).extra(Extra.STRING).hasResult(); -} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java deleted file mode 100644 index d7a11f7..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java +++ /dev/null @@ -1,23 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs; - -import dev.architectury.event.EventResult; -import dev.ftb.mods.ftbfiltersystem.api.event.CustomFilterEvent; -import dev.latvian.mods.kubejs.KubeJSPlugin; -import dev.latvian.mods.kubejs.script.ScriptType; -import net.minecraft.world.item.ItemStack; - -public class FFSKubeJSPlugin extends KubeJSPlugin { - @Override - public void init() { - CustomFilterEvent.MATCH_ITEM.register(FFSKubeJSPlugin::onCustomFilter); - } - - @Override - public void registerEvents() { - FFSEvents.EVENT_GROUP.register(); - } - - private static EventResult onCustomFilter(ItemStack stack, String eventId, String extraData) { - return FFSEvents.CUSTOM_FILTER.post(ScriptType.SERVER, eventId, new CustomFilterEventJS(stack, extraData)).arch(); - } -} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java deleted file mode 100644 index 1057176..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSEvents.java +++ /dev/null @@ -1,16 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; - -import dev.latvian.mods.kubejs.event.EventGroup; -import dev.latvian.mods.kubejs.event.EventHandler; -import dev.latvian.mods.kubejs.event.Extra; - -public interface FTBQuestsKubeJSEvents { - EventGroup EVENT_GROUP = EventGroup.of("FTBQuestsEvents"); - - EventHandler CUSTOM_TASK = EVENT_GROUP.server("customTask", () -> CustomTaskEventJS.class).extra(Extra.STRING).hasResult(); - EventHandler CUSTOM_REWARD = EVENT_GROUP.server("customReward", () -> CustomRewardEventJS.class).extra(Extra.STRING).hasResult(); - EventHandler OBJECT_COMPLETED = EVENT_GROUP.server("completed", () -> QuestObjectCompletedEventJS.class).extra(Extra.STRING); - EventHandler OBJECT_STARTED = EVENT_GROUP.server("started", () -> QuestObjectStartedEventJS.class).extra(Extra.STRING); - - EventHandler CUSTOM_FILTER_ITEM = EVENT_GROUP.client("customFilterItem", () -> CustomFilterItemEventJS.class); -} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java deleted file mode 100644 index 1d0c267..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/KubeJSIntegration.java +++ /dev/null @@ -1,92 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; - -import dev.architectury.event.EventResult; -import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; -import dev.ftb.mods.ftbquests.events.CustomRewardEvent; -import dev.ftb.mods.ftbquests.events.CustomTaskEvent; -import dev.ftb.mods.ftbquests.events.ObjectCompletedEvent; -import dev.ftb.mods.ftbquests.events.ObjectStartedEvent; -import dev.ftb.mods.ftbquests.quest.task.StageTask; -import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; -import dev.latvian.mods.kubejs.KubeJSPlugin; -import dev.latvian.mods.kubejs.script.BindingsEvent; -import dev.latvian.mods.kubejs.script.ScriptType; -import dev.latvian.mods.kubejs.stages.Stages; -import dev.latvian.mods.kubejs.util.AttachedData; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; - -public class KubeJSIntegration extends KubeJSPlugin { - @Override - public void init() { - CustomTaskEvent.EVENT.register(KubeJSIntegration::onCustomTask); - CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward); - ObjectCompletedEvent.GENERIC.register(KubeJSIntegration::onCompleted); - ObjectStartedEvent.GENERIC.register(KubeJSIntegration::onStarted); - CustomFilterDisplayItemsEvent.ADD_ITEMSTACK.register(KubeJSIntegration::onCustomFilterItem); - - Stages.added(event -> { - if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); - }); - Stages.removed(event -> { - if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); - }); - - FTBXModCompat.LOGGER.info("[FTB Quests] Enabled KubeJS integration"); - } - - @Override - public void registerBindings(BindingsEvent event) { - event.add("FTBQuests", FTBQuestsKubeJSWrapper.INSTANCE); - } - - @Override - public void attachPlayerData(AttachedData event) { - event.add("ftbquests", new FTBQuestsKubeJSPlayerData(event.getParent())); - } - - @Override - public void registerEvents() { - FTBQuestsKubeJSEvents.EVENT_GROUP.register(); - } - - private static void onCustomFilterItem(CustomFilterDisplayItemsEvent event) { - FTBQuestsKubeJSEvents.CUSTOM_FILTER_ITEM.post(ScriptType.CLIENT, new CustomFilterItemEventJS(event)); - } - - public static EventResult onCustomTask(CustomTaskEvent event) { - return FTBQuestsKubeJSEvents.CUSTOM_TASK.post(ScriptType.SERVER, event.getTask(), new CustomTaskEventJS(event)).arch(); - } - - public static EventResult onCustomReward(CustomRewardEvent event) { - return FTBQuestsKubeJSEvents.CUSTOM_REWARD.post(ScriptType.SERVER, event.getReward(), new CustomRewardEventJS(event)).arch(); - } - - public static EventResult onCompleted(ObjectCompletedEvent event) { - if (event.getData().getFile().isServerSide()) { - var kjsEvent = new QuestObjectCompletedEventJS(event); - var object = event.getObject(); - - FTBQuestsKubeJSEvents.OBJECT_COMPLETED.post(ScriptType.SERVER, event.getObject(), kjsEvent); - for (String tag : object.getTags()) { - FTBQuestsKubeJSEvents.OBJECT_COMPLETED.post(ScriptType.SERVER, '#' + tag, kjsEvent); - } - } - - return EventResult.pass(); - } - - public static EventResult onStarted(ObjectStartedEvent event) { - if (event.getData().getFile().isServerSide()) { - var kjsEvent = new QuestObjectStartedEventJS(event); - var object = event.getObject(); - - FTBQuestsKubeJSEvents.OBJECT_STARTED.post(ScriptType.SERVER, event.getObject(), kjsEvent); - for (String tag : object.getTags()) { - FTBQuestsKubeJSEvents.OBJECT_STARTED.post(ScriptType.SERVER, '#' + tag, kjsEvent); - } - } - - return EventResult.pass(); - } -} \ No newline at end of file diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/KubeJSStageProvider.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/KubeJSStageProvider.java deleted file mode 100644 index a029b33..0000000 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/KubeJSStageProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -package dev.ftb.mods.ftbxmodcompat.generic.gamestages; - -import dev.ftb.mods.ftblibrary.integration.stages.StageProvider; -import dev.latvian.mods.kubejs.stages.Stages; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; - -public class KubeJSStageProvider implements StageProvider { - @Override - public boolean has(Player player, String stage) { - return Stages.get(player).has(stage); - } - - @Override - public void add(ServerPlayer player, String stage) { - Stages.get(player).add(stage); - } - - @Override - public void remove(ServerPlayer player, String stage) { - Stages.get(player).remove(stage); - } - - @Override - public void sync(ServerPlayer player) { - Stages.get(player).sync(); - } - - @Override - public String getName() { - return "KubeJS Stages"; - } -} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/StagesSetup.java b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/StagesSetup.java index b8b5863..7b3b9b4 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/StagesSetup.java +++ b/common/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/StagesSetup.java @@ -1,5 +1,6 @@ package dev.ftb.mods.ftbxmodcompat.generic.gamestages; +import dev.architectury.injectables.annotations.ExpectPlatform; import dev.ftb.mods.ftblibrary.integration.stages.StageHelper; import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; import dev.ftb.mods.ftbxmodcompat.config.FTBXModConfig; @@ -14,18 +15,24 @@ public static void init() { } switch (sel) { - case KUBEJS -> StageHelper.getInstance().setProviderImpl(new KubeJSStageProvider()); + case KUBEJS -> addKubeJSProvider(); case GAMESTAGES -> StageHelper.getInstance().setProviderImpl(new GameStagesStageProvider()); case VANILLA -> { /* do nothing, this is the fallback */ } case DEFAULT -> { - if (FTBXModCompat.isKubeJSLoaded) { - StageHelper.getInstance().setProviderImpl(new KubeJSStageProvider()); + // TODO: nothing for now, neither KJS nor Gamestages have a working stages implementation yet on 1.21 + /* if (FTBXModCompat.isKubeJSLoaded) { + addKubeJSProvider(); } else if (FTBXModCompat.isGameStagesLoaded) { StageHelper.getInstance().setProviderImpl(new GameStagesStageProvider()); - } + }*/ } } FTBXModCompat.LOGGER.info("Chose [{}] as the active game stages implementation", StageHelper.getInstance().getProvider().getName()); } + + @ExpectPlatform + public static void addKubeJSProvider() { + throw new AssertionError(); + } } diff --git a/common/src/main/resources/kubejs.classfilter.txt b/common/src/main/resources/kubejs.classfilter.txt deleted file mode 100644 index b146614..0000000 --- a/common/src/main/resources/kubejs.classfilter.txt +++ /dev/null @@ -1,3 +0,0 @@ -+dev.ftb.mods.ftbquests -+dev.ftb.mods.ftbchunks -+dev.ftb.mods.ftbteams \ No newline at end of file diff --git a/common/src/main/resources/kubejs.plugins.txt b/common/src/main/resources/kubejs.plugins.txt deleted file mode 100644 index b5f5441..0000000 --- a/common/src/main/resources/kubejs.plugins.txt +++ /dev/null @@ -1,4 +0,0 @@ -dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs.KubeJSIntegration ftbquests -dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs.FTBChunksKubeJSPlugin ftbchunks -dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams -dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs.FFSKubeJSPlugin ftbfiltersystem \ No newline at end of file diff --git a/fabric/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/fabric/StagesSetupImpl.java b/fabric/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/fabric/StagesSetupImpl.java new file mode 100644 index 0000000..c8ee3e3 --- /dev/null +++ b/fabric/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/fabric/StagesSetupImpl.java @@ -0,0 +1,7 @@ +package dev.ftb.mods.ftbxmodcompat.generic.gamestages.fabric; + +public class StagesSetupImpl { + public static void addKubeJSProvider() { + throw new IllegalStateException("KubeJS stages only supported on Neoforge!"); + } +} diff --git a/gradle.properties b/gradle.properties index 76e8ca7..a566931 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,12 +11,12 @@ maven_group=dev.ftb.mods curseforge_id=889915 forge_version=50.0.9 -neoforge_version=21.0.14-beta +neoforge_version=21.0.43-beta neoforge_loader_version=4 fabric_loader_version=0.15.11 fabric_api_version=0.100.1+1.21 -architectury_version=13.0.1 +architectury_version=13.0.2 ftb_library_version=2100.1.1 ftb_quests_version=2100.1.1 @@ -36,7 +36,7 @@ balm_neoforge_version=5438018 balm_forge_version=5438000 balm_fabric_version=5437997 jei_version=19.0.0.11 +kubejs_version=2100.7.0-build.56 # TODO compiling against 1.20.4 version for now -kubejs_version=2004.7.0-build.16 gamestages_version=15.0.1 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index d500d83..0182011 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -38,14 +38,15 @@ dependencies { modApi("dev.ftb.mods:ftb-ranks-neoforge:${rootProject.ftb_ranks_version}") modApi("dev.ftb.mods:ftb-essentials-neoforge:${rootProject.ftb_essentials_version}") modApi("dev.ftb.mods:ftb-teams-neoforge:${rootProject.ftb_teams_version}") + modApi("dev.ftb.mods:ftb-filter-system-neoforge:${rootProject.ftb_filter_system_version}") modCompileOnlyApi("me.shedaniel:RoughlyEnoughItems-neoforge:${rootProject.rei_version}") compileOnly("net.luckperms:api:${rootProject.luckperms_api_version}") + modApi("dev.latvian.mods:kubejs-neoforge:${rootProject.kubejs_version}") + // TODO below here is compile-only for now modCompileOnlyApi("net.darkhax.gamestages:GameStages-Forge-1.20.1:${rootProject.gamestages_version}") { transitive false } - - modCompileOnly("dev.latvian.mods:kubejs-neoforge:${rootProject.kubejs_version}") modCompileOnly("curse.maven:balm-531761:${balm_neoforge_version}") modCompileOnly("curse.maven:waystones-245755:${waystones_neoforge_version}") diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/KubeJSStageProvider.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/KubeJSStageProvider.java new file mode 100644 index 0000000..310403b --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/KubeJSStageProvider.java @@ -0,0 +1,33 @@ +package dev.ftb.mods.ftbxmodcompat.generic.gamestages.neoforge; + +import dev.ftb.mods.ftblibrary.integration.stages.StageProvider; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; + +public class KubeJSStageProvider implements StageProvider { + @Override + public boolean has(Player player, String stage) { + return false; +// return Stages.get(player).has(stage); + } + + @Override + public void add(ServerPlayer player, String stage) { +// Stages.get(player).add(stage); + } + + @Override + public void remove(ServerPlayer player, String stage) { +// Stages.get(player).remove(stage); + } + + @Override + public void sync(ServerPlayer player) { +// Stages.get(player).sync(); + } + + @Override + public String getName() { + return "KubeJS Stages (non-functional!)"; + } +} diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java new file mode 100644 index 0000000..9d6021e --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java @@ -0,0 +1,11 @@ +package dev.ftb.mods.ftbxmodcompat.generic.gamestages.neoforge; + +import dev.ftb.mods.ftblibrary.integration.stages.StageHelper; +import org.jline.utils.Log; + +public class StagesSetupImpl { + public static void addKubeJSProvider() { + Log.warn("KubeJS gamestages are not functional on 1.21 yet!"); + StageHelper.getInstance().setProviderImpl(new KubeJSStageProvider()); + } +} diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/kubejs/KJSUtil.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/kubejs/KJSUtil.java new file mode 100644 index 0000000..b875183 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/kubejs/KJSUtil.java @@ -0,0 +1,24 @@ +package dev.ftb.mods.ftbxmodcompat.kubejs; + +import dev.architectury.event.CompoundEventResult; +import dev.latvian.mods.kubejs.event.EventResult; + +public class KJSUtil { + public static CompoundEventResult asCompoundArchResult(EventResult result, T object) { + return switch (result.type()) { + case INTERRUPT_DEFAULT -> CompoundEventResult.interruptDefault(object); + case INTERRUPT_FALSE -> CompoundEventResult.interruptFalse(object); + case INTERRUPT_TRUE -> CompoundEventResult.interruptTrue(object); + default -> CompoundEventResult.pass(); + }; + } + + public static dev.architectury.event.EventResult asArchResult(EventResult result) { + return switch (result.type()) { + case INTERRUPT_DEFAULT -> dev.architectury.event.EventResult.interruptDefault(); + case INTERRUPT_FALSE -> dev.architectury.event.EventResult.interruptFalse(); + case INTERRUPT_TRUE -> dev.architectury.event.EventResult.interruptTrue(); + default -> dev.architectury.event.EventResult.pass(); + }; + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/AfterEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/AfterEventJS.java similarity index 56% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/AfterEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/AfterEventJS.java index a091112..881c02e 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/AfterEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/AfterEventJS.java @@ -1,15 +1,13 @@ -package dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbchunks.kubejs; import dev.ftb.mods.ftbchunks.api.ClaimedChunk; -import dev.latvian.mods.kubejs.entity.EntityEventJS; +import dev.latvian.mods.kubejs.entity.KubeEntityEvent; import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; -public class AfterEventJS extends EntityEventJS { +public class AfterEventJS implements KubeEntityEvent { public final CommandSourceStack source; public final ClaimedChunk chunk; @@ -18,22 +16,12 @@ public AfterEventJS(CommandSourceStack s, ClaimedChunk c) { chunk = c; } - @Override - public Level getLevel() { - return source.getLevel(); - } - @Override @Nullable public Entity getEntity() { return source.getEntity(); } - @Nullable - public ServerPlayer getPlayer() { - return source.getEntity() instanceof ServerPlayer sp ? sp : null; - } - public BlockPos getClaimPos() { return chunk.getPos().chunkPos().getWorldPosition(); } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/BeforeEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/BeforeEventJS.java similarity index 64% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/BeforeEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/BeforeEventJS.java index 0792671..e9a8f9b 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/BeforeEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/BeforeEventJS.java @@ -1,9 +1,11 @@ -package dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbchunks.kubejs; import dev.ftb.mods.ftbchunks.api.ClaimResult; import dev.ftb.mods.ftbchunks.api.ClaimedChunk; +import dev.latvian.mods.kubejs.entity.KubeEntityEvent; import dev.latvian.mods.kubejs.event.EventExit; import net.minecraft.commands.CommandSourceStack; +import net.minecraft.world.entity.Entity; public class BeforeEventJS extends AfterEventJS { private ClaimResult result; @@ -17,13 +19,13 @@ public ClaimResult getResult() { return result; } - public void setResult(ClaimResult r) throws EventExit { + public void setResult(ClaimResult r) { result = r; - cancel(result); +// cancel(result); } - public void setCustomResult(String messageKey) throws EventExit { + public void setCustomResult(String messageKey) { result = ClaimResult.customProblem(messageKey); - cancel(result); +// cancel(result); } } diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSEvents.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSEvents.java new file mode 100644 index 0000000..6625e71 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSEvents.java @@ -0,0 +1,15 @@ +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbchunks.kubejs; + +import dev.latvian.mods.kubejs.event.EventGroup; +import dev.latvian.mods.kubejs.event.EventHandler; +import dev.latvian.mods.kubejs.event.EventTargetType; +import dev.latvian.mods.kubejs.event.TargetedEventHandler; + +public interface FTBChunksKubeJSEvents { + EventGroup EVENT_GROUP = EventGroup.of("FTBChunksEvents"); + + TargetedEventHandler BEFORE = EVENT_GROUP.server("before", () -> BeforeEventJS.class) + .requiredTarget(EventTargetType.STRING).hasResult(); + TargetedEventHandler AFTER = EVENT_GROUP.server("after", () -> AfterEventJS.class) + .requiredTarget(EventTargetType.STRING); +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java similarity index 58% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java index e010544..4380982 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbchunks/kubejs/FTBChunksKubeJSPlugin.java @@ -1,16 +1,19 @@ -package dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbchunks.kubejs; import dev.architectury.event.CompoundEventResult; import dev.ftb.mods.ftbchunks.api.ClaimResult; import dev.ftb.mods.ftbchunks.api.ClaimedChunk; import dev.ftb.mods.ftbchunks.api.event.ClaimedChunkEvent; import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; -import dev.latvian.mods.kubejs.KubeJSPlugin; +import dev.ftb.mods.ftbxmodcompat.kubejs.KJSUtil; +import dev.latvian.mods.kubejs.event.EventGroupRegistry; +import dev.latvian.mods.kubejs.event.EventResult; +import dev.latvian.mods.kubejs.plugin.KubeJSPlugin; import dev.latvian.mods.kubejs.script.ScriptType; -import dev.latvian.mods.rhino.util.wrap.TypeWrappers; +import dev.latvian.mods.kubejs.script.TypeWrapperRegistry; import net.minecraft.commands.CommandSourceStack; -public class FTBChunksKubeJSPlugin extends KubeJSPlugin { +public class FTBChunksKubeJSPlugin implements KubeJSPlugin { @Override public void init() { ClaimedChunkEvent.BEFORE_CLAIM.register((source, chunk) -> before(source, chunk, "claim")); @@ -26,20 +29,22 @@ public void init() { } @Override - public void registerEvents() { - FTBChunksKubeJSEvents.EVENT_GROUP.register(); + public void registerEvents(EventGroupRegistry registry) { + registry.register(FTBChunksKubeJSEvents.EVENT_GROUP); } @Override - public void registerTypeWrappers(ScriptType type, TypeWrappers typeWrappers) { - typeWrappers.register(ClaimResult.class, (ctx, o) -> ClaimResult.StandardProblem.valueOf(o.toString().toUpperCase())); - } + public void registerTypeWrappers(TypeWrapperRegistry registry) { + registry.register(ClaimResult.class, (cx, from, target) -> ClaimResult.StandardProblem.valueOf(from.toString().toUpperCase())); + } private CompoundEventResult before(CommandSourceStack source, ClaimedChunk chunk, String id) { - return FTBChunksKubeJSEvents.BEFORE.post(ScriptType.SERVER, new BeforeEventJS(source, chunk)).archCompound(); + BeforeEventJS event = new BeforeEventJS(source, chunk); + EventResult result = FTBChunksKubeJSEvents.BEFORE.post(ScriptType.SERVER, id, event); + return KJSUtil.asCompoundArchResult(result, event.getResult()); } private void after(CommandSourceStack source, ClaimedChunk chunk, String id) { - FTBChunksKubeJSEvents.AFTER.post(ScriptType.SERVER, id, new AfterEventJS(source, chunk)); + FTBChunksKubeJSEvents.AFTER.post(ScriptType.SERVER, id, new AfterEventJS(source, chunk)); } } diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/CustomFilterKubeEvent.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/CustomFilterKubeEvent.java new file mode 100644 index 0000000..3ead498 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/CustomFilterKubeEvent.java @@ -0,0 +1,16 @@ +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbfiltersystem.kubejs; + +import dev.latvian.mods.kubejs.event.KubeEvent; +import net.minecraft.world.item.ItemStack; + +public record CustomFilterKubeEvent(ItemStack stack, String data) implements KubeEvent { + // getter methods are for backward compat with 1.20 + + public ItemStack getStack() { + return stack; + } + + public String getData() { + return data; + } +} diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSEvents.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSEvents.java new file mode 100644 index 0000000..a0ab755 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSEvents.java @@ -0,0 +1,12 @@ +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbfiltersystem.kubejs; + +import dev.latvian.mods.kubejs.event.EventGroup; +import dev.latvian.mods.kubejs.event.EventTargetType; +import dev.latvian.mods.kubejs.event.TargetedEventHandler; + +public interface FFSEvents { + EventGroup EVENT_GROUP = EventGroup.of("FTBFilterSystemEvents"); + + TargetedEventHandler CUSTOM_FILTER = EVENT_GROUP.server("customFilter", () -> CustomFilterKubeEvent.class) + .supportsTarget(EventTargetType.STRING).hasResult(); +} diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java new file mode 100644 index 0000000..7b122e4 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbfiltersystem/kubejs/FFSKubeJSPlugin.java @@ -0,0 +1,25 @@ +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbfiltersystem.kubejs; + +import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbfiltersystem.api.event.CustomFilterEvent; +import dev.ftb.mods.ftbxmodcompat.kubejs.KJSUtil; +import dev.latvian.mods.kubejs.event.EventGroupRegistry; +import dev.latvian.mods.kubejs.plugin.KubeJSPlugin; +import dev.latvian.mods.kubejs.script.ScriptType; +import net.minecraft.world.item.ItemStack; + +public class FFSKubeJSPlugin implements KubeJSPlugin { + @Override + public void init() { + CustomFilterEvent.MATCH_ITEM.register(FFSKubeJSPlugin::onCustomFilter); + } + + @Override + public void registerEvents(EventGroupRegistry registry) { + registry.register(FFSEvents.EVENT_GROUP); + } + + private static EventResult onCustomFilter(ItemStack stack, String eventId, String extraData) { + return KJSUtil.asArchResult(FFSEvents.CUSTOM_FILTER.post(ScriptType.SERVER, eventId, new CustomFilterKubeEvent(stack, extraData))); + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomFilterItemKubeEvent.java similarity index 62% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomFilterItemKubeEvent.java index 4e1f892..9b81480 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomFilterItemEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomFilterItemKubeEvent.java @@ -1,15 +1,15 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; -import dev.latvian.mods.kubejs.event.EventJS; +import dev.latvian.mods.kubejs.event.KubeEvent; import net.minecraft.world.item.ItemStack; import java.util.Collection; -public class CustomFilterItemEventJS extends EventJS { +public class CustomFilterItemKubeEvent implements KubeEvent { private final CustomFilterDisplayItemsEvent event; - public CustomFilterItemEventJS(CustomFilterDisplayItemsEvent event) { + public CustomFilterItemKubeEvent(CustomFilterDisplayItemsEvent event) { this.event = event; } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomRewardEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomRewardKubeEvent.java similarity index 64% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomRewardEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomRewardKubeEvent.java index 127999f..5d22730 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomRewardEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomRewardKubeEvent.java @@ -1,14 +1,14 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.events.CustomRewardEvent; import dev.ftb.mods.ftbquests.quest.reward.CustomReward; -import dev.latvian.mods.kubejs.player.PlayerEventJS; +import dev.latvian.mods.kubejs.player.KubePlayerEvent; import net.minecraft.world.entity.player.Player; -public class CustomRewardEventJS extends PlayerEventJS { +public class CustomRewardKubeEvent implements KubePlayerEvent { public final transient CustomRewardEvent event; - public CustomRewardEventJS(CustomRewardEvent e) { + public CustomRewardKubeEvent(CustomRewardEvent e) { event = e; } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomTaskEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomTaskKubeEvent.java similarity index 71% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomTaskEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomTaskKubeEvent.java index 74f8183..4c6993e 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomTaskEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/CustomTaskKubeEvent.java @@ -1,13 +1,13 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.events.CustomTaskEvent; import dev.ftb.mods.ftbquests.quest.task.CustomTask; -import dev.latvian.mods.kubejs.event.EventJS; +import dev.latvian.mods.kubejs.event.KubeEvent; -public class CustomTaskEventJS extends EventJS { +public class CustomTaskKubeEvent implements KubeEvent { public final CustomTaskEvent event; - CustomTaskEventJS(CustomTaskEvent e) { + CustomTaskKubeEvent(CustomTaskEvent e) { event = e; } diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSEvents.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSEvents.java new file mode 100644 index 0000000..0fa5fd0 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSEvents.java @@ -0,0 +1,21 @@ +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; + +import dev.latvian.mods.kubejs.event.EventGroup; +import dev.latvian.mods.kubejs.event.EventHandler; +import dev.latvian.mods.kubejs.event.EventTargetType; +import dev.latvian.mods.kubejs.event.TargetedEventHandler; + +public interface FTBQuestsKubeJSEvents { + EventGroup EVENT_GROUP = EventGroup.of("FTBQuestsEvents"); + + TargetedEventHandler CUSTOM_TASK = EVENT_GROUP.server("customTask", () -> CustomTaskKubeEvent.class) + .requiredTarget(EventTargetType.STRING).hasResult(); + TargetedEventHandler CUSTOM_REWARD = EVENT_GROUP.server("customReward", () -> CustomRewardKubeEvent.class) + .requiredTarget(EventTargetType.STRING).hasResult(); + TargetedEventHandler OBJECT_COMPLETED = EVENT_GROUP.server("completed", () -> QuestObjectCompletedKubeEvent.class) + .requiredTarget(EventTargetType.STRING); + TargetedEventHandler OBJECT_STARTED = EVENT_GROUP.server("started", () -> QuestObjectStartedKubeEvent.class) + .requiredTarget(EventTargetType.STRING); + + EventHandler CUSTOM_FILTER_ITEM = EVENT_GROUP.client("customFilterItem", () -> CustomFilterItemKubeEvent.class); +} diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java similarity index 89% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java index ef607f7..6841eea 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlayerData.java @@ -1,4 +1,4 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.quest.BaseQuestFile; import dev.ftb.mods.ftbquests.quest.ServerQuestFile; diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlugin.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlugin.java new file mode 100644 index 0000000..b04fa13 --- /dev/null +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSPlugin.java @@ -0,0 +1,105 @@ +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; + +import dev.architectury.event.EventResult; +import dev.ftb.mods.ftbquests.api.event.CustomFilterDisplayItemsEvent; +import dev.ftb.mods.ftbquests.events.CustomRewardEvent; +import dev.ftb.mods.ftbquests.events.CustomTaskEvent; +import dev.ftb.mods.ftbquests.events.ObjectCompletedEvent; +import dev.ftb.mods.ftbquests.events.ObjectStartedEvent; +import dev.ftb.mods.ftbquests.quest.QuestObjectBase; +import dev.ftb.mods.ftbquests.quest.ServerQuestFile; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; +import dev.ftb.mods.ftbxmodcompat.kubejs.KJSUtil; +import dev.latvian.mods.kubejs.event.EventGroupRegistry; +import dev.latvian.mods.kubejs.plugin.KubeJSPlugin; +import dev.latvian.mods.kubejs.script.BindingRegistry; +import dev.latvian.mods.kubejs.script.ScriptType; +import dev.latvian.mods.kubejs.util.AttachedData; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.entity.player.Player; + +public class FTBQuestsKubeJSPlugin implements KubeJSPlugin { + @Override + public void init() { + CustomTaskEvent.EVENT.register(FTBQuestsKubeJSPlugin::onCustomTask); + CustomRewardEvent.EVENT.register(FTBQuestsKubeJSPlugin::onCustomReward); + ObjectCompletedEvent.GENERIC.register(FTBQuestsKubeJSPlugin::onCompleted); + ObjectStartedEvent.GENERIC.register(FTBQuestsKubeJSPlugin::onStarted); + CustomFilterDisplayItemsEvent.ADD_ITEMSTACK.register(FTBQuestsKubeJSPlugin::onCustomFilterItem); + +// Stages.added(event -> { +// if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); +// }); +// Stages.removed(event -> { +// if (event.getPlayer() instanceof ServerPlayer sp) StageTask.checkStages(sp); +// }); + + FTBXModCompat.LOGGER.info("[FTB Quests] Enabled KubeJS integration"); + } + + @Override + public void registerBindings(BindingRegistry bindings) { + bindings.add("FTBQuests", FTBQuestsKubeJSWrapper.INSTANCE); + } + + @Override + public void attachPlayerData(AttachedData event) { + event.add("ftbquests", new FTBQuestsKubeJSPlayerData(event.getParent())); + } + + @Override + public void registerEvents(EventGroupRegistry registry) { + registry.register(FTBQuestsKubeJSEvents.EVENT_GROUP); + } + + private static void onCustomFilterItem(CustomFilterDisplayItemsEvent event) { + FTBQuestsKubeJSEvents.CUSTOM_FILTER_ITEM.post(ScriptType.CLIENT, new CustomFilterItemKubeEvent(event)); + } + + public static EventResult onCustomTask(CustomTaskEvent event) { + return KJSUtil.asArchResult( + FTBQuestsKubeJSEvents.CUSTOM_TASK.post(ScriptType.SERVER, event.getTask().toString(), new CustomTaskKubeEvent(event)) + ); + } + + public static EventResult onCustomReward(CustomRewardEvent event) { + return KJSUtil.asArchResult( + FTBQuestsKubeJSEvents.CUSTOM_REWARD.post(ScriptType.SERVER, event.getReward().toString(), new CustomRewardKubeEvent(event)) + ); + } + + public static EventResult onCompleted(ObjectCompletedEvent event) { + if (event.getData().getFile().isServerSide()) { + var kjsEvent = new QuestObjectCompletedKubeEvent(event); + var object = event.getObject(); + + FTBQuestsKubeJSEvents.OBJECT_COMPLETED.post(ScriptType.SERVER, event.getObject().toString(), kjsEvent); + for (String tag : object.getTags()) { + FTBQuestsKubeJSEvents.OBJECT_COMPLETED.post(ScriptType.SERVER, '#' + tag, kjsEvent); + } + } + + return EventResult.pass(); + } + + public static EventResult onStarted(ObjectStartedEvent event) { + if (event.getData().getFile().isServerSide()) { + var kjsEvent = new QuestObjectStartedKubeEvent(event); + var object = event.getObject(); + + FTBQuestsKubeJSEvents.OBJECT_STARTED.post(ScriptType.SERVER, event.getObject().toString(), kjsEvent); + for (String tag : object.getTags()) { + FTBQuestsKubeJSEvents.OBJECT_STARTED.post(ScriptType.SERVER, '#' + tag, kjsEvent); + } + } + + return EventResult.pass(); + } + + static MinecraftServer getServer(QuestObjectBase qo) { + if (qo.getQuestFile() instanceof ServerQuestFile sqf) { + return sqf.server; + } + throw new IllegalStateException("only use this on the server!"); + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java similarity index 92% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java index 92aa849..699baa7 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSTeamData.java @@ -1,10 +1,9 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.quest.*; import dev.ftb.mods.ftbquests.quest.task.Task; import dev.ftb.mods.ftbquests.util.ProgressChange; import dev.latvian.mods.kubejs.player.EntityArrayList; -import dev.latvian.mods.kubejs.util.UtilsJS; import net.minecraft.Util; import java.util.function.Consumer; @@ -88,6 +87,7 @@ public void setLocked(boolean v) { } public EntityArrayList getOnlineMembers() { - return new EntityArrayList(UtilsJS.staticServer.overworld(), getData().getOnlineMembers()); + var server = FTBQuestsKubeJSPlugin.getServer(getFile()); + return new EntityArrayList(server.overworld(), getData().getOnlineMembers()); } } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java similarity index 86% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java index 2b7a30b..b599eb2 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSTeamDataWrapper.java @@ -1,4 +1,4 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.quest.BaseQuestFile; import dev.ftb.mods.ftbquests.quest.TeamData; diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java similarity index 96% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java index 72a4e05..b26523b 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/FTBQuestsKubeJSWrapper.java @@ -1,4 +1,4 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.api.FTBQuestsAPI; import dev.ftb.mods.ftbquests.quest.*; diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectCompletedEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectCompletedKubeEvent.java similarity index 69% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectCompletedEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectCompletedKubeEvent.java index 70a72ca..2166b95 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectCompletedEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectCompletedKubeEvent.java @@ -1,22 +1,22 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.events.ObjectCompletedEvent; import dev.ftb.mods.ftbquests.quest.QuestObject; import dev.ftb.mods.ftbquests.quest.ServerQuestFile; import dev.latvian.mods.kubejs.player.EntityArrayList; -import dev.latvian.mods.kubejs.server.ServerEventJS; -import dev.latvian.mods.kubejs.util.UtilsJS; +import dev.latvian.mods.kubejs.server.ServerKubeEvent; import net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.Nullable; -public class QuestObjectCompletedEventJS extends ServerEventJS { +public class QuestObjectCompletedKubeEvent extends ServerKubeEvent { public final ObjectCompletedEvent event; private final FTBQuestsKubeJSTeamDataWrapper wrapper; - public QuestObjectCompletedEventJS(ObjectCompletedEvent e) { - super(UtilsJS.staticServer); - event = e; - wrapper = new FTBQuestsKubeJSTeamDataWrapper(event.getData()); + public QuestObjectCompletedKubeEvent(ObjectCompletedEvent event) { + super(FTBQuestsKubeJSPlugin.getServer(event.getObject())); + + this.event = event; + wrapper = new FTBQuestsKubeJSTeamDataWrapper(this.event.getData()); } public FTBQuestsKubeJSTeamDataWrapper getData() { @@ -39,4 +39,5 @@ public EntityArrayList getOnlineMembers() { public ServerPlayer getPlayer() { return event.getData().getFile() instanceof ServerQuestFile file ? file.getCurrentPlayer() : null; } + } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectStartedEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectStartedKubeEvent.java similarity index 69% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectStartedEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectStartedKubeEvent.java index febdb28..a84f2f7 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/QuestObjectStartedEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbquests/kubejs/QuestObjectStartedKubeEvent.java @@ -1,22 +1,22 @@ -package dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs; import dev.ftb.mods.ftbquests.events.ObjectStartedEvent; import dev.ftb.mods.ftbquests.quest.QuestObject; import dev.ftb.mods.ftbquests.quest.ServerQuestFile; import dev.latvian.mods.kubejs.player.EntityArrayList; -import dev.latvian.mods.kubejs.server.ServerEventJS; -import dev.latvian.mods.kubejs.util.UtilsJS; +import dev.latvian.mods.kubejs.server.ServerKubeEvent; import net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.Nullable; -public class QuestObjectStartedEventJS extends ServerEventJS { +public class QuestObjectStartedKubeEvent extends ServerKubeEvent { public final ObjectStartedEvent event; private final FTBQuestsKubeJSTeamDataWrapper wrapper; - public QuestObjectStartedEventJS(ObjectStartedEvent e) { - super(UtilsJS.staticServer); - event = e; - wrapper = new FTBQuestsKubeJSTeamDataWrapper(event.getData()); + public QuestObjectStartedKubeEvent(ObjectStartedEvent event) { + super(FTBQuestsKubeJSPlugin.getServer(event.getObject())); + + this.event = event; + wrapper = new FTBQuestsKubeJSTeamDataWrapper(this.event.getData()); } public FTBQuestsKubeJSTeamDataWrapper getData() { diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/FTBTeamsKubeJSEvents.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/FTBTeamsKubeJSEvents.java similarity index 68% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/FTBTeamsKubeJSEvents.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/FTBTeamsKubeJSEvents.java index 658862c..8829301 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/FTBTeamsKubeJSEvents.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/FTBTeamsKubeJSEvents.java @@ -1,4 +1,4 @@ -package dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbteams.kubejs; import dev.latvian.mods.kubejs.event.EventGroup; import dev.latvian.mods.kubejs.event.EventHandler; @@ -6,6 +6,6 @@ public interface FTBTeamsKubeJSEvents { EventGroup EVENT_GROUP = EventGroup.of("FTBTeamsEvents"); - EventHandler PLAYER_JOINED_PARTY = EVENT_GROUP.server("playerJoinedParty", () -> PlayerTeamEventJS.class); - EventHandler PLAYER_LEFT_PARTY = EVENT_GROUP.server("playerLeftParty", () -> PlayerTeamEventJS.class); + EventHandler PLAYER_JOINED_PARTY = EVENT_GROUP.server("playerJoinedParty", () -> PlayerTeamKubeEvent.class); + EventHandler PLAYER_LEFT_PARTY = EVENT_GROUP.server("playerLeftParty", () -> PlayerTeamKubeEvent.class); } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java similarity index 58% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java index 0009f28..6d778df 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/FTBTeamsKubeJSPlugin.java @@ -1,12 +1,13 @@ -package dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbteams.kubejs; import dev.ftb.mods.ftbteams.api.event.PlayerJoinedPartyTeamEvent; import dev.ftb.mods.ftbteams.api.event.PlayerLeftPartyTeamEvent; import dev.ftb.mods.ftbteams.api.event.TeamEvent; -import dev.latvian.mods.kubejs.KubeJSPlugin; +import dev.latvian.mods.kubejs.event.EventGroupRegistry; +import dev.latvian.mods.kubejs.plugin.KubeJSPlugin; import dev.latvian.mods.kubejs.script.ScriptType; -public class FTBTeamsKubeJSPlugin extends KubeJSPlugin { +public class FTBTeamsKubeJSPlugin implements KubeJSPlugin { @Override public void init() { TeamEvent.PLAYER_JOINED_PARTY.register(FTBTeamsKubeJSPlugin::onPlayerJoinedParty); @@ -14,15 +15,15 @@ public void init() { } @Override - public void registerEvents() { - FTBTeamsKubeJSEvents.EVENT_GROUP.register(); + public void registerEvents(EventGroupRegistry registry) { + registry.register(FTBTeamsKubeJSEvents.EVENT_GROUP); } private static void onPlayerJoinedParty(PlayerJoinedPartyTeamEvent event) { - FTBTeamsKubeJSEvents.PLAYER_JOINED_PARTY.post(ScriptType.SERVER, new PlayerTeamEventJS(event.getPlayer(), event.getTeam(), event.getPreviousTeam())); + FTBTeamsKubeJSEvents.PLAYER_JOINED_PARTY.post(ScriptType.SERVER, new PlayerTeamKubeEvent(event.getPlayer(), event.getTeam(), event.getPreviousTeam())); } private static void onPlayerLeftParty(PlayerLeftPartyTeamEvent event) { - FTBTeamsKubeJSEvents.PLAYER_LEFT_PARTY.post(ScriptType.SERVER, new PlayerTeamEventJS(event.getPlayer(), event.getPlayerTeam(), event.getTeam())); + FTBTeamsKubeJSEvents.PLAYER_LEFT_PARTY.post(ScriptType.SERVER, new PlayerTeamKubeEvent(event.getPlayer(), event.getPlayerTeam(), event.getTeam())); } } diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/KJSTeamWrapper.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/KJSTeamWrapper.java similarity index 87% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/KJSTeamWrapper.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/KJSTeamWrapper.java index a7d78d0..ba3157e 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/KJSTeamWrapper.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/KJSTeamWrapper.java @@ -1,4 +1,4 @@ -package dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbteams.kubejs; import dev.ftb.mods.ftbteams.api.Team; diff --git a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/PlayerTeamEventJS.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/PlayerTeamKubeEvent.java similarity index 70% rename from common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/PlayerTeamEventJS.java rename to neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/PlayerTeamKubeEvent.java index a01034b..aeef69f 100644 --- a/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbteams/kubejs/PlayerTeamEventJS.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/neoforge/ftbteams/kubejs/PlayerTeamKubeEvent.java @@ -1,16 +1,16 @@ -package dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs; +package dev.ftb.mods.ftbxmodcompat.neoforge.ftbteams.kubejs; import dev.ftb.mods.ftbteams.api.Team; -import dev.latvian.mods.kubejs.player.PlayerEventJS; +import dev.latvian.mods.kubejs.player.KubePlayerEvent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; -public class PlayerTeamEventJS extends PlayerEventJS { +public class PlayerTeamKubeEvent implements KubePlayerEvent { private final ServerPlayer player; private final Team currentTeam; private final Team prevTeam; - public PlayerTeamEventJS(ServerPlayer player, Team currentTeam, Team prevTeam) { + public PlayerTeamKubeEvent(ServerPlayer player, Team currentTeam, Team prevTeam) { this.player = player; this.currentTeam = currentTeam; this.prevTeam = prevTeam; diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index b0791e4..0d35b29 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -65,14 +65,14 @@ side = "BOTH" [[dependencies.ftbxmodcompat]] modId = "jei" type = "optional" -versionRange = "[16,)" +versionRange = "[19,)" ordering = "AFTER" side = "BOTH" [[dependencies.ftbxmodcompat]] modId = "kubejs" type = "optional" -versionRange = "[2001.6.3,)" +versionRange = "[2100.7.0,)" ordering = "AFTER" side = "BOTH" diff --git a/neoforge/src/main/resources/kubejs.classfilter.txt b/neoforge/src/main/resources/kubejs.classfilter.txt new file mode 100644 index 0000000..97f7952 --- /dev/null +++ b/neoforge/src/main/resources/kubejs.classfilter.txt @@ -0,0 +1,4 @@ ++dev.ftb.mods.ftbquests ++dev.ftb.mods.ftbchunks ++dev.ftb.mods.ftbteams ++dev.ftb.mods.ftbfiltersystem \ No newline at end of file diff --git a/neoforge/src/main/resources/kubejs.plugins.txt b/neoforge/src/main/resources/kubejs.plugins.txt new file mode 100644 index 0000000..d1c4b95 --- /dev/null +++ b/neoforge/src/main/resources/kubejs.plugins.txt @@ -0,0 +1,4 @@ +dev.ftb.mods.ftbxmodcompat.neoforge.ftbquests.kubejs.FTBQuestsKubeJSPlugin ftbquests +dev.ftb.mods.ftbxmodcompat.neoforge.ftbchunks.kubejs.FTBChunksKubeJSPlugin ftbchunks +dev.ftb.mods.ftbxmodcompat.neoforge.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams +dev.ftb.mods.ftbxmodcompat.neoforge.ftbfiltersystem.kubejs.FFSKubeJSPlugin ftbfiltersystem \ No newline at end of file From 33252a24fcb7896d5507ba59a0ff8ea2846eaf21 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 1 Jul 2024 15:29:16 +0100 Subject: [PATCH 2/4] build: version -> 3.2.1, changelog updated --- CHANGELOG.md | 5 +++++ gradle.properties | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf71673..d9995dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.1] + +### Changed +* Updated to support KubeJS 2100.7.0 on Neoforge + ## [3.2.0] ### Changed diff --git a/gradle.properties b/gradle.properties index a566931..cd46552 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ enabled_platforms=fabric,neoforge archives_base_name=ftb-xmod-compat readable_name=FTB XMod Compat -mod_version=3.2.0 +mod_version=3.2.1 maven_group=dev.ftb.mods curseforge_id=889915 @@ -18,7 +18,7 @@ fabric_api_version=0.100.1+1.21 architectury_version=13.0.2 -ftb_library_version=2100.1.1 +ftb_library_version=2100.1.2 ftb_quests_version=2100.1.1 ftb_chunks_version=2100.1.0 ftb_ranks_version=2100.1.0 From 814019f77615ba3d1e3d13bb4919e5c76ffd5beb Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 1 Jul 2024 15:57:30 +0100 Subject: [PATCH 3/4] fix: release type checking for curseforge --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 63837fd..c696a2c 100644 --- a/build.gradle +++ b/build.gradle @@ -123,7 +123,7 @@ publishMods { // TODO: Migrate to something else def tag = providers.environmentVariable("TAG").getOrElse("release") - type = tag == "beta" ? BETA : (tag == "alpha" ? ALPHA : STABLE) + type = tag.endsWith("-beta") ? BETA : (tag.endsWith("-alpha") ? ALPHA : STABLE) def createOptions = (String projectName) -> { publishOptions { From e56cd7b5abe35f886973ade31023db1c9173a64e Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 2 Jul 2024 08:21:47 +0100 Subject: [PATCH 4/4] fix: use the right logger! --- .../generic/gamestages/neoforge/StagesSetupImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java index 9d6021e..27fa60f 100644 --- a/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java +++ b/neoforge/src/main/java/dev/ftb/mods/ftbxmodcompat/generic/gamestages/neoforge/StagesSetupImpl.java @@ -1,11 +1,11 @@ package dev.ftb.mods.ftbxmodcompat.generic.gamestages.neoforge; import dev.ftb.mods.ftblibrary.integration.stages.StageHelper; -import org.jline.utils.Log; +import dev.ftb.mods.ftbxmodcompat.FTBXModCompat; public class StagesSetupImpl { public static void addKubeJSProvider() { - Log.warn("KubeJS gamestages are not functional on 1.21 yet!"); + FTBXModCompat.LOGGER.warn("KubeJS gamestages are not functional on 1.21 yet!"); StageHelper.getInstance().setProviderImpl(new KubeJSStageProvider()); } }