public static ExecuteCommand ( |
||
server | ||
user | RemoteClient | |
text | string | |
return | void |
private void MinecraftServerOnChatMessage(object sender, ChatMessageEventArgs chatMessageEventArgs) { var internalArgs = new ChatMessageEventArgs(chatMessageEventArgs.Origin, chatMessageEventArgs.RawMessage); if (ChatMessage != null) { ChatMessage(this, internalArgs); if (internalArgs.Handled) { chatMessageEventArgs.Handled = true; return; } } chatMessageEventArgs.Handled = true; if (chatMessageEventArgs.RawMessage.StartsWith("/")) { if (chatMessageEventArgs.RawMessage.StartsWith("//")) { MinecraftServer.SendChat(string.Format(SettingsProvider.Get <string>("chat.format"), chatMessageEventArgs.Origin.Username, chatMessageEventArgs.RawMessage.Substring(1))); } else { Command.ExecuteCommand(this, chatMessageEventArgs.Origin, chatMessageEventArgs.RawMessage); } } else { MinecraftServer.SendChat(string.Format(SettingsProvider.Get <string>("chat.format"), chatMessageEventArgs.Origin.Username, chatMessageEventArgs.RawMessage)); } }
public static void Main(string[] args) { CheckEnvironment(); // TODO: Load certain plugins earlier if (PreStartup != null) { PreStartup(null, null); } if (SettingsProvider == null) { // Select a settings provider based on the enviornment if (File.Exists("server.properties")) { SettingsProvider = new VanillaSettingsProvider("server.properties"); } else { // TODO: Create a better settings provider than vanilla SettingsProvider = new VanillaSettingsProvider("server.properties"); SetUpDefaultPermissions(SettingsProvider); } } var server = new Server(SettingsProvider); LoadPlugins(server); Command.LoadCommands(server); // TODO //var consoleLog = new ConsoleLogWriter(LogImportance.Medium); //LogProvider.RegisterProvider(consoleLog); server.Start(); Console.WriteLine("Use /stop to kill the server."); ConsoleClient = new ConsoleClient(server.MinecraftServer); while (true) { var command = Console.ReadLine(); try { if (!String.IsNullOrWhiteSpace(command)) { Command.ExecuteCommand(server, ConsoleClient, command); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } server.Stop(); }