diff --git a/.gitignore b/.gitignore index 1e2a6ac2..cd88c055 100644 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,6 @@ Thumbs.db *.sdf *.opensdf *.cache -*.txt *.pdb *.csproj.user */_ReSharper*/* diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index 91d7637e..daf4ffcc 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -152,6 +152,7 @@ namespace TShockAPI } return false; } + public FileTools() { } } } diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs new file mode 100644 index 00000000..d3b22e8a --- /dev/null +++ b/TShockAPI/Group.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TShockAPI +{ + public class Group + { + private string name; + private Group parent = null; + + public Group(string groupName, Group parentGroup = null) + { + name = groupName; + parent = parentGroup; + } + + public string GetName() + { + return name; + } + + public Group GetParent() + { + return parent; + } + + public bool HasPermission(string permission) + { + //TODO: implement this + return true; + } + } +} diff --git a/TShockAPI/Permission.cs b/TShockAPI/Permission.cs new file mode 100644 index 00000000..75460d61 --- /dev/null +++ b/TShockAPI/Permission.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TShockAPI +{ + class Permission + { + } +} diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 60103e5b..e098b04f 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -10,6 +10,7 @@ namespace TShockAPI public uint tileThreshold; public bool syncHP = false; public bool syncMP = false; + public Group group; private int player; private bool admin; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 203d58f3..92e8e2a5 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -22,7 +22,7 @@ namespace TShockAPI public static Dictionary admincommandList = new Dictionary(); public static Dictionary commandList = new Dictionary(); - + static bool[] BlacklistTiles; public override Version Version diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 7db2762a..3eede161 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -58,7 +58,9 @@ + + diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index 31b62775..c8b79911 100644 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -7,6 +7,8 @@ namespace TShockAPI { class Tools { + private static List groups; + /// /// Provides the real IP address from a RemoteEndPoint string that contains a port and an IP /// @@ -317,6 +319,39 @@ namespace TShockAPI tr.Close(); } + private static void LoadGroups() + { + } + + /// + /// Shows a MOTD to the player + /// + /// int player + public static Group GetGroup(string name) + { + //first attempt on cached groups + for (int i = 0; i < groups.Count; i++) + { + if (groups[i].GetName().Equals(name)) + { + return groups[i]; + } + } + //shit, it didnt work, reload and try again + LoadGroups(); + + for (int i = 0; i < groups.Count; i++) + { + if (groups[i].GetName().Equals(name)) + { + return groups[i]; + } + } + + //sigh :(, ok, you fucked up the config files, congrats. + return null; + } + public Tools() { } } } \ No newline at end of file diff --git a/TShockAPI/config/groups.txt b/TShockAPI/config/groups.txt new file mode 100644 index 00000000..26fc2642 --- /dev/null +++ b/TShockAPI/config/groups.txt @@ -0,0 +1,12 @@ +#Format +#name parent permisson1 permission2 permissionN +#if there is no parent, put null instead +#groups inherit permissions from their parents +#put a ! before a permission to negate it +#currently avaliable permissions: kick ban ignorecheatdetection +#Do not remove the group default +#Do not name a group SuperAdmin, that is hard-coded into the code, it grants total permissions +default null +admin default kick ban +trustedadmin admin ignorecheatdetection +newadmin admin !ban \ No newline at end of file diff --git a/TShockAPI/config/users.txt b/TShockAPI/config/users.txt new file mode 100644 index 00000000..b4e0aeb6 --- /dev/null +++ b/TShockAPI/config/users.txt @@ -0,0 +1,4 @@ +#format +#ip group +#see groups.txt for a list of groups +127.0.0.1 superadmin \ No newline at end of file