mirror of
https://github.com/ceratic/project_vollidioten_mod.git
synced 2026-05-14 00:16:47 +02:00
implement GitHub resource pack auto-updater with HTTP server and configuration
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package ceratic.projectvollidioten;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -14,6 +16,8 @@ public class Projectvollidioten implements ModInitializer {
|
||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
private GithubResourcePackUpdater updater;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
@@ -22,6 +26,9 @@ public class Projectvollidioten implements ModInitializer {
|
||||
|
||||
LOGGER.info("Hello Fabric world!");
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(this::onServerStart);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStop);
|
||||
|
||||
// Event: Player Join
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||
PlayerDataLogger.sendPlayerData(handler.getPlayer(), server, "JOIN");
|
||||
@@ -32,4 +39,15 @@ public class Projectvollidioten implements ModInitializer {
|
||||
PlayerDataLogger.sendPlayerData(handler.getPlayer(), server, "LEAVE");
|
||||
});
|
||||
}
|
||||
|
||||
private void onServerStart(MinecraftServer server) {
|
||||
updater = new GithubResourcePackUpdater(server);
|
||||
updater.start();
|
||||
}
|
||||
|
||||
private void onServerStop(MinecraftServer server) {
|
||||
if (updater != null) {
|
||||
updater.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user