Added shitty config system
This commit is contained in:
parent
0afb85f242
commit
f87a14577e
1 changed files with 99 additions and 0 deletions
|
|
@ -13,6 +13,25 @@ namespace TShockAPI
|
|||
public class TShock : TerrariaPlugin
|
||||
{
|
||||
public static string saveDir = "./tshock/";
|
||||
private static double version = 3;
|
||||
private static bool shownVersion = false;
|
||||
|
||||
public static bool killGuide = true;
|
||||
public static int invasionMultiplier = 1;
|
||||
public static int defaultMaxSpawns = 4;
|
||||
public static int defaultSpawnRate = 700;
|
||||
public static bool kickCheater = true;
|
||||
public static bool banCheater = true;
|
||||
public static int serverPort = 7777;
|
||||
public static bool enableWhitelist = false;
|
||||
public static bool infinateInvasion = false;
|
||||
public static bool permaPvp = false;
|
||||
public static int killCount = 0;
|
||||
public static bool shownOneTimeInvasionMinder = false;
|
||||
|
||||
public static string tileWhitelist = "";
|
||||
private static bool banTnt = false;
|
||||
private static bool kickTnt = false;
|
||||
|
||||
public override Version Version
|
||||
{
|
||||
|
|
@ -99,6 +118,86 @@ namespace TShockAPI
|
|||
* Useful stuff:
|
||||
* */
|
||||
|
||||
private static void KeepTilesUpToDate()
|
||||
{
|
||||
TextReader tr = new StreamReader(saveDir + "tiles.txt");
|
||||
string file = tr.ReadToEnd();
|
||||
tr.Close();
|
||||
if (!file.Contains("0x3d"))
|
||||
{
|
||||
System.IO.File.Delete(saveDir + "tiles.txt");
|
||||
CreateFile(saveDir + "tiles.txt");
|
||||
TextWriter tw = new StreamWriter(saveDir + "tiles.txt");
|
||||
tw.Write("0x03, 0x05, 0x14, 0x25, 0x18, 0x18, 0x20, 0x1b, 0x34, 0x48, 0x33, 0x3d, 0x47, 0x49, 0x4a, 0x35, 0x3d, 0x3e, 0x45, 0x47, 0x49, 0x4a,");
|
||||
tw.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetupConfig()
|
||||
{
|
||||
if (!System.IO.Directory.Exists(saveDir)) { System.IO.Directory.CreateDirectory(saveDir); }
|
||||
if (!System.IO.File.Exists(saveDir + "tiles.txt"))
|
||||
{
|
||||
CreateFile(saveDir + "tiles.txt");
|
||||
TextWriter tw = new StreamWriter(saveDir + "tiles.txt");
|
||||
tw.Write("0x03, 0x05, 0x14, 0x25, 0x18, 0x18, 0x20, 0x1b, 0x34, 0x48, 0x33, 0x3d, 0x47, 0x49, 0x4a, 0x35, 0x3d, 0x3e, 0x45, 0x47, 0x49, 0x4a,");
|
||||
tw.Close();
|
||||
}
|
||||
if (!System.IO.File.Exists(saveDir + "motd.txt"))
|
||||
{
|
||||
CreateFile(saveDir + "motd.txt");
|
||||
TextWriter tw = new StreamWriter(saveDir + "motd.txt");
|
||||
tw.WriteLine("This server is running TShock. Type /help for a list of commands.");
|
||||
tw.WriteLine("%255,000,000%Current map: %map%");
|
||||
tw.WriteLine("Current players: %players%");
|
||||
tw.Close();
|
||||
}
|
||||
if (!System.IO.File.Exists(saveDir + "bans.txt")) { CreateFile(saveDir + "bans.txt"); }
|
||||
if (!System.IO.File.Exists(saveDir + "cheaters.txt")) { CreateFile(saveDir + "cheaters.txt"); }
|
||||
if (!System.IO.File.Exists(saveDir + "admins.txt")) { CreateFile(saveDir + "admins.txt"); }
|
||||
if (!System.IO.File.Exists(saveDir + "grief.txt")) { CreateFile(saveDir + "grief.txt"); }
|
||||
if (!System.IO.File.Exists(saveDir + "config.txt"))
|
||||
{
|
||||
CreateFile(saveDir + "config.txt");
|
||||
TextWriter tw = new StreamWriter(saveDir + "config.txt");
|
||||
tw.WriteLine("true,50,4,700,true,true,7777,false,false,false,false,false");
|
||||
tw.Close();
|
||||
}
|
||||
KeepTilesUpToDate();
|
||||
TextReader tr = new StreamReader(saveDir + "config.txt");
|
||||
string config = tr.ReadToEnd();
|
||||
config = config.Replace("\n", "");
|
||||
config = config.Replace("\r", "");
|
||||
config = config.Replace(" ", "");
|
||||
tr.Close();
|
||||
string[] configuration = config.Split(',');
|
||||
try
|
||||
{
|
||||
killGuide = Convert.ToBoolean(configuration[0]);
|
||||
invasionMultiplier = Convert.ToInt32(configuration[1]);
|
||||
defaultMaxSpawns = Convert.ToInt32(configuration[2]);
|
||||
defaultSpawnRate = Convert.ToInt32(configuration[3]);
|
||||
kickCheater = Convert.ToBoolean(configuration[4]);
|
||||
banCheater = Convert.ToBoolean(configuration[5]);
|
||||
serverPort = Convert.ToInt32(configuration[6]);
|
||||
enableWhitelist = Convert.ToBoolean(configuration[7]);
|
||||
infinateInvasion = Convert.ToBoolean(configuration[8]);
|
||||
permaPvp = Convert.ToBoolean(configuration[9]);
|
||||
kickTnt = Convert.ToBoolean(configuration[10]);
|
||||
banTnt = Convert.ToBoolean(configuration[11]);
|
||||
if (infinateInvasion)
|
||||
{
|
||||
//Main.startInv();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteError(e.Message);
|
||||
}
|
||||
|
||||
Netplay.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public static void Kick(int ply, string reason)
|
||||
{
|
||||
NetMessage.SendData(0x2, ply, -1, reason, 0x0, 0f, 0f, 0f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue