Added /auth <token>
This commit is contained in:
parent
32947a1a1e
commit
3422ade35f
3 changed files with 28 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Terraria;
|
||||
|
|
@ -100,10 +101,11 @@ namespace TShockAPI
|
|||
commands.Add(new Command("protectspawn", "editspawn", new CommandDelegate(ProtectSpawn)));
|
||||
commands.Add(new Command("debug-config", "cfg", new CommandDelegate(DebugConfiguration)));
|
||||
commands.Add(new Command("playing", "", new CommandDelegate(Playing)));
|
||||
commands.Add(new Command("auth", "", new CommandDelegate(AuthToken)));
|
||||
//TShock.admincommandList.Add("debug-config", new CommandDelegate(DebugConfiguration));
|
||||
//TShock.admincommandList.Add("playing", new CommandDelegate(Playing));
|
||||
//TShock.commandList.Add("help", new CommandDelegate(Help));
|
||||
//TShock.commandList.Add("playing", new CommandDelegate(Playing));
|
||||
//TShock.commandList.Add("playing", new CommandDelegate(Playing)););
|
||||
if (ConfigurationManager.distributationAgent != "terraria-online")
|
||||
{
|
||||
commands.Add(new Command("kill", "kill", new CommandDelegate(Kill)));
|
||||
|
|
@ -314,6 +316,20 @@ namespace TShockAPI
|
|||
Tools.SendMessage(ply, "Teleported to your spawnpoint.");
|
||||
}
|
||||
|
||||
public static void AuthToken(CommandArgs args)
|
||||
{
|
||||
if (ConfigurationManager.authToken == 0)
|
||||
return;
|
||||
int givenCode = Convert.ToInt32(args.Message.Remove(0, 5));
|
||||
if (givenCode == ConfigurationManager.authToken)
|
||||
{
|
||||
TextWriter tw = new StreamWriter(FileTools.SaveDir + "users.txt", true);
|
||||
tw.WriteLine(Tools.GetRealIP(Convert.ToString(Netplay.serverSock[args.PlayerID].tcpClient.Client.RemoteEndPoint)) + " superadmin");
|
||||
Tools.SendMessage(args.PlayerID, "SuperAdmin authenticated. Please re-connect using the same IP.");
|
||||
ConfigurationManager.authToken = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void TP(CommandArgs args)
|
||||
{
|
||||
int ply = args.PlayerID;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ namespace TShockAPI
|
|||
public static bool spawnProtect = true;
|
||||
public static int spawnProtectRadius = 5;
|
||||
public static string distributationAgent = "facepunch";
|
||||
public static int authToken = 0;
|
||||
|
||||
public enum NPCList : int
|
||||
{
|
||||
|
|
@ -79,10 +80,7 @@ namespace TShockAPI
|
|||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileTools.CreateFile(FileTools.SaveDir + "config.json");
|
||||
}
|
||||
|
||||
ConfigFile cfg = new ConfigFile();
|
||||
cfg.InvasionMultiplier = 50;
|
||||
cfg.DefaultMaximumSpawns = 4;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ namespace TShockAPI
|
|||
|
||||
public static string saveDir = "./tshock/";
|
||||
|
||||
public static Version VersionNum = new Version(1, 7, 0, 0);
|
||||
public static Version VersionNum = new Version(1, 8, 0, 0);
|
||||
|
||||
public static string VersionCodename = "Facepunch";
|
||||
public static string VersionCodename = "Fuck the wiki!";
|
||||
|
||||
public static bool shownVersion = false;
|
||||
|
||||
|
|
@ -111,6 +111,14 @@ namespace TShockAPI
|
|||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
Console.WriteLine("TShock Version " + Version.Major + "." + Version.Minor + "." + Version.Build + "." + Version.Revision + " (" + VersionCodename + ") now running.");
|
||||
if (!System.IO.File.Exists(FileTools.SaveDir + "auth.lck"))
|
||||
{
|
||||
Random r = new Random((int)System.DateTime.Now.ToBinary());
|
||||
ConfigurationManager.authToken = r.Next(100000, 10000000);
|
||||
Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + ConfigurationManager.authToken);
|
||||
Console.WriteLine("This token will only display ONCE.");
|
||||
FileTools.CreateFile(FileTools.SaveDir + "auth.lck");
|
||||
}
|
||||
Log.Initialize(FileTools.SaveDir + "log.txt", LogLevel.All, true);
|
||||
Log.Info("Starting...");
|
||||
GameHooks.OnPreInitialize += OnPreInit;
|
||||
|
|
@ -484,7 +492,6 @@ namespace TShockAPI
|
|||
|
||||
void OnPreInit()
|
||||
{
|
||||
FileTools.SetupConfig();
|
||||
}
|
||||
|
||||
void OnPostInit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue