dont fucking blindy try-catch everywhere
This commit is contained in:
parent
24f7756370
commit
43f173f7d7
2 changed files with 217 additions and 264 deletions
|
|
@ -89,6 +89,8 @@ namespace TShockAPI
|
|||
if (!System.IO.File.Exists(SaveDir + "admins.txt")) { FileTools.CreateFile(SaveDir + "admins.txt"); }
|
||||
if (!System.IO.File.Exists(SaveDir + "grief.txt")) { FileTools.CreateFile(SaveDir + "grief.txt"); }
|
||||
if (!System.IO.File.Exists(SaveDir + "whitelist.txt")) { FileTools.CreateFile(SaveDir + "whitelist.txt"); }
|
||||
if (!System.IO.File.Exists(SaveDir + "groups.txt")) { FileTools.CreateFile(SaveDir + "groups.txt"); }
|
||||
if (!System.IO.File.Exists(SaveDir + "users.txt")) { FileTools.CreateFile(SaveDir + "users.txt"); }
|
||||
ConfigurationManager.WriteJsonConfiguration();
|
||||
ConfigurationManager.ReadJsonConfiguration();
|
||||
Netplay.serverPort = ConfigurationManager.serverPort;
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ namespace TShockAPI
|
|||
* */
|
||||
|
||||
void NpcHooks_OnStrikeNpc(NpcStrikeEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ConfigurationManager.infiniteInvasion)
|
||||
{
|
||||
|
|
@ -159,15 +157,8 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileTools.WriteError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void GetData(GetDataEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Main.netMode != 2) { return; }
|
||||
if (e.MsgID == 17)
|
||||
|
|
@ -332,15 +323,8 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileTools.WriteError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void OnGreetPlayer(int who, HandledEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Main.netMode != 2) { return; }
|
||||
int plr = who; //legacy support
|
||||
|
|
@ -361,15 +345,8 @@ namespace TShockAPI
|
|||
ShowUpdateReminder(who);
|
||||
e.Handled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileTools.WriteError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void OnChat(int ply, string msg, HandledEventArgs handler)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Main.netMode != 2) { return; }
|
||||
int x = (int)Main.player[ply].position.X;
|
||||
|
|
@ -402,15 +379,8 @@ namespace TShockAPI
|
|||
handler.Handled = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileTools.WriteError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void OnJoin(int ply, AllowEventArgs handler)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Main.netMode != 2) { return; }
|
||||
string ip = Tools.GetRealIP((Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)));
|
||||
|
|
@ -433,35 +403,21 @@ namespace TShockAPI
|
|||
players[ply] = new TSPlayer(ply);
|
||||
players[ply].group = Tools.GetGroupForIP(ip);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileTools.WriteError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPreInit()
|
||||
{
|
||||
try
|
||||
{
|
||||
FileTools.SetupConfig();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void OnPostInit()
|
||||
{
|
||||
}
|
||||
|
||||
void OnUpdate(GameTime time)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Main.netMode != 2) { return; }
|
||||
for (uint i = 0; i < Main.maxPlayers; i++)
|
||||
|
|
@ -487,11 +443,6 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileTools.WriteError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Useful stuff:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue