fix: welcome module crashing

This commit is contained in:
iceBear67 committed 2024-07-14 15:31:48 +08:00
1 parent e3193ab49d
commit 9c19007d81
4 files changed
+8 -15

No files matched your search

@@ -1,6 +1,5 @@
package io.ib67.sfcraft.config;
public class ConfigResources {
public static final String UPDATE_LOG="update.log";
public static final String MOTD="motd.txt";
}
@@ -50,6 +50,7 @@ public abstract class GuiceModInitializer extends AbstractModule implements ModI
moduleManager = new SimpleModuleManager(Map.copyOf(map));
}
private void onServerStopping(MinecraftServer minecraftServer) {
onStopping(minecraftServer);
}
@@ -35,25 +35,13 @@ public class WelcomeModule extends ServerModule {
private static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern("yyyy/MM/dd");
@Inject
private SFConfig config;
@Inject
@ConfigRoot
private Path root;
@Inject
private GeoIPService geoIPService;
private String updateLog;
@Override
public void onInitialize() {
updateLog = getConfigResource(root, ConfigResources.UPDATE_LOG).orElse("他没写呢");
ServerPlayConnectionEvents.JOIN.register(this::onPlayerJoin);
}
@Provides
@ConfigResource(ConfigResources.UPDATE_LOG)
private String getUpdateLog() {
return updateLog;
}
public void onPlayerJoin(ServerPlayNetworkHandler serverPlayNetworkHandler, PacketSender
packetSender, MinecraftServer minecraftServer) {
var player = serverPlayNetworkHandler.getPlayer();