Removed all referneces to admin and replaced with group permissions
This commit is contained in:
parent
8d7a52ff9a
commit
362b2b776e
5 changed files with 7 additions and 65 deletions
|
|
@ -74,7 +74,7 @@ namespace TShockAPI
|
|||
{
|
||||
commands.Add(new Command("kick", "kick", new CommandDelegate(Kick)));
|
||||
commands.Add(new Command("ban", "ban", new CommandDelegate(Ban)));
|
||||
commands.Add(new Command("off", "power", new CommandDelegate(Off)));
|
||||
commands.Add(new Command("off", "maintenance", new CommandDelegate(Off)));
|
||||
commands.Add(new Command("reload", "cfg", new CommandDelegate(Reload)));
|
||||
commands.Add(new Command("dropmetor", "causeevents", new CommandDelegate(DropMeteor)));
|
||||
commands.Add(new Command("star", "causeevents", new CommandDelegate(Star)));
|
||||
|
|
@ -100,7 +100,7 @@ namespace TShockAPI
|
|||
commands.Add(new Command("kill", "kill", new CommandDelegate(Kill)));
|
||||
commands.Add(new Command("help", "", new CommandDelegate(Help)));
|
||||
commands.Add(new Command("slap", "pvpfun", new CommandDelegate(Slap)));
|
||||
commands.Add(new Command("off-nosave", "power", new CommandDelegate(OffNoSave)));
|
||||
commands.Add(new Command("off-nosave", "maintenance", new CommandDelegate(OffNoSave)));
|
||||
}
|
||||
|
||||
#region Command Methods
|
||||
|
|
@ -557,9 +557,8 @@ namespace TShockAPI
|
|||
|
||||
public static void Kill(CommandArgs args)
|
||||
{
|
||||
bool isadmin = TShock.players[args.PlayerID].IsAdmin(); ;
|
||||
var msgargs = Regex.Split(args.Message, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
|
||||
if (msgargs.Length == 2 && isadmin)
|
||||
if (msgargs.Length == 2)
|
||||
{
|
||||
int player = -1;
|
||||
player = Tools.FindPlayer((msgargs[1].TrimEnd('"')).TrimStart('"'));
|
||||
|
|
@ -567,11 +566,6 @@ namespace TShockAPI
|
|||
Tools.SendMessage(player, Tools.FindPlayer(args.PlayerID) + " just killed you!");
|
||||
TShock.KillMe(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
Tools.SendMessage(args.PlayerID, "You just suicided.");
|
||||
TShock.KillMe(args.PlayerID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Slap(CommandArgs args)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ namespace TShockAPI
|
|||
}
|
||||
if (!System.IO.File.Exists(SaveDir + "bans.txt")) { FileTools.CreateFile(SaveDir + "bans.txt"); }
|
||||
if (!System.IO.File.Exists(SaveDir + "cheaters.txt")) { FileTools.CreateFile(SaveDir + "cheaters.txt"); }
|
||||
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"))
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ namespace TShockAPI
|
|||
public Group group;
|
||||
|
||||
private int player;
|
||||
private bool admin;
|
||||
private bool adminSet;
|
||||
|
||||
public TSPlayer(int ply)
|
||||
{
|
||||
|
|
@ -30,16 +28,5 @@ namespace TShockAPI
|
|||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
public bool IsAdmin()
|
||||
{
|
||||
if (adminSet)
|
||||
{
|
||||
return admin;
|
||||
}
|
||||
admin = Tools.IsAdmin(player);
|
||||
adminSet = true;
|
||||
return admin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ namespace TShockAPI
|
|||
}
|
||||
if (type == 29 || type == 28)
|
||||
{
|
||||
if (!players[e.Msg.whoAmI].IsAdmin())
|
||||
if (!players[e.Msg.whoAmI].group.HasPermission("ignoregriefdetection"))
|
||||
{
|
||||
if (ConfigurationManager.kickBoom || ConfigurationManager.banBoom)
|
||||
{
|
||||
|
|
@ -338,7 +338,7 @@ namespace TShockAPI
|
|||
Main.player[who].hostile = true;
|
||||
NetMessage.SendData(30, -1, -1, "", who);
|
||||
}
|
||||
if (TShock.players[who].IsAdmin() && ConfigurationManager.infiniteInvasion && !ConfigurationManager.startedInvasion)
|
||||
if (TShock.players[who].group.HasPermission("causeevents") && ConfigurationManager.infiniteInvasion && !ConfigurationManager.startedInvasion)
|
||||
{
|
||||
StartInvasion();
|
||||
}
|
||||
|
|
@ -452,7 +452,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (!shownVersion)
|
||||
{
|
||||
if (TShock.players[ply].IsAdmin())
|
||||
if (TShock.players[ply].group.HasPermission("maintenance"))
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)");
|
||||
|
|
|
|||
|
|
@ -190,44 +190,6 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a player, reads admins.txt, and determines if their IP address is on that list.
|
||||
/// </summary>
|
||||
/// <param name="ply">int player</param>
|
||||
/// <returns>true/false</returns>
|
||||
public static bool IsAdmin(int ply)
|
||||
{
|
||||
string remoteEndPoint = Convert.ToString((Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
|
||||
string[] remoteEndPointIP = remoteEndPoint.Split(':');
|
||||
TextReader tr = new StreamReader(FileTools.SaveDir + "admins.txt");
|
||||
string adminlist = tr.ReadToEnd();
|
||||
tr.Close();
|
||||
if (adminlist.Contains(remoteEndPointIP[0]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a player based on their name, reads admins.txt, and determines if thier IP address is on that list.
|
||||
/// </summary>
|
||||
/// <param name="ply"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsAdmin(string ply)
|
||||
{
|
||||
string remoteEndPoint = Convert.ToString((Netplay.serverSock[Tools.FindPlayer(ply)].tcpClient.Client.RemoteEndPoint));
|
||||
string[] remoteEndPointIP = remoteEndPoint.Split(':');
|
||||
TextReader tr = new StreamReader(FileTools.SaveDir + "admins.txt");
|
||||
string adminlist = tr.ReadToEnd();
|
||||
tr.Close();
|
||||
if (adminlist.Contains(remoteEndPointIP[0]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kicks a player from the server.
|
||||
/// </summary>
|
||||
|
|
@ -265,7 +227,7 @@ namespace TShockAPI
|
|||
/// <param name="ply">int player</param>
|
||||
public static void HandleGriefer(int ply)
|
||||
{
|
||||
if (!TShock.players[ply].IsAdmin())
|
||||
if (!TShock.players[ply].group.HasPermission("ignoregriefdetection"))
|
||||
{
|
||||
string cheater = Tools.FindPlayer(ply);
|
||||
string ip = Tools.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue