feat: add ModLoaded callback event on Fabric (#346)

Co-authored-by: William <will27528@gmail.com>
feat/data-edit-commands
Stampede 4 months ago committed by GitHub
parent 0dee2e8319
commit e7659255fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -49,6 +49,7 @@ import net.william278.husksync.database.MongoDbDatabase;
import net.william278.husksync.database.MySqlDatabase;
import net.william278.husksync.database.PostgresDatabase;
import net.william278.husksync.event.FabricEventDispatcher;
import net.william278.husksync.event.ModLoadedCallback;
import net.william278.husksync.hook.PlanHook;
import net.william278.husksync.listener.EventListener;
import net.william278.husksync.listener.FabricEventListener;
@ -206,6 +207,8 @@ public class FabricHuskSync implements DedicatedServerModInitializer, HuskSync,
// Check for updates
this.checkForUpdates();
ModLoadedCallback.EVENT.invoker().post(FabricHuskSyncAPI.getInstance());
}
private void onDisable() {

@ -0,0 +1,39 @@
/*
* This file is part of HuskSync, licensed under the Apache License 2.0.
*
* Copyright (c) William278 <will27528@gmail.com>
* Copyright (c) contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.william278.husksync.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.william278.husksync.api.HuskSyncAPI;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
public interface ModLoadedCallback {
@NotNull
Event<ModLoadedCallback> EVENT = EventFactory.createArrayBacked(
ModLoadedCallback.class,
(listeners) -> (api) -> Arrays.stream(listeners).forEach(listener -> listener.post(api))
);
void post(@NotNull HuskSyncAPI api);
}
Loading…
Cancel
Save