added more sided dialog, added api and added PlayerHandler
This commit is contained in:
1 parent
9f63680d79
commit
4e6255483b
11 files changed
+635
-3
No files matched your search
@@ -0,0 +1,73 @@
|
||||
package eu.mhsl.craftattack.loginServer;
|
||||
|
||||
import eu.mhsl.craftattack.loginServer.listeners.Listener;
|
||||
import net.minestom.server.Auth;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.extras.lan.OpenToLAN;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Main {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Main.class.getName());
|
||||
|
||||
public static ConfigurationNode globalConfig;
|
||||
|
||||
static void main(String[] args) throws IOException {
|
||||
Path configPath = Path.of("resources", "config.yml");
|
||||
|
||||
if (Files.notExists(configPath)) {
|
||||
Files.createDirectories(configPath.getParent());
|
||||
try (InputStream in = Main.class.getResourceAsStream("/config.yml")) {
|
||||
if (in == null) {
|
||||
throw new IllegalStateException("config.yml fehlt in src/main/resources!");
|
||||
}
|
||||
Files.copy(in, configPath);
|
||||
}
|
||||
}
|
||||
|
||||
globalConfig = YamlConfigurationLoader.builder().path(configPath).build().load();
|
||||
|
||||
ConfigurationNode serverConfig = globalConfig.node("server");
|
||||
|
||||
int viewDistance = serverConfig.node("view-distance").getInt(12);
|
||||
if (viewDistance > 0) {
|
||||
System.setProperty("minestom.chunk-view-distance", String.valueOf(viewDistance));
|
||||
}
|
||||
|
||||
logger.info("Initialisiere Minecraft-Server ...");
|
||||
|
||||
Auth auth = new Auth.Online();
|
||||
if (globalConfig.node("bungeecord", "enabled").getBoolean(false)) {
|
||||
auth = new Auth.Bungee();
|
||||
} else if (globalConfig.node("velocity", "enabled").getBoolean(false)) {
|
||||
String secret = globalConfig.node("velocity", "secret").getString("");
|
||||
if (secret.isBlank()) {
|
||||
throw new IllegalStateException("Velocity ist aktiviert, aber das Secret fehlt!");
|
||||
}
|
||||
auth = new Auth.Velocity(secret);
|
||||
}
|
||||
|
||||
MinecraftServer server = MinecraftServer.init(auth);
|
||||
MinecraftServer.setCompressionThreshold(serverConfig.node("compression-threshold").getInt(0));
|
||||
|
||||
Listener.registerAll(
|
||||
MinecraftServer.getGlobalEventHandler(),
|
||||
MinecraftServer.getInstanceManager()
|
||||
);
|
||||
|
||||
if (serverConfig.node("open-to-lan").getBoolean(false)) {
|
||||
OpenToLAN.open();
|
||||
}
|
||||
|
||||
int port = serverConfig.node("port").getInt(25565);
|
||||
logger.info("Starte Minecraft-Server auf Port " + port + " ...");
|
||||
server.start("0.0.0.0", port);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user