Skip to content

[Feature] Events listening#135

Open
Jaffe2718 wants to merge 3 commits intoTeamMidnightDust:feat/comment-formattingfrom
Jaffe2718:multiversion
Open

[Feature] Events listening#135
Jaffe2718 wants to merge 3 commits intoTeamMidnightDust:feat/comment-formattingfrom
Jaffe2718:multiversion

Conversation

@Jaffe2718
Copy link
Copy Markdown
Contributor

Add events for (Neo)Forge/Fabric:

NeoForge

@EventBusSubscriber(modid = "midnightlib", value = Dist.CLIENT)
public class MidnightLibNeoEvent {

    @SubscribeEvent
    public void onConfigRegistered(MidnightEvent.ConfigRegistered event) {
        // ...
    }

    @SubscribeEvent
    public void onConfigScreenOpened(MidnightEvent.ConfigScreenOpened event) {
        // ...
    }

    @SubscribeEvent
    public void onConfigScreenClosed(MidnightEvent.ConfigScreenClosed event) {
        // ...
    }

    @SubscribeEvent
    public void onSetValue(MidnightEvent.SetValue event) {
        // ...
    }

    @SubscribeEvent
    public void onWriteConfig(MidnightEvent.WriteConfig event) {
        // ...
    }
}

Fabric

public class MidnightEventTest {
    public static void registerEvents() {
        MidnightEvent.CONFIG_REGISTERED.register((modid) -> System.out.println("ConfigRegistered: " + modid));
        MidnightEvent.CONFIG_SCREEN_OPENED.register((modid, screen) -> System.out.println("ConfigScreenOpened: " + modid));
        MidnightEvent.CONFIG_SCREEN_CLOSED.register((modid) -> System.out.println("ConfigScreenClosed: " + modid));
        MidnightEvent.SET_VALUE.register((modid, fieldName, old, newValue) -> System.out.printf("SetValue[%s:%s]: %s -> %s%n", modid, fieldName, old, newValue));
        MidnightEvent.WRITE_CONFIG.register((modid) -> System.out.println("WriteConfig: " + modid));
    }
}
image

@Jaffe2718
Copy link
Copy Markdown
Contributor Author

#134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant