Added code to convey idea before I write all of it out, also added default config files, everything is subject to change
This commit is contained in:
parent
d0fe76090d
commit
bb2e9559f0
10 changed files with 102 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -44,7 +44,6 @@ Thumbs.db
|
|||
*.sdf
|
||||
*.opensdf
|
||||
*.cache
|
||||
*.txt
|
||||
*.pdb
|
||||
*.csproj.user
|
||||
*/_ReSharper*/*
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ namespace TShockAPI
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public FileTools() { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
TShockAPI/Group.cs
Normal file
35
TShockAPI/Group.cs
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
TShockAPI/Permission.cs
Normal file
11
TShockAPI/Permission.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
class Permission
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace TShockAPI
|
|||
public static Dictionary<string, Commands.CommandDelegate> admincommandList = new Dictionary<string, Commands.CommandDelegate>();
|
||||
|
||||
public static Dictionary<string, Commands.CommandDelegate> commandList = new Dictionary<string, Commands.CommandDelegate>();
|
||||
|
||||
|
||||
static bool[] BlacklistTiles;
|
||||
|
||||
public override Version Version
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@
|
|||
<Compile Include="ConfigFile.cs" />
|
||||
<Compile Include="ConfigurationManager.cs" />
|
||||
<Compile Include="FileTools.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="Permission.cs" />
|
||||
<Compile Include="Tools.cs" />
|
||||
<Compile Include="TShock.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ namespace TShockAPI
|
|||
{
|
||||
class Tools
|
||||
{
|
||||
private static List<Group> groups;
|
||||
|
||||
/// <summary>
|
||||
/// Provides the real IP address from a RemoteEndPoint string that contains a port and an IP
|
||||
/// </summary>
|
||||
|
|
@ -317,6 +319,39 @@ namespace TShockAPI
|
|||
tr.Close();
|
||||
}
|
||||
|
||||
private static void LoadGroups()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a MOTD to the player
|
||||
/// </summary>
|
||||
/// <param name="ply">int player</param>
|
||||
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() { }
|
||||
}
|
||||
}
|
||||
12
TShockAPI/config/groups.txt
Normal file
12
TShockAPI/config/groups.txt
Normal file
|
|
@ -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
|
||||
4
TShockAPI/config/users.txt
Normal file
4
TShockAPI/config/users.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#format
|
||||
#ip group
|
||||
#see groups.txt for a list of groups
|
||||
127.0.0.1 superadmin
|
||||
Loading…
Add table
Add a link
Reference in a new issue