public Server() { ServerHash = Hash.MD5(Guid.NewGuid().ToByteArray()); UseOfficalAuthentication = Settings.Default.UseOfficalAuthentication; Clients = new Dictionary<int, Client>(); Rand = new Random(); Logger = new Logger(this, Settings.Default.LogFile); PluginManager = new PluginManager(this, Settings.Default.PluginFolder); Items = new ItemDb(Settings.Default.ItemsFile); Recipes = Recipe.FromFile(Settings.Default.RecipesFile); SmeltingRecipes = SmeltingRecipe.FromFile(Settings.Default.SmeltingRecipesFile); ClientCommandHandler = new ClientCommandHandler(); ServerCommandHandler = new ServerCommandHandler(); if (Settings.Default.IrcEnabled) InitializeIrc(); }
public Server() { ServerHash = Hash.MD5(Guid.NewGuid().ToByteArray()); UseOfficalAuthentication = Settings.Default.UseOfficalAuthentication; Clients = new ConcurrentDictionary<int, Client>(); Rand = new Random(); Logger = new Logger(this, Settings.Default.LogFile); PluginManager = new PluginManager(this, Settings.Default.PluginFolder); Items = new ItemDb(Settings.Default.ItemsFile); Recipes = Recipe.FromFile(Settings.Default.RecipesFile); SmeltingRecipes = SmeltingRecipe.FromFile(Settings.Default.SmeltingRecipesFile); ClientCommandHandler = new ClientCommandHandler(); ServerCommandHandler = new ServerCommandHandler(); if (Settings.Default.IrcEnabled) InitializeIrc(); _AcceptEventArgs = new SocketAsyncEventArgs(); _AcceptEventArgs.Completed += Accept_Completion; _Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); }
public Server() { ChraftConfig.Load(); BanSystem = new BanSystem(); BanSystem.LoadBansAndWhiteList(); ClientsConnectionSlots = 30; Packet.Role = StreamRole.Server; Rand = new Random(); UseOfficalAuthentication = ChraftConfig.UseOfficalAuthentication; ServerHash = GetRandomServerHash(); EncryptionEnabled = ChraftConfig.EncryptionEnabled; EnableUserSightRadius = ChraftConfig.EnableUserSightRadius; Clients = new ConcurrentDictionary<int, Client>(); AuthClients = new ConcurrentDictionary<int, Client>(); Logger = new Logger(this, ChraftConfig.LogFile); PluginLogger = new PluginLogger(Logger); PluginManager = new PluginManager(this, ChraftConfig.PluginFolder); Items = new ItemDb(ChraftConfig.ItemsFile); Recipes = Recipe.FromXmlFile(ChraftConfig.RecipesFile); SmeltingRecipes = SmeltingRecipe.FromFile(ChraftConfig.SmeltingRecipesFile); ClientCommandHandler = new ClientCommandHandler(); ServerCommandHandler = new ServerCommandHandler(); PacketMap.Initialize(); _AcceptEventArgs = new SocketAsyncEventArgs(); _AcceptEventArgs.Completed += Accept_Completion; _Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); for(int i = 0; i < 10; ++i) { MapChunkPacket.DeflaterPool.Push(new Deflater(5)); } PlayersToSave = new ConcurrentQueue<Client>(); PlayersToSavePostponed = new ConcurrentQueue<Client>(); _generators = new Dictionary<string, IChunkGenerator>(); ServerKey = PacketCryptography.GenerateKeyPair(); }
public Server() { ChraftConfig.Load(); ClientsConnectionSlots = 30; Packet.Role = StreamRole.Server; Rand = new Random(); ServerHash = GetRandomServerHash(); UseOfficalAuthentication = ChraftConfig.UseOfficalAuthentication; Clients = new ConcurrentDictionary<int, Client>(); AuthClients = new ConcurrentDictionary<int, Client>(); Logger = new Logger(this, ChraftConfig.LogFile); PluginManager = new PluginManager(this, ChraftConfig.PluginFolder); Items = new ItemDb(ChraftConfig.ItemsFile); Recipes = Recipe.FromXmlFile(ChraftConfig.RecipesFile); SmeltingRecipes = SmeltingRecipe.FromFile(ChraftConfig.SmeltingRecipesFile); ClientCommandHandler = new ClientCommandHandler(); ServerCommandHandler = new ServerCommandHandler(); if (ChraftConfig.IrcEnabled) InitializeIrc(); PacketMap.Initialize(); _AcceptEventArgs = new SocketAsyncEventArgs(); _AcceptEventArgs.Completed += Accept_Completion; _Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); for(int i = 0; i < 10; ++i) { MapChunkPacket.DeflaterPool.Push(new Deflater(5)); } PlayersToSave = new ConcurrentQueue<Client>(); PlayersToSavePostponed = new ConcurrentQueue<Client>(); }
public void Use(IServer iServer, string commandName, string[] tokens) { Server server = iServer as Server; if (tokens.Length == 0) { server.Logger.Log(LogLevel.Info, "Use /help build for a list of building commands."); server.Logger.Log(LogLevel.Info, "Use /help mod for a list of moderation commands."); server.Logger.Log(LogLevel.Info, "Use /help information for a list of information commands."); server.Logger.Log(LogLevel.Info, "Use /help other for a list of other commands."); server.Logger.Log(LogLevel.Info, "Use /help short for a list of shortcuts."); } else if (tokens.Length > 0) { string message; switch (tokens[0].ToLower()) { case "build": message = (from IServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { server.Logger.Log(LogLevel.Info, "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); server.Logger.Log(LogLevel.Info, message); break; case "mod": message = (from IServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { server.Logger.Log(LogLevel.Info, "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); server.Logger.Log(LogLevel.Info, message); break; case "information": case "info": message = (from IServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { server.Logger.Log(LogLevel.Info, "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); server.Logger.Log(LogLevel.Info, message); break; case "other": message = (from IServerCommand c in ServerCommandHandler.GetCommands() where c.Type == CommandType.Build select c).Aggregate("", (current, c) => current + (", " + c.Name)); if (message == "") { server.Logger.Log(LogLevel.Info, "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); server.Logger.Log(LogLevel.Info, message); break; case "short": message = (from IServerCommand c in ServerCommandHandler.GetCommands() where !string.IsNullOrEmpty(c.Shortcut) select c).Aggregate("", (current, c) => current + (", " + c.Shortcut)); if (message == "") { server.Logger.Log(LogLevel.Info, "There are no commands of this type that you can use."); return; } message = message.Remove(0, 1); server.Logger.Log(LogLevel.Info, message); break; default: IServerCommand cmd; try { cmd = ServerCommandHandler.Find(tokens[0]) as IServerCommand; } catch (CommandNotFoundException e) { server.Logger.Log(LogLevel.Info, e.Message); return; } try { cmd.Help(server); server.Logger.Log(LogLevel.Info, "Type: " + cmd.Type.ToString()); } catch (Exception e) { server.Logger.Log(LogLevel.Info, "There was an error while accessing the help for this command."); server.Logger.Log(e); } break; } } }