2023-05-10 21:21:16 +02:00
|
|
|
package com.hypherionmc.craterlib;
|
2022-05-12 00:20:18 +02:00
|
|
|
|
2024-05-01 13:26:18 +02:00
|
|
|
import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
|
|
|
import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
2023-06-02 23:59:14 +02:00
|
|
|
import com.hypherionmc.craterlib.common.FabricCommonPlatform;
|
2024-05-01 18:28:52 +02:00
|
|
|
import com.hypherionmc.craterlib.compat.Vanish;
|
2023-06-08 22:58:02 +02:00
|
|
|
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
2024-01-02 15:16:13 +02:00
|
|
|
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
|
|
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
2024-05-01 18:28:52 +02:00
|
|
|
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
2024-01-02 15:16:13 +02:00
|
|
|
import com.hypherionmc.craterlib.network.CraterFabricNetworkHandler;
|
2024-05-01 13:26:18 +02:00
|
|
|
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
2022-05-12 00:20:18 +02:00
|
|
|
import net.fabricmc.api.ModInitializer;
|
2023-06-08 22:58:02 +02:00
|
|
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
2022-09-24 21:21:01 +02:00
|
|
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
2022-05-12 00:20:18 +02:00
|
|
|
|
2022-12-29 18:15:42 +02:00
|
|
|
public class CraterLibInitializer implements ModInitializer {
|
2022-05-12 00:20:18 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInitialize() {
|
2024-01-02 15:16:13 +02:00
|
|
|
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.SERVER));
|
2024-05-01 13:26:18 +02:00
|
|
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
2024-08-10 14:13:51 +02:00
|
|
|
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(dispatcher));
|
2024-05-01 13:26:18 +02:00
|
|
|
});
|
2023-06-08 22:58:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
ServerLifecycleEvents.SERVER_STARTING.register(server -> {
|
|
|
|
FabricCommonPlatform.server = server;
|
2024-05-01 13:26:18 +02:00
|
|
|
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Starting(BridgedMinecraftServer.of(server)));
|
2023-06-08 22:58:02 +02:00
|
|
|
});
|
|
|
|
|
2024-05-01 13:26:18 +02:00
|
|
|
ServerLifecycleEvents.SERVER_STARTED.register(li -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started(BridgedMinecraftServer.of(li))));
|
|
|
|
ServerLifecycleEvents.SERVER_STOPPING.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping(BridgedMinecraftServer.of(server))));
|
|
|
|
ServerLifecycleEvents.SERVER_STOPPED.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(server))));
|
2024-05-01 18:28:52 +02:00
|
|
|
|
|
|
|
if (ModloaderEnvironment.INSTANCE.isModLoaded("melius-vanish")) {
|
|
|
|
Vanish.register();
|
|
|
|
}
|
2022-05-12 00:20:18 +02:00
|
|
|
}
|
2022-05-12 00:18:53 +02:00
|
|
|
}
|