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.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
shadow('com.maxmind.geoip2:geoip2:4.2.0')
|
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)
|
configurations.implementation.extendsFrom(configurations.shadow)
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configurations = [project.configurations.shadow]
|
configurations = [project.configurations.shadow]
|
||||||
exclude("META-INF")
|
exclude("META-INF")
|
||||||
|
//relocate 'com.google', 'sfcraft.relocation.google'
|
||||||
}
|
}
|
||||||
|
|
||||||
remapJar {
|
remapJar {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.ib67.sfcraft.config;
|
package io.ib67.sfcraft.config;
|
||||||
|
|
||||||
public class ConfigResources {
|
public class ConfigResources {
|
||||||
public static final String UPDATE_LOG="update.log";
|
|
||||||
public static final String MOTD="motd.txt";
|
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));
|
moduleManager = new SimpleModuleManager(Map.copyOf(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void onServerStopping(MinecraftServer minecraftServer) {
|
private void onServerStopping(MinecraftServer minecraftServer) {
|
||||||
onStopping(minecraftServer);
|
onStopping(minecraftServer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,25 +35,13 @@ public class WelcomeModule extends ServerModule {
|
|||||||
private static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
private static final DateTimeFormatter FMT = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||||
@Inject
|
@Inject
|
||||||
private SFConfig config;
|
private SFConfig config;
|
||||||
@Inject
|
|
||||||
@ConfigRoot
|
|
||||||
private Path root;
|
|
||||||
@Inject
|
|
||||||
private GeoIPService geoIPService;
|
|
||||||
private String updateLog;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
updateLog = getConfigResource(root, ConfigResources.UPDATE_LOG).orElse("他没写呢");
|
|
||||||
ServerPlayConnectionEvents.JOIN.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register(this::onPlayerJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@ConfigResource(ConfigResources.UPDATE_LOG)
|
|
||||||
private String getUpdateLog() {
|
|
||||||
return updateLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPlayerJoin(ServerPlayNetworkHandler serverPlayNetworkHandler, PacketSender
|
public void onPlayerJoin(ServerPlayNetworkHandler serverPlayNetworkHandler, PacketSender
|
||||||
packetSender, MinecraftServer minecraftServer) {
|
packetSender, MinecraftServer minecraftServer) {
|
||||||
var player = serverPlayNetworkHandler.getPlayer();
|
var player = serverPlayNetworkHandler.getPlayer();
|
||||||
|
|||||||
Reference in new issue
Block a user