diff --git a/TShockAPI/BackupManager.cs b/TShockAPI/BackupManager.cs
index 3d776ce2..127fb185 100644
--- a/TShockAPI/BackupManager.cs
+++ b/TShockAPI/BackupManager.cs
@@ -18,10 +18,7 @@ along with this program. If not, see .
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
using System.Threading;
using Terraria;
diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index b69a9219..4c0d6b73 100644
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -17,12 +17,11 @@ along with this program. If not, see .
*/
using System;
using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Linq;
using System.Diagnostics;
+using System.IO;
+using System.Linq;
using System.Net;
+using System.Text;
using System.Threading;
using Microsoft.Xna.Framework;
using Terraria;
@@ -370,7 +369,7 @@ namespace TShockAPI
catch (UserManagerException ex)
{
args.Player.SendMessage("Sorry, an error occured: " + ex.Message, Color.Green);
- Log.ConsoleError("RegisterUser returned an error: " + ex.ToString());
+ Log.ConsoleError("RegisterUser returned an error: " + ex);
}
}
@@ -406,7 +405,7 @@ namespace TShockAPI
catch (UserManagerException ex)
{
args.Player.SendMessage("Sorry, an error occured: " + ex.Message, Color.Green);
- Log.ConsoleError("RegisterUser returned an error: " + ex.ToString());
+ Log.ConsoleError("RegisterUser returned an error: " + ex);
}
}
@@ -936,7 +935,7 @@ namespace TShockAPI
return;
}
NPC eater = Tools.GetNPCById(13);
- TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned eater of worlds {1} times!", args.Player.Name, amount));
}
@@ -955,7 +954,7 @@ namespace TShockAPI
}
NPC eye = Tools.GetNPCById(4);
TSPlayer.Server.SetTime(false, 0.0);
- TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned eye {1} times!", args.Player.Name, amount));
}
@@ -973,7 +972,7 @@ namespace TShockAPI
return;
}
NPC king = Tools.GetNPCById(50);
- TSPlayer.Server.SpawnNPC(king.type, king.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(king.type, king.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned king slime {1} times!", args.Player.Name, amount));
}
@@ -992,7 +991,7 @@ namespace TShockAPI
}
NPC skeletron = Tools.GetNPCById(35);
TSPlayer.Server.SetTime(false, 0.0);
- TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned skeletron {1} times!", args.Player.Name, amount));
}
@@ -1014,10 +1013,10 @@ namespace TShockAPI
NPC king = Tools.GetNPCById(50);
NPC skeletron = Tools.GetNPCById(35);
TSPlayer.Server.SetTime(false, 0.0);
- TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
- TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
- TSPlayer.Server.SpawnNPC(king.type, king.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
- TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, (int)args.Player.TileX, (int)args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(eater.type, eater.name, amount, args.Player.TileX, args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(eye.type, eye.name, amount, args.Player.TileX, args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(king.type, king.name, amount, args.Player.TileX, args.Player.TileY);
+ TSPlayer.Server.SpawnNPC(skeletron.type, skeletron.name, amount, args.Player.TileX, args.Player.TileY);
Tools.Broadcast(string.Format("{0} has spawned all bosses {1} times!", args.Player.Name, amount));
}
@@ -1054,7 +1053,7 @@ namespace TShockAPI
var npc = npcs[0];
if (npc.type >= 1 && npc.type < Main.maxNPCTypes)
{
- TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, (int)args.Player.TileX, (int)args.Player.TileY, 50, 20);
+ TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY, 50, 20);
Tools.Broadcast(string.Format("{0} was spawned {1} time(s).", npc.name, amount));
}
else
@@ -1988,8 +1987,8 @@ namespace TShockAPI
else
{
var ply = players[0];
- args.Player.SendMessage("Annoying " + ply.Name + " for " + annoy.ToString() + " seconds.");
- (new Thread(new ParameterizedThreadStart(ply.Whoopie))).Start(annoy);
+ args.Player.SendMessage("Annoying " + ply.Name + " for " + annoy + " seconds.");
+ (new Thread(ply.Whoopie)).Start(annoy);
}
}
#endregion General Commands
@@ -2080,7 +2079,7 @@ namespace TShockAPI
if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack;
args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
- args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount.ToString(), item.name));
+ args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
}
else
{
@@ -2150,8 +2149,8 @@ namespace TShockAPI
if (itemAmount == 0 || itemAmount > item.maxStack)
itemAmount = item.maxStack;
plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount);
- args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount.ToString(), item.name));
- plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount.ToString(), item.name));
+ args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name));
+ plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name));
}
else
{
diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs
index 0071a5d8..dc36f700 100644
--- a/TShockAPI/ConfigFile.cs
+++ b/TShockAPI/ConfigFile.cs
@@ -27,9 +27,9 @@ namespace TShockAPI
public int DefaultMaximumSpawns = 4;
public int DefaultSpawnRate = 700;
public int ServerPort = 7777;
- public bool EnableWhitelist = false;
- public bool InfiniteInvasion = false;
- public bool AlwaysPvP = false;
+ public bool EnableWhitelist;
+ public bool InfiniteInvasion;
+ public bool AlwaysPvP;
public bool KickCheaters = true;
public bool BanCheaters = true;
public bool KickGriefers = true;
@@ -44,24 +44,24 @@ namespace TShockAPI
public string DistributationAgent = "facepunch";
public int MaxSlots = 8;
public bool RangeChecks = true;
- public bool SpamChecks = false;
- public bool DisableBuild = false;
+ public bool SpamChecks;
+ public bool DisableBuild;
public int TileThreshold = 60;
public float[] AdminChatRGB = { 255, 0, 0 };
public string AdminChatPrefix = "(Admin) ";
public bool AdminChatEnabled = true;
- public int PvpThrottle = 0;
+ public int PvpThrottle;
- public int BackupInterval = 0;
+ public int BackupInterval;
public int BackupKeepFor = 60;
- public bool RememberLeavePos = false;
+ public bool RememberLeavePos;
- public bool HardcoreOnly = false;
- public bool KickOnHardcoreDeath = false;
- public bool BanOnHardcoreDeath = false;
+ public bool HardcoreOnly;
+ public bool KickOnHardcoreDeath;
+ public bool BanOnHardcoreDeath;
public bool AutoSave = true;
@@ -94,9 +94,9 @@ namespace TShockAPI
public string HardcoreBanReason = "Death results in a ban";
public string HardcoreKickReason = "Death results in a kick";
- public bool EnableDNSHostResolution = false;
+ public bool EnableDNSHostResolution;
- public bool EnableBanOnUsernames = false;
+ public bool EnableBanOnUsernames;
public bool EnableAntiLag = true;
diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs
index 20bf5c84..f4d0fa86 100644
--- a/TShockAPI/DB/BanManager.cs
+++ b/TShockAPI/DB/BanManager.cs
@@ -17,12 +17,8 @@ along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.Data;
using System.IO;
-using System.Text;
-using Community.CsharpSqlite.SQLiteClient;
-using TShockAPI.DB;
namespace TShockAPI.DB
{
@@ -63,7 +59,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "bans.txt");
if (!Directory.Exists(path))
- System.IO.Directory.CreateDirectory(path);
+ Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
diff --git a/TShockAPI/DB/DbExt.cs b/TShockAPI/DB/DbExt.cs
index 49014ac8..20d4a74c 100644
--- a/TShockAPI/DB/DbExt.cs
+++ b/TShockAPI/DB/DbExt.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
-using System.Linq;
-using System.Text;
namespace TShockAPI.DB
{
@@ -55,8 +53,8 @@ namespace TShockAPI.DB
return parm;
}
- static Dictionary> ReadFuncs = new Dictionary>()
- {
+ static Dictionary> ReadFuncs = new Dictionary>
+ {
{typeof(bool), (s, i) => s.GetBoolean(i)},
{typeof(byte), (s, i) => s.GetByte(i)},
{typeof(Int16), (s, i) => s.GetInt16(i)},
diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs
index c82b2eaa..6fe3bbc1 100644
--- a/TShockAPI/DB/GroupManager.cs
+++ b/TShockAPI/DB/GroupManager.cs
@@ -1,10 +1,8 @@
using System;
-using System.IO;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Data;
-using Community.CsharpSqlite.SQLiteClient;
+using System.IO;
+using System.Linq;
namespace TShockAPI.DB
{
@@ -72,7 +70,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "groups.txt");
if (!Directory.Exists(path))
- System.IO.Directory.CreateDirectory(path);
+ Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
diff --git a/TShockAPI/DB/ItemManager.cs b/TShockAPI/DB/ItemManager.cs
index d30c580f..7722724d 100644
--- a/TShockAPI/DB/ItemManager.cs
+++ b/TShockAPI/DB/ItemManager.cs
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Data;
-using Community.CsharpSqlite.SQLiteClient;
-using TShockAPI.DB;
using System.IO;
namespace TShockAPI.DB
@@ -50,7 +46,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "itembans.txt");
if (!Directory.Exists(path))
- System.IO.Directory.CreateDirectory(path);
+ Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs
index 57285994..fea9328a 100644
--- a/TShockAPI/DB/RegionManager.cs
+++ b/TShockAPI/DB/RegionManager.cs
@@ -18,17 +18,12 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Xml;
-using System.IO;
using System.Data;
-using TShockAPI.DB;
-using Community.CsharpSqlite.SQLiteClient;
+using System.IO;
+using System.Xml;
using Microsoft.Xna.Framework;
using Terraria;
-
namespace TShockAPI.DB
{
public class RegionManager
@@ -171,8 +166,8 @@ namespace TShockAPI.DB
int height = reader.Get("height");
int width = reader.Get("width");
int Protected = reader.Get("Protected");
- string MergedIDs = DbExt.Get(reader, "UserIds");
- string name = DbExt.Get(reader, "RegionName");
+ string MergedIDs = reader.Get("UserIds");
+ string name = reader.Get("RegionName");
string[] SplitIDs = MergedIDs.Split(',');
@@ -215,8 +210,8 @@ namespace TShockAPI.DB
int height = reader.Get("height");
int width = reader.Get("width");
int Protected = reader.Get("Protected");
- string MergedIDs = DbExt.Get(reader, "UserIds");
- string name = DbExt.Get(reader, "RegionName");
+ string MergedIDs = reader.Get("UserIds");
+ string name = reader.Get("RegionName");
string[] SplitIDs = MergedIDs.Split(',');
Region r = new Region(new Rectangle(X1, Y1, width, height), name, Protected != 0, Main.worldID.ToString());
diff --git a/TShockAPI/DB/SqlTable.cs b/TShockAPI/DB/SqlTable.cs
index 4d1dc44c..fd6eefea 100644
--- a/TShockAPI/DB/SqlTable.cs
+++ b/TShockAPI/DB/SqlTable.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace TShockAPI.DB
+namespace TShockAPI.DB
{
class SqlTable
{
diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs
index 6aa8d841..2dbee46c 100644
--- a/TShockAPI/DB/UserManager.cs
+++ b/TShockAPI/DB/UserManager.cs
@@ -18,12 +18,9 @@ along with this program. If not, see .
*/
using System;
-using System.IO;
-using System.Collections.Generic;
using System.Data;
-using System.Linq;
-using System.Text;
-using Community.CsharpSqlite.SQLiteClient;
+using System.IO;
+
namespace TShockAPI.DB
{
public class UserManager
@@ -82,7 +79,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "users.txt");
if (!Directory.Exists(path))
- System.IO.Directory.CreateDirectory(path);
+ Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
File.Move(file, file2);
@@ -201,7 +198,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
- Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex.ToString());
+ Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex);
}
return returndata;
}
@@ -220,7 +217,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
- Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex.ToString());
+ Log.ConsoleError("FetchHashedPasswordAndGroup SQL returned an error: " + ex);
}
return -1;
}
@@ -244,7 +241,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
- Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex.ToString());
+ Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex);
}
return Tools.GetGroup("default");
}
@@ -266,7 +263,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
- Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex.ToString());
+ Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex);
}
return Tools.GetGroup("default");
}
diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs
index 39411cc7..e15d630f 100644
--- a/TShockAPI/DB/WarpsManager.cs
+++ b/TShockAPI/DB/WarpsManager.cs
@@ -20,8 +20,8 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
-using Microsoft.Xna.Framework;
using System.Xml;
+using Microsoft.Xna.Framework;
using Terraria;
namespace TShockAPI.DB
@@ -111,7 +111,7 @@ namespace TShockAPI.DB
String path = Path.Combine(TShock.SavePath, "old_configs");
String file2 = Path.Combine(path, "warps.xml");
if (!Directory.Exists(path))
- System.IO.Directory.CreateDirectory(path);
+ Directory.CreateDirectory(path);
if (File.Exists(file2))
File.Delete(file2);
//File.Move(file, file2);
diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs
index 880748f4..fcb8d801 100644
--- a/TShockAPI/FileTools.cs
+++ b/TShockAPI/FileTools.cs
@@ -17,7 +17,6 @@ along with this program. If not, see .
*/
using System;
using System.IO;
-using Terraria;
namespace TShockAPI
{
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index 68fc95f7..59cd78b1 100755
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -340,7 +340,7 @@ namespace TShockAPI
if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000)
{
- args.Player.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds).ToString() + " milliseconds before placing/destroying tiles", Color.Red);
+ args.Player.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds) + " milliseconds before placing/destroying tiles", Color.Red);
args.Player.SendTileSquare(x, y);
return true;
}
diff --git a/TShockAPI/IPackable.cs b/TShockAPI/IPackable.cs
index ac6dbaaa..a28952e3 100644
--- a/TShockAPI/IPackable.cs
+++ b/TShockAPI/IPackable.cs
@@ -16,11 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
namespace TShockAPI
{
diff --git a/TShockAPI/Net/NetTile.cs b/TShockAPI/Net/NetTile.cs
index 2395b3fc..be269a61 100644
--- a/TShockAPI/Net/NetTile.cs
+++ b/TShockAPI/Net/NetTile.cs
@@ -17,10 +17,7 @@ along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
using Terraria;
using XNAHelpers;
diff --git a/TShockAPI/Net/WorldInfoMsg.cs b/TShockAPI/Net/WorldInfoMsg.cs
index 913b976c..118f9582 100644
--- a/TShockAPI/Net/WorldInfoMsg.cs
+++ b/TShockAPI/Net/WorldInfoMsg.cs
@@ -17,11 +17,8 @@ along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using Terraria;
using TerrariaAPI;
using XNAHelpers;
diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs
index 43f2e26a..490cfd41 100644
--- a/TShockAPI/Properties/AssemblyInfo.cs
+++ b/TShockAPI/Properties/AssemblyInfo.cs
@@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.1.4.0724")]
-[assembly: AssemblyFileVersion("3.1.4.0724")]
+[assembly: AssemblyVersion("3.1.4.0726")]
+[assembly: AssemblyFileVersion("3.1.4.0726")]
diff --git a/TShockAPI/RconHandler.cs b/TShockAPI/RconHandler.cs
index e72f2588..4240b8ed 100644
--- a/TShockAPI/RconHandler.cs
+++ b/TShockAPI/RconHandler.cs
@@ -18,12 +18,11 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
using System.IO;
using System.Net;
using System.Net.Sockets;
+using System.Text;
+using System.Threading;
using Terraria;
namespace TShockAPI
@@ -36,7 +35,7 @@ namespace TShockAPI
public static int ListenPort;
public static bool ContinueServer = true;
public static string Response = "";
- private static bool Started = false;
+ private static bool Started;
private static UdpClient listener;
public static void StartThread()
@@ -55,9 +54,9 @@ namespace TShockAPI
try
{
Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}",
- ListenPort.ToString(),
+ ListenPort,
Password));
- Thread listen = new Thread(new ThreadStart(Listener));
+ Thread listen = new Thread(Listener);
listen.Start();
while (true)
{
@@ -87,7 +86,7 @@ namespace TShockAPI
catch (SocketException e)
{
if (e.SocketErrorCode == SocketError.AddressAlreadyInUse)
- Log.ConsoleError("Could not bind to " + ListenPort.ToString() + ". Are you sure you don't have another instance running?");
+ Log.ConsoleError("Could not bind to " + ListenPort + ". Are you sure you don't have another instance running?");
}
catch (Exception e)
{
@@ -150,7 +149,7 @@ namespace TShockAPI
args[1] = args[0] = "";
string command = string.Join(" ", args.ToArray());
command = command.TrimEnd(' ').TrimEnd('\0').TrimStart(' ');
- Log.ConsoleInfo("Rcon from " + EP.ToString() + ":" + command);
+ Log.ConsoleInfo("Rcon from " + EP + ":" + command);
Response = "";
response = ExecuteCommand(command);
response += "\n" + Response;
@@ -160,7 +159,7 @@ namespace TShockAPI
else
{
response = "Bad rconpassword.\n";
- Log.ConsoleInfo("Bad rconpassword from " + EP.ToString());
+ Log.ConsoleInfo("Bad rconpassword from " + EP);
}
}
else
@@ -186,7 +185,7 @@ namespace TShockAPI
var infostring = string.Format(@"\_TShock_ver\{6}\mapname\{1}\sv_maxclients\{2}\clients\{3}\sv_privateClients\{4}\hconly\{5}\gamename\TERRARIA\protocol\100\sv_hostname\{0}\g_needPass\{7}",
TShock.Config.ServerName, Main.worldName, Main.maxNetPlayers,
Tools.ActivePlayers(), Main.maxNetPlayers - TShock.Config.MaxSlots,
- TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum.ToString(),
+ TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum,
Netplay.password != "" ? 1 : 0);
if (challenge != "")
infostring += @"\challenge\" + challenge;
@@ -205,7 +204,7 @@ namespace TShockAPI
var statusstring = string.Format(@"\_TShock_ver\{6}\mapname\{1}\sv_maxclients\{2}\clients\{3}\sv_privateClients\{4}\hconly\{5}\gamename\TERRARIA\protocol\100\sv_hostname\{0}\g_needPass\{7}",
TShock.Config.ServerName, Main.worldName, Main.maxNetPlayers,
Tools.ActivePlayers(), Main.maxNetPlayers - TShock.Config.MaxSlots,
- TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum.ToString(),
+ TShock.Config.HardcoreOnly ? 1 : 0, TShock.VersionNum,
Netplay.password != "" ? 1 : 0) + "\n";
if (challenge != "")
statusstring += @"\challenge\" + challenge;
@@ -260,7 +259,7 @@ namespace TShockAPI
if (player != null && player.Active)
{
count++;
- Response += (string.Format("{0} 0 0 {1}({2}) {3} {4} 0 0", count, player.Name, player.Group.Name, Netplay.serverSock[player.Index].tcpClient.Client.RemoteEndPoint.ToString())) + "\n";
+ Response += (string.Format("{0} 0 0 {1}({2}) {3} {4} 0 0", count, player.Name, player.Group.Name, Netplay.serverSock[player.Index].tcpClient.Client.RemoteEndPoint)) + "\n";
}
}
}
@@ -334,7 +333,7 @@ namespace TShockAPI
catch (SocketException e)
{
if (e.SocketErrorCode == SocketError.AddressAlreadyInUse)
- Log.ConsoleError("Could not bind to " + ListenPort.ToString() + ". Are you sure you don't have another instance running?");
+ Log.ConsoleError("Could not bind to " + ListenPort + ". Are you sure you don't have another instance running?");
}
catch (Exception e)
{
diff --git a/TShockAPI/RememberPosManager.cs b/TShockAPI/RememberPosManager.cs
index e6a94615..da4ff076 100644
--- a/TShockAPI/RememberPosManager.cs
+++ b/TShockAPI/RememberPosManager.cs
@@ -18,12 +18,8 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using Terraria;
-using Microsoft.Xna.Framework;
using System.Xml;
+using Microsoft.Xna.Framework;
namespace TShockAPI
{
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index 2db1f9c4..cf81ed0d 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -18,10 +18,10 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.IO;
+using System.Threading;
using Microsoft.Xna.Framework;
using Terraria;
using TerrariaAPI;
-using TShockAPI.DB;
using TShockAPI.Net;
namespace TShockAPI
@@ -38,21 +38,21 @@ namespace TShockAPI
public bool ReceivedInfo { get; set; }
public int Index { get; protected set; }
public DateTime LastPvpChange { get; protected set; }
- public Rectangle TempArea = new Rectangle();
+ public Rectangle TempArea;
public DateTime LastExplosive { get; set; }
public DateTime LastTileChangeNotify { get; set; }
- public bool InitSpawn = false;
+ public bool InitSpawn;
public bool DisplayLogs = true;
public Vector2 oldSpawn = Vector2.Zero;
public TSPlayer LastWhisper;
public int LoginAttempts { get; set; }
public Vector2 TeleportCoords = new Vector2(-1, -1);
public string UserAccountName { get; set; }
- public bool HasBeenSpammedWithBuildMessage = false;
- public bool IsLoggedIn = false;
+ public bool HasBeenSpammedWithBuildMessage;
+ public bool IsLoggedIn;
public int UserID = -1;
- public bool HasBeenNaggedAboutLoggingIn = false;
- Player FakePlayer = null;
+ public bool HasBeenNaggedAboutLoggingIn;
+ Player FakePlayer;
public bool RealPlayer
{
@@ -241,7 +241,7 @@ namespace TShockAPI
{
try
{
- SendData(PacketTypes.TileSendSquare, "", size, (float)(x - (size / 2)), (float)(y - (size / 2)));
+ SendData(PacketTypes.TileSendSquare, "", size, (x - (size / 2)), (y - (size / 2)));
return true;
}
catch (Exception ex)
@@ -253,7 +253,7 @@ namespace TShockAPI
public virtual void GiveItem(int type, string name, int width, int height, int stack)
{
- int itemid = Terraria.Item.NewItem((int)X, (int)Y, width, height, type, stack, true);
+ int itemid = Item.NewItem((int)X, (int)Y, width, height, type, stack, true);
// This is for special pickaxe/hammers/swords etc
Main.item[itemid].SetDefaults(name);
// The set default overrides the wet and stack set by NewItem
@@ -310,18 +310,18 @@ namespace TShockAPI
{
Main.player[0].inventory[player].SetDefaults("Whoopie Cushion");
Main.player[0].inventory[player].stack = 1;
- SendData(TerrariaAPI.PacketTypes.PlayerSlot, "Whoopie Cushion", player, 0f);
+ SendData(PacketTypes.PlayerSlot, "Whoopie Cushion", player, 0f);
Main.player[player].position = TPlayer.position;
Main.player[player].selectedItem = 0;
Main.player[player].controlUseItem = true;
- SendData(TerrariaAPI.PacketTypes.PlayerUpdate, number: player);
- System.Threading.Thread.Sleep(500);
+ SendData(PacketTypes.PlayerUpdate, number: player);
+ Thread.Sleep(500);
Main.player[player].controlUseItem = false;
- SendData(TerrariaAPI.PacketTypes.PlayerUpdate, number: player);
- System.Threading.Thread.Sleep(50);
+ SendData(PacketTypes.PlayerUpdate, number: player);
+ Thread.Sleep(50);
}
Main.player[0].inventory[0] = oriinv;
- SendData(TerrariaAPI.PacketTypes.PlayerSlot, oriinv.name, player, 0f);
+ SendData(PacketTypes.PlayerSlot, oriinv.name, player, 0f);
}
//Todo: Separate this into a few functions. SendTo, SendToAll, etc
@@ -423,7 +423,7 @@ namespace TShockAPI
// Send all players updated tile sqaures
foreach (Vector2 coords in destroyedTiles.Keys)
{
- TSPlayer.All.SendTileSquare((int)coords.X, (int)coords.Y, 3);
+ All.SendTileSquare((int)coords.X, (int)coords.Y, 3);
}
}
}
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 441b089f..e285830b 100755
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -32,16 +32,14 @@ using System.IO;
using System.Net;
using System.Reflection;
using System.Security.Cryptography;
+using System.Text;
using System.Threading;
-using MySql.Data.MySqlClient;
using Community.CsharpSqlite.SQLiteClient;
using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
+using MySql.Data.MySqlClient;
using Terraria;
using TerrariaAPI;
using TerrariaAPI.Hooks;
-using System.Text;
using TShockAPI.DB;
namespace TShockAPI
@@ -68,7 +66,7 @@ namespace TShockAPI
public static IDbConnection DB;
public static Process TShockProcess;
- public static bool OverridePort = false;
+ public static bool OverridePort;
public static double ElapsedTime;
@@ -136,13 +134,14 @@ namespace TShockAPI
{
var hostport = Config.MySqlHost.Split(':');
DB = new MySqlConnection();
- DB.ConnectionString = String.Format("Server='{0}'; Port='{1}'; Database='{2}'; Uid='{3}'; Pwd='{4}';",
- hostport[0],
- hostport.Length > 1 ? hostport[1] : "3306",
- Config.MySqlDbName,
- Config.MySqlUsername,
- Config.MySqlPassword
- );
+ DB.ConnectionString =
+ String.Format("Server='{0}'; Port='{1}'; Database='{2}'; Uid='{3}'; Pwd='{4}';",
+ hostport[0],
+ hostport.Length > 1 ? hostport[1] : "3306",
+ Config.MySqlDbName,
+ Config.MySqlUsername,
+ Config.MySqlPassword
+ );
DB.Open();
}
catch (MySqlException ex)
@@ -178,17 +177,17 @@ namespace TShockAPI
NetHooks.GetData += GetData;
NetHooks.GreetPlayer += OnGreetPlayer;
NpcHooks.StrikeNpc += NpcHooks_OnStrikeNpc;
- NetHooks.SendData += new NetHooks.SendDataD(NetHooks_SendData);
+ NetHooks.SendData += NetHooks_SendData;
GetDataHandlers.InitGetDataHandler();
Commands.InitCommands();
//RconHandler.StartThread();
- Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled"));
+ Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
Log.ConsoleInfo("Backups " + (Backups.Interval > 0 ? "Enabled" : "Disabled"));
}
- void NetHooks_SendData(SendDataEventArgs e)
+ private void NetHooks_SendData(SendDataEventArgs e)
{
if (e.MsgID == PacketTypes.PlayerActive)
{
@@ -305,11 +304,12 @@ namespace TShockAPI
*/
public static int AuthToken = -1;
+
private void OnPostInit()
{
if (!File.Exists(Path.Combine(SavePath, "auth.lck")) && !File.Exists(Path.Combine(SavePath, "authcode.txt")))
{
- var r = new Random((int)DateTime.Now.ToBinary());
+ var r = new Random((int) DateTime.Now.ToBinary());
AuthToken = r.Next(100000, 10000000);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("TShock Notice: To become SuperAdmin, join the game and type /auth " + AuthToken);
@@ -326,7 +326,8 @@ namespace TShockAPI
AuthToken = Convert.ToInt32(tr.ReadLine());
tr.Close();
Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine("TShock Notice: authcode.txt is still present, and the AuthToken located in that file will be used.");
+ Console.WriteLine(
+ "TShock Notice: authcode.txt is still present, and the AuthToken located in that file will be used.");
Console.WriteLine("To become superadmin, join the game and type /auth " + AuthToken);
Console.WriteLine("This token will display until disabled by verification. (/auth-verify)");
Console.ForegroundColor = ConsoleColor.Gray;
@@ -340,6 +341,7 @@ namespace TShockAPI
private DateTime LastCheck = DateTime.UtcNow;
+
private void OnUpdate(GameTime time)
{
UpdateManager.UpdateProcedureCheck();
@@ -351,13 +353,13 @@ namespace TShockAPI
if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1)
{
LastCheck = DateTime.UtcNow;
- foreach (TSPlayer player in TShock.Players)
+ foreach (TSPlayer player in Players)
{
if (player != null && player.Active)
{
if (player.TilesDestroyed != null)
{
- if (player.TileThreshold >= TShock.Config.TileThreshold)
+ if (player.TileThreshold >= Config.TileThreshold)
{
if (Tools.HandleTntUser(player, "Kill tile abuse detected."))
{
@@ -377,7 +379,7 @@ namespace TShockAPI
for (int i = 0; i < inv.Length; i++)
{
- if (inv[i] != null && TShock.Itembans.ItemIsBanned(inv[i].name))
+ if (inv[i] != null && Itembans.ItemIsBanned(inv[i].name))
{
player.Disconnect("Using banned item: " + inv[i].name + ", remove it and rejoin");
break;
@@ -394,14 +396,14 @@ namespace TShockAPI
var player = new TSPlayer(ply);
if (Config.EnableDNSHostResolution)
{
- player.Group = TShock.Users.GetGroupForIPExpensive(player.IP);
+ player.Group = Users.GetGroupForIPExpensive(player.IP);
}
else
{
- player.Group = TShock.Users.GetGroupForIP(player.IP);
+ player.Group = Users.GetGroupForIP(player.IP);
}
- if (Tools.ActivePlayers() + 1 > TShock.Config.MaxSlots && !player.Group.HasPermission("reservedslot"))
+ if (Tools.ActivePlayers() + 1 > Config.MaxSlots && !player.Group.HasPermission("reservedslot"))
{
Tools.ForceKick(player, "Server is full");
handler.Handled = true;
@@ -435,11 +437,11 @@ namespace TShockAPI
{
Log.Info(string.Format("{0} left.", tsplr.Name));
- if (TShock.Config.RememberLeavePos)
+ if (Config.RememberLeavePos)
{
RemeberedPosManager.RemeberedPosistions.Add(new RemeberedPos(tsplr.IP,
- new Vector2(tsplr.X / 16,
- (tsplr.Y / 16) + 3)));
+ new Vector2(tsplr.X/16,
+ (tsplr.Y/16) + 3)));
RemeberedPosManager.WriteSettings();
}
}
@@ -469,8 +471,9 @@ namespace TShockAPI
if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/") && Config.AdminChatEnabled)
{
- Tools.Broadcast(TShock.Config.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
- (byte)TShock.Config.AdminChatRGB[0], (byte)TShock.Config.AdminChatRGB[1], (byte)TShock.Config.AdminChatRGB[2]);
+ Tools.Broadcast(Config.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
+ (byte) Config.AdminChatRGB[0], (byte) Config.AdminChatRGB[1],
+ (byte) Config.AdminChatRGB[2]);
e.Handled = true;
return;
}
@@ -534,7 +537,8 @@ namespace TShockAPI
if (player != null && player.Active)
{
count++;
- TSPlayer.Server.SendMessage(string.Format("{0} ({1}) [{2}]", player.Name, player.IP, player.Group.Name));
+ TSPlayer.Server.SendMessage(string.Format("{0} ({1}) [{2}]", player.Name, player.IP,
+ player.Group.Name));
}
}
TSPlayer.Server.SendMessage(string.Format("{0} players connected.", count));
@@ -546,8 +550,8 @@ namespace TShockAPI
}
else if (text == "autosave")
{
- Main.autoSave = TShock.Config.AutoSave = !TShock.Config.AutoSave;
- Log.ConsoleInfo("AutoSave " + (TShock.Config.AutoSave ? "Enabled" : "Disabled"));
+ Main.autoSave = Config.AutoSave = !Config.AutoSave;
+ Log.ConsoleInfo("AutoSave " + (Config.AutoSave ? "Enabled" : "Disabled"));
e.Handled = true;
}
else if (text.StartsWith("/"))
@@ -577,7 +581,8 @@ namespace TShockAPI
//Debug.WriteLine("Recv: {0:X} ({2}): {3} ({1:XX})", player.Index, (byte)type, player.TPlayer.dead ? "dead " : "alive", type.ToString());
// Stop accepting updates from player as this player is going to be kicked/banned during OnUpdate (different thread so can produce race conditions)
- if ((TShock.Config.BanKillTileAbusers || TShock.Config.KickKillTileAbusers) && player.TileThreshold >= TShock.Config.TileThreshold && !player.Group.HasPermission("ignoregriefdetection"))
+ if ((Config.BanKillTileAbusers || Config.KickKillTileAbusers) &&
+ player.TileThreshold >= Config.TileThreshold && !player.Group.HasPermission("ignoregriefdetection"))
{
Log.Debug("Rejecting " + type + " from " + player.Name + " as this player is about to be kicked");
e.Handled = true;
@@ -618,7 +623,9 @@ namespace TShockAPI
if (Config.AlwaysPvP)
{
player.SetPvP(true);
- player.SendMessage("PvP is forced! Enable PvP else you can't deal damage to other people. (People can kill you)", Color.Red);
+ player.SendMessage(
+ "PvP is forced! Enable PvP else you can't deal damage to other people. (People can kill you)",
+ Color.Red);
}
if (player.Group.HasPermission("causeevents") && Config.InfiniteInvasion)
{
@@ -630,7 +637,7 @@ namespace TShockAPI
{
if (playerIP.IP == player.IP)
{
- player.Teleport((int)playerIP.Pos.X, (int)playerIP.Pos.Y);
+ player.Teleport((int) playerIP.Pos.X, (int) playerIP.Pos.Y);
RemeberedPosManager.RemeberedPosistions.Remove(playerIP);
RemeberedPosManager.WriteSettings();
break;
@@ -667,13 +674,13 @@ namespace TShockAPI
public static void StartInvasion()
{
Main.invasionType = 1;
- if (TShock.Config.InfiniteInvasion)
+ if (Config.InfiniteInvasion)
{
Main.invasionSize = 20000000;
}
else
{
- Main.invasionSize = 100 + (TShock.Config.InvasionMultiplier * Tools.ActivePlayers());
+ Main.invasionSize = 100 + (Config.InvasionMultiplier*Tools.ActivePlayers());
}
Main.invasionWarn = 0;
@@ -687,13 +694,14 @@ namespace TShockAPI
}
}
- static int KillCount = 0;
+ private static int KillCount;
+
public static void IncrementKills()
{
KillCount++;
Random r = new Random();
int random = r.Next(5);
- if (KillCount % 100 == 0)
+ if (KillCount%100 == 0)
{
switch (random)
{
@@ -723,15 +731,15 @@ namespace TShockAPI
{
Vector2 tile = new Vector2(x, y);
Vector2 spawn = new Vector2(Main.spawnTileX, Main.spawnTileY);
- return Vector2.Distance(spawn, tile) <= TShock.Config.SpawnProtectionRadius;
+ return Vector2.Distance(spawn, tile) <= Config.SpawnProtectionRadius;
}
public static bool HackedHealth(TSPlayer player)
{
return (player.TPlayer.statManaMax > 200) ||
- (player.TPlayer.statMana > 200) ||
- (player.TPlayer.statLifeMax > 400) ||
- (player.TPlayer.statLife > 400);
+ (player.TPlayer.statMana > 200) ||
+ (player.TPlayer.statLifeMax > 400) ||
+ (player.TPlayer.statLife > 400);
}
public void OnConfigRead(ConfigFile file)
@@ -772,7 +780,5 @@ namespace TShockAPI
Log.ConsoleError("Invalid or not supported hashing algorithm: " + file.HashAlgorithm);
}
}
-
-
}
}
\ No newline at end of file
diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs
index 345f184c..985ffe8b 100755
--- a/TShockAPI/Tools.cs
+++ b/TShockAPI/Tools.cs
@@ -18,13 +18,13 @@ along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
+using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
-using System.Net;
using Microsoft.Xna.Framework;
using Terraria;
-using System.Linq;
namespace TShockAPI
{
@@ -488,8 +488,8 @@ namespace TShockAPI
public static HashAlgorithm HashAlgo = new MD5Cng();
- public static readonly Dictionary HashTypes = new Dictionary()
- {
+ public static readonly Dictionary HashTypes = new Dictionary
+ {
{"sha512", typeof(SHA512Managed)},
{"sha256", typeof(SHA256Managed)},
{"md5", typeof(MD5Cng)},
diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs
index 88b8fb15..8d86d3c5 100644
--- a/TShockAPI/UpdateManager.cs
+++ b/TShockAPI/UpdateManager.cs
@@ -16,14 +16,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Net;
-using System.Text;
using System.Threading;
-using System.Threading.Tasks;
using Microsoft.Xna.Framework;
-using Terraria;
namespace TShockAPI
{