fix: welcome module crashing
This commit is contained in:
4 files changed
+8
-15
No files matched your search
+6
-1
@@ -30,13 +30,18 @@ dependencies {
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
shadow('com.maxmind.geoip2:geoip2:4.2.0')
|
||||
shadow('com.google.inject:guice:7.0.0')
|
||||
shadow('com.google.inject:guice:7.0.0') {
|
||||
exclude group: 'com.google.guava', module: 'guava'
|
||||
exclude group: 'com.google.guava', module: 'listenablefuture'
|
||||
exclude group: 'com.google.guava', module: 'failureaccess'
|
||||
}
|
||||
}
|
||||
configurations.implementation.extendsFrom(configurations.shadow)
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadow]
|
||||
exclude("META-INF")
|
||||
//relocate 'com.google', 'sfcraft.relocation.google'
|
||||
}
|
||||
|
||||
remapJar {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user