public Server(ISettingsProvider settingsProvider) { SettingsProvider = settingsProvider; // Touch TerrainGeneration to load it into app domain FlatlandGenerator.DefaultGeneratorOptions.ToString(); var generator = Level.GetGenerator(SettingsProvider.Get<string>("level.type")); if (generator == null) generator = new FlatlandGenerator(); Level level; if (Directory.Exists(SettingsProvider.Get<string>("level.name"))) level = Level.LoadFrom(SettingsProvider.Get<string>("level.name")); else { level = new Level(generator, SettingsProvider.Get<string>("level.name")); level.AddWorld("overworld"); level.SaveTo(SettingsProvider.Get<string>("level.name")); } MinecraftServer = new MinecraftServer(level); MinecraftServer.Settings.MotD = SettingsProvider.Get<string>("server.motd"); MinecraftServer.Settings.OnlineMode = SettingsProvider.Get<bool>("server.onlinemode"); MinecraftServer.ChatMessage += MinecraftServerOnChatMessage; MinecraftServer.PlayerLoggedIn += MinecraftServerOnPlayerLoggedIn; MinecraftServer.PlayerLoggedOut += MinecraftServerOnPlayerLoggedOut; //MinecraftServer.TabComplete += MinecraftServer_TabComplete; }
public Server (int port, bool onlineMode, int maxPlayers, String motd, int difficulty, String levelName, String levelType, GameMode gamemode, String ingameMOTD) { var level = new Level (); if (levelType == "FLAT") { var generator = new FlatlandGenerator (); level = new Level (generator); } else if (levelType == "NORMAL") { var generator = new StandardGenerator (); level = new Level (generator); } level.AddWorld ("overworld"); this.server = new MinecraftServer (level); this.server.Settings.MotD = motd; this.server.Settings.OnlineMode = onlineMode; this.server.Settings.MaxPlayers = (byte)maxPlayers; this.server.Settings.Difficulty = (Difficulty)difficulty; this.server.PlayerLoggedIn += OnPlayerLoggedIn; this.server.ChatMessage += OnPlayerChatMessage; this.server.PlayerLoggedOut += OnPlayerLoggedOut; this.server.Level.GameMode = gamemode; this.port = port; this.ingameMOTD = ingameMOTD; }