Console can now use ingame commands. Although they are the chat commands so right now some wont work like the ones that spawn bosses at you, etc.
This commit is contained in:
parent
f31bae459e
commit
e9dd445055
4 changed files with 61 additions and 10 deletions
|
|
@ -69,8 +69,8 @@ namespace TShockAPI
|
||||||
|
|
||||||
public class SuperAdminGroup : Group
|
public class SuperAdminGroup : Group
|
||||||
{
|
{
|
||||||
public SuperAdminGroup(string groupName, Group parentGroup = null)
|
public SuperAdminGroup()
|
||||||
: base(groupName, parentGroup)
|
: base("superadmin")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
|
@ -23,7 +24,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
public class TSPlayer
|
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 });
|
public static readonly TSPlayer All = new TSPlayer(new Player { name = "All", whoAmi = -1 });
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -71,6 +72,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
TilesDestroyed = new Dictionary<Vector2, Tile>();
|
||||||
TPlayer = ply;
|
TPlayer = ply;
|
||||||
|
Group = new Group("null");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SendMessage(string msg)
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,9 +35,9 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
public static TSPlayer[] Players = new TSPlayer[Main.maxPlayers];
|
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.";
|
public static readonly string VersionCodename = "Forgot to increase the version.";
|
||||||
|
|
||||||
|
|
@ -197,8 +197,37 @@ namespace TShockAPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmd"></param>
|
/// <param name="cmd"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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()
|
public override void DeInitialize()
|
||||||
|
|
@ -616,9 +645,6 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = (int)Main.player[ply].position.X;
|
|
||||||
int y = (int)Main.player[ply].position.Y;
|
|
||||||
|
|
||||||
if (text.StartsWith("/"))
|
if (text.StartsWith("/"))
|
||||||
{
|
{
|
||||||
text = text.Remove(0, 1);
|
text = text.Remove(0, 1);
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ namespace TShockAPI
|
||||||
public static void LoadGroups()
|
public static void LoadGroups()
|
||||||
{
|
{
|
||||||
groups = new List<Group>();
|
groups = new List<Group>();
|
||||||
groups.Add(new SuperAdminGroup("superadmin"));
|
groups.Add(new SuperAdminGroup());
|
||||||
|
|
||||||
StreamReader sr = new StreamReader(FileTools.GroupsPath);
|
StreamReader sr = new StreamReader(FileTools.GroupsPath);
|
||||||
string data = sr.ReadToEnd();
|
string data = sr.ReadToEnd();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue