//public static bool StartEclipse; //public static bool StartBloodMoon; public static void ProgramStart() { Console.Clear(); Console.ForegroundColor = ConsoleColor.Yellow; ProgramLog.Log("TDSM Rebind API build {0}{1} running on {2}", Globals.Build, Globals.PhaseToSuffix(Globals.BuildPhase), Tools.RuntimePlatform.ToString() ); Console.ForegroundColor = Command.ConsoleSender.DefaultColour; Globals.Touch(); ID.Lookup.Initialise(); try { var lis = new Logging.LogTraceListener(); System.Diagnostics.Trace.Listeners.Clear(); System.Diagnostics.Trace.Listeners.Add(lis); System.Diagnostics.Debug.Listeners.Clear(); System.Diagnostics.Debug.Listeners.Add(lis); } catch (Exception e) { Console.WriteLine(e); } //This will setup the assembly resolves PluginManager.Initialize(Globals.PluginPath); PluginManager.SetHookSource(typeof(HookPoints)); //Load the logs if (!ProgramLog.IsOpen) { var logFile = Globals.DataPath + System.IO.Path.DirectorySeparatorChar + "server.log"; ProgramLog.OpenLogFile(logFile); ConsoleSender.DefaultColour = ConsoleColor.Gray; } //Load plugins PluginManager.LoadPlugins(); // if (!Permissions.PermissionsManager.IsSet) // { // var file = System.IO.Path.Combine(Globals.DataPath, "permissions.xml"); // //if (System.IO.File.Exists(file)) System.IO.File.Delete(file); // if (System.IO.File.Exists(file)) // { // var handler = new Permissions.XmlSupplier(file); // if (handler.Load()) // Permissions.PermissionsManager.SetHandler(handler); // } // } }
protected override void Initialized(object state) { if (/*!Globals.IsPatching &&*/ !ProgramLog.IsOpen) { var logFile = Globals.DataPath + System.IO.Path.DirectorySeparatorChar + "server.log"; ProgramLog.OpenLogFile(logFile); ProgramLog.Log("TDSM Rebind core build {0}", this.Version); Tools.SetWriteLineMethod(ProgramLog.Log, OnLogFinished); ConsoleSender.DefaultColour = ConsoleColor.Gray; //ConsoleSender.SetMethod((msg, r, g, b) => //{ // Console.ForegroundColor = FromColor((byte)r, (byte)g, (byte)b); // Console.WriteLine(msg); //}); } Ops = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "ops.txt")); #if WebInterface WebInterface.WebPermissions.Load(); #endif AddCommand("platform") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Show what type of server is running TDSM") .SetDefaultUsage() .WithPermissionNode("tdsm.platform") .Calls(this.OperatingSystem); AddCommand("exit") .WithDescription("Stops the server") .WithAccessLevel(AccessLevel.CONSOLE) .SetDefaultUsage() .WithPermissionNode("tdsm.admin") .Calls(this.Exit); AddCommand("stop") .WithDescription("Stops the server") .WithAccessLevel(AccessLevel.CONSOLE) .SetDefaultUsage() .WithPermissionNode("tdsm.admin") .Calls(this.Exit); AddCommand("time") .WithDescription("Change the time of day") .WithAccessLevel(AccessLevel.OP) .WithHelpText("set <numeric time>") .WithHelpText("set 5:10am") .WithHelpText("now|?") .WithHelpText("day|dawn|dusk|noon|night") .WithPermissionNode("tdsm.time") .Calls(this.Time); AddCommand("give") .WithAccessLevel(AccessLevel.OP) .WithDescription("Give a player items") .WithHelpText("<player> <amount> <itemname:itemid> [-prefix]") .WithPermissionNode("tdsm.give") .Calls(this.Give); AddCommand("spawnnpc") .WithAccessLevel(AccessLevel.OP) .WithDescription("Spawns NPCs") .WithHelpText("<amount> \"<name:id>\" \"<player>\"") .WithPermissionNode("tdsm.spawnnpc") .Calls(this.SpawnNPC); AddCommand("tp") .WithAccessLevel(AccessLevel.OP) .WithDescription("Teleport a player to another player") .WithHelpText("<player> <toplayer> - another player") .WithHelpText("<player> <x> <y>") .WithHelpText("<toplayer> - yourself") .WithHelpText("<x> <y>") .WithHelpText(" - yourself to spawn") .WithPermissionNode("tdsm.tp") .Calls(this.Teleport); AddCommand("tphere") .WithAccessLevel(AccessLevel.OP) .WithDescription("Teleport a player to yourself") .WithHelpText("<player>") .WithPermissionNode("tdsm.tphere") .Calls(this.TeleportHere); AddCommand("save") .WithDescription("Save world and configuration data") .WithAccessLevel(AccessLevel.OP) .SetDefaultUsage() .WithPermissionNode("tdsm.admin") .Calls(this.SaveAll); AddCommand("save-all") .WithDescription("Save world and configuration data") .WithAccessLevel(AccessLevel.OP) .SetDefaultUsage() .WithPermissionNode("tdsm.admin") .Calls(this.SaveAll); //AddCommand("reload") // .WithDescription(Languages.CommandDescription_ReloadConfig) // .WithAccessLevel(AccessLevel.REMOTE_CONSOLE) // .WithPermissionNode("tdsm.admin") // .Calls(this.Reload); AddCommand("itemrej") .WithAccessLevel(AccessLevel.OP) .WithDescription("Manage item rejections") .WithHelpText("-add|-remove <id:name>") .WithHelpText("-clear") .WithPermissionNode("tdsm.itemrej") .Calls(this.ItemRejection); AddCommand("refresh") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Redownload the area around you from the server") .WithHelpText("Usage: refresh") .WithPermissionNode("tdsm.refresh") .Calls(this.Refresh); AddCommand("list") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Lists online players") .SetDefaultUsage() .WithPermissionNode("tdsm.who") .Calls(this.List); AddCommand("who") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Lists online players") .SetDefaultUsage() .WithPermissionNode("tdsm.who") .Calls(this.List); AddCommand("players") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Lists online players") .SetDefaultUsage() .WithPermissionNode("tdsm.who") .Calls(this.OldList); // this is what the server crawler expects AddCommand("playing") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Lists online players") .SetDefaultUsage() .WithPermissionNode("tdsm.who") .Calls(this.OldList); AddCommand("online") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Lists online players") .SetDefaultUsage() .WithPermissionNode("tdsm.who") .Calls(this.List); AddCommand("me") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("3rd person talk") .WithHelpText("<message> - Message to display in third person.") //.SetDefaultUsage() //This was causing an additional "me" to be displayed in the help commmand syntax. .WithPermissionNode("tdsm.me") .Calls(this.Action); AddCommand("say") .WithAccessLevel(AccessLevel.OP) .WithDescription("Say a message from the server") .WithHelpText("<message>") .WithPermissionNode("tdsm.say") .Calls(this.Say); AddCommand("status") .WithDescription("Server status") .SetDefaultUsage() .WithPermissionNode("tdsm.status") .Calls(this.ServerStatus); AddCommand("kick") .WithDescription("Kicks a player from the server") .WithHelpText("<player> - Kicks the player specified.") .WithPermissionNode("tdsm.kick") .Calls(this.Kick); AddCommand("op") .WithAccessLevel(AccessLevel.OP) .WithDescription("Allows a player server operator status") .WithHelpText("<player> <password> - Sets the player as an operator on the server and sets the OP password for that player.") .WithPermissionNode("tdsm.op") .Calls(this.OpPlayer); AddCommand("deop") .WithAccessLevel(AccessLevel.OP) .WithDescription("Removes server operator status from a player") .WithHelpText("<player> - Removes server operator status from the specified player.") .WithPermissionNode("tdsm.deop") .Calls(this.DeopPlayer); AddCommand("oplogin") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Allows an operator to log in") .WithHelpText("<password> - Logs into the server as an OP.") .WithPermissionNode("tdsm.oplogin") .Calls(this.OpLogin); AddCommand("oplogout") .WithAccessLevel(AccessLevel.PLAYER) .WithDescription("Logs out a signed in operator.") .SetDefaultUsage() .WithPermissionNode("tdsm.oplogout") .Calls(this.OpLogout); AddCommand("spawnboss") .WithAccessLevel(AccessLevel.OP) .WithDescription("Spawn a boss") .WithHelpText("eye skeletron eater kingslime prime twins destroyer wof plantera golem retinazer spazmatism") .WithHelpText("eye twins -night") .WithHelpText("-all") .WithHelpText("<boss> -player <name>") .WithHelpText("(If no player is entered it will be a random online player)") .WithPermissionNode("tdsm.spawnboss") .Calls(this.SummonBoss); AddCommand("timelock") .WithAccessLevel(AccessLevel.OP) .WithDescription("Forces the time to stay at a certain point.") .WithHelpText("now") .WithHelpText("set day|dawn|dusk|noon|night") .WithHelpText("setat <time>") .WithHelpText("disable") .WithPermissionNode("tdsm.timelock") .Calls(this.Timelock); //AddCommand("heal") // .WithAccessLevel(AccessLevel.OP) // .WithDescription("Heals one or all players.") // .WithHelpText("<player>") // .WithHelpText("-all") // .WithPermissionNode("tdsm.heal") // .Calls(this.Heal); AddCommand("hardmode") .WithAccessLevel(AccessLevel.OP) .SetDefaultUsage() .WithDescription("Enables hard mode.") .WithPermissionNode("tdsm.hardmode") .Calls(this.HardMode); AddCommand("rcon") .WithDescription("Manage remote console access.") .WithAccessLevel(AccessLevel.REMOTE_CONSOLE) .WithHelpText("load - reload login database") .WithHelpText("list - list rcon connections") .WithHelpText("cut <name> - cut off rcon connections") .WithHelpText("ban <name> - cut off rcon connections and revoke access") .WithHelpText("add <name> <password> - add an rcon user") .WithPermissionNode("tdsm.rcon") .Calls(RConServer.RConCommand); AddCommand("npcspawning") .WithDescription("Turn NPC spawning on or off.") .WithAccessLevel(AccessLevel.OP) .WithHelpText("<true|false>") .WithPermissionNode("tdsm.npcspawning") .Calls(this.NPCSpawning); AddCommand("invasion") .WithDescription("Begins an invasion") .WithAccessLevel(AccessLevel.OP) .WithHelpText("goblin|frost|pirate|martian") .WithHelpText("-custom <npc id or name> <npc id or name> ...") .WithHelpText("stop|end|cancel") .WithPermissionNode("tdsm.invasion") .Calls(this.Invasion); AddCommand("serverlist") .WithDescription("Manages the heartbeat and server list") .WithAccessLevel(AccessLevel.OP) .WithHelpText("print|? - Displays the current details") .WithHelpText("enable|disable - Enable/disable the heartbeat") .WithHelpText("public true|false - Allows public viewing") .WithHelpText("desc|name|domain - Displays the current") .WithHelpText("desc <description>") .WithHelpText("name <name>") .WithHelpText("domain <domain>") .WithPermissionNode("tdsm.serverlist") .Calls(this.ServerList); AddCommand("var") .WithAccessLevel(AccessLevel.OP) .WithDescription("Experimental variable manipulation") .WithHelpText("<field|exec|prop> <namespace.classname> <fieldname|methodname>") .WithHelpText("field Terraria.Main eclipse #Get the value") .WithHelpText("field Terraria.Main eclipse false #Set the value") .WithPermissionNode("tdsm.var") .Calls(this.VariableMan); AddCommand("worldevent") .WithAccessLevel(AccessLevel.OP) .WithDescription("Start or stop an event") .WithHelpText("eclipse|bloodmoon|pumpkinmoon|snowmoon|slimerain") .WithPermissionNode("tdsm.worldevent") .Calls(this.WorldEvent); #if TDSMServer AddCommand("maxplayers") .WithAccessLevel(AccessLevel.REMOTE_CONSOLE) .WithDescription("Set the maximum number of player slots.") .WithHelpText("<num> - set the max number of slots") .WithHelpText("<num> <num> - also set the number of overlimit slots") .WithPermissionNode("tdsm.maxplayers") .Calls(SlotManager.MaxPlayersCommand); AddCommand("q") .WithAccessLevel(AccessLevel.OP) .WithDescription("List connections waiting in queues.") .WithHelpText("q") .WithPermissionNode("tdsm.q") .Calls(SlotManager.QCommand); AddCommand("conn") .WithAccessLevel(AccessLevel.OP) .WithDescription("Accept new connections.") .WithPermissionNode("tdsm.conn") .SetDefaultUsage() .Calls(Server.Command_AcceptConnections); #endif // AddCommand("restart") // .WithAccessLevel(AccessLevel.OP) // .WithDescription("Restart the server.") // .WithHelpText("<no parameters> - Restart immediately.") // .WithHelpText("--wait - Wait for users to disconnect and then restart.") // .WithPermissionNode("tdsm.restart") // .Calls(this.Restart); #if DEBUG AddCommand("repo") .WithAccessLevel(AccessLevel.OP) .WithDescription("Install or update plugins.") .WithHelpText("<status|update|install> <plugin name>") .WithHelpText("status -all") .WithHelpText("update -all") .WithHelpText("update \"TDSM Core Module\"") .WithPermissionNode("tdsm.repo") .Calls(this.RepositoryCommand); //Template for when we have more plugins //AddCommand("repo") // .WithDescription("The tdsm update repository") // .WithAccessLevel(AccessLevel.OP) // .WithHelpText("status - Displays plugins out of date") // .WithHelpText("definitions - Update NPC and Item definitions") // .WithHelpText("updatetest - Tests if your plugins are compatible with the latest TDSM") // .WithHelpText("search <search params> - Browse the repository") // .WithHelpText("update <plugin name>|-all - Update a particular plugin or all") // .WithHelpText("install <plugin name> - Installs a plugin") // .WithPermissionNode("tdsm.repo") // .Calls(this.Repository); #endif if (!DefinitionManager.Initialise()) { ProgramLog.Log("Failed to initialise definitions."); } ProgramLog.Log("TDSM Rebind core enabled"); }