diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs
index d0525120..11cfcdf9 100644
--- a/TShockAPI/Group.cs
+++ b/TShockAPI/Group.cs
@@ -69,8 +69,8 @@ namespace TShockAPI
public class SuperAdminGroup : Group
{
- public SuperAdminGroup(string groupName, Group parentGroup = null)
- : base(groupName, parentGroup)
+ public SuperAdminGroup()
+ : base("superadmin")
{
}
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index c60c430f..17b3d8e9 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -15,6 +15,7 @@ GNU General Public License for more details.
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 Microsoft.Xna.Framework;
using Terraria;
@@ -23,7 +24,7 @@ namespace TShockAPI
{
public class TSPlayer
{
- public static readonly TSPlayer Server = new TSPlayer(new Player { name = "Server" });
+ public static readonly TSPlayer Server = new ServerPlayer();
public static readonly TSPlayer All = new TSPlayer(new Player { name = "All", whoAmi = -1 });
@@ -71,6 +72,7 @@ namespace TShockAPI
{
TilesDestroyed = new Dictionary();
TPlayer = ply;
+ Group = new Group("null");
}
public virtual void SendMessage(string msg)
@@ -89,4 +91,27 @@ namespace TShockAPI
}
}
+
+
+ public class ServerPlayer : TSPlayer
+ {
+ public ServerPlayer()
+ : base(new Player { name = "Server" })
+ {
+ Group = new SuperAdminGroup();
+ }
+
+ public override void SendMessage(string msg)
+ {
+ Console.WriteLine(msg);
+ }
+ public override void SendMessage(string msg, byte red, byte green, byte blue)
+ {
+ SendMessage(msg);
+ }
+ public override void SendMessage(string msg, Color color)
+ {
+ SendMessage(msg);
+ }
+ }
}
\ No newline at end of file
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 68bd481b..bffc9a78 100755
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -35,9 +35,9 @@ namespace TShockAPI
{
public static TSPlayer[] Players = new TSPlayer[Main.maxPlayers];
- public static readonly string SavePath = "./tshock/";
+ public static readonly string SavePath = "tshock";
- public static readonly Version VersionNum = new Version(2, 1, 0, 3);
+ public static readonly Version VersionNum = new Version(2, 1, 0, 4);
public static readonly string VersionCodename = "Forgot to increase the version.";
@@ -197,8 +197,37 @@ namespace TShockAPI
///
///
///
- private void ServerHooks_OnCommand(string cmd, HandledEventArgs e)
+ private void ServerHooks_OnCommand(string text, HandledEventArgs e)
{
+ if (text.StartsWith("/"))
+ {
+ text = text.Remove(0, 1);
+ var args = Commands.ParseParameters(text);
+ if (args.Count < 1)
+ return;
+
+ string scmd = args[0];
+ args.RemoveAt(0);
+
+ Command cmd = null;
+ for (int i = 0; i < Commands.ChatCommands.Count; i++)
+ {
+ if (Commands.ChatCommands[i].Name.Equals(scmd))
+ {
+ cmd = Commands.ChatCommands[i];
+ }
+ }
+
+ if (cmd == null)
+ {
+ TSPlayer.Server.SendMessage("That command does not exist, try /help", Color.Red);
+ }
+ else
+ {
+ cmd.Run(text, TSPlayer.Server, args);
+ }
+ e.Handled = true;
+ }
}
public override void DeInitialize()
@@ -616,9 +645,6 @@ namespace TShockAPI
return;
}
- int x = (int)Main.player[ply].position.X;
- int y = (int)Main.player[ply].position.Y;
-
if (text.StartsWith("/"))
{
text = text.Remove(0, 1);
diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs
index 88bc3435..7103009c 100755
--- a/TShockAPI/Tools.cs
+++ b/TShockAPI/Tools.cs
@@ -338,7 +338,7 @@ namespace TShockAPI
public static void LoadGroups()
{
groups = new List();
- groups.Add(new SuperAdminGroup("superadmin"));
+ groups.Add(new SuperAdminGroup());
StreamReader sr = new StreamReader(FileTools.GroupsPath);
string data = sr.ReadToEnd();