Removed all referneces to admin and replaced with group permissions

This commit is contained in:
Maverick Motherfucker 2011-06-04 13:35:52 -07:00
parent 8d7a52ff9a
commit 362b2b776e
5 changed files with 7 additions and 65 deletions

View file

@ -74,7 +74,7 @@ namespace TShockAPI
{ {
commands.Add(new Command("kick", "kick", new CommandDelegate(Kick))); commands.Add(new Command("kick", "kick", new CommandDelegate(Kick)));
commands.Add(new Command("ban", "ban", new CommandDelegate(Ban))); 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("reload", "cfg", new CommandDelegate(Reload)));
commands.Add(new Command("dropmetor", "causeevents", new CommandDelegate(DropMeteor))); commands.Add(new Command("dropmetor", "causeevents", new CommandDelegate(DropMeteor)));
commands.Add(new Command("star", "causeevents", new CommandDelegate(Star))); 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("kill", "kill", new CommandDelegate(Kill)));
commands.Add(new Command("help", "", new CommandDelegate(Help))); commands.Add(new Command("help", "", new CommandDelegate(Help)));
commands.Add(new Command("slap", "pvpfun", new CommandDelegate(Slap))); 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 #region Command Methods
@ -557,9 +557,8 @@ namespace TShockAPI
public static void Kill(CommandArgs args) public static void Kill(CommandArgs args)
{ {
bool isadmin = TShock.players[args.PlayerID].IsAdmin(); ;
var msgargs = Regex.Split(args.Message, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); var msgargs = Regex.Split(args.Message, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
if (msgargs.Length == 2 && isadmin) if (msgargs.Length == 2)
{ {
int player = -1; int player = -1;
player = Tools.FindPlayer((msgargs[1].TrimEnd('"')).TrimStart('"')); player = Tools.FindPlayer((msgargs[1].TrimEnd('"')).TrimStart('"'));
@ -567,11 +566,6 @@ namespace TShockAPI
Tools.SendMessage(player, Tools.FindPlayer(args.PlayerID) + " just killed you!"); Tools.SendMessage(player, Tools.FindPlayer(args.PlayerID) + " just killed you!");
TShock.KillMe(player); TShock.KillMe(player);
} }
else
{
Tools.SendMessage(args.PlayerID, "You just suicided.");
TShock.KillMe(args.PlayerID);
}
} }
public static void Slap(CommandArgs args) public static void Slap(CommandArgs args)

View file

@ -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 + "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 + "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 + "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 + "whitelist.txt")) { FileTools.CreateFile(SaveDir + "whitelist.txt"); }
if (!System.IO.File.Exists(SaveDir + "groups.txt")) if (!System.IO.File.Exists(SaveDir + "groups.txt"))

View file

@ -13,8 +13,6 @@ namespace TShockAPI
public Group group; public Group group;
private int player; private int player;
private bool admin;
private bool adminSet;
public TSPlayer(int ply) public TSPlayer(int ply)
{ {
@ -30,16 +28,5 @@ namespace TShockAPI
{ {
return player; return player;
} }
public bool IsAdmin()
{
if (adminSet)
{
return admin;
}
admin = Tools.IsAdmin(player);
adminSet = true;
return admin;
}
} }
} }

View file

@ -290,7 +290,7 @@ namespace TShockAPI
} }
if (type == 29 || type == 28) if (type == 29 || type == 28)
{ {
if (!players[e.Msg.whoAmI].IsAdmin()) if (!players[e.Msg.whoAmI].group.HasPermission("ignoregriefdetection"))
{ {
if (ConfigurationManager.kickBoom || ConfigurationManager.banBoom) if (ConfigurationManager.kickBoom || ConfigurationManager.banBoom)
{ {
@ -338,7 +338,7 @@ namespace TShockAPI
Main.player[who].hostile = true; Main.player[who].hostile = true;
NetMessage.SendData(30, -1, -1, "", who); 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(); StartInvasion();
} }
@ -452,7 +452,7 @@ namespace TShockAPI
{ {
if (!shownVersion) if (!shownVersion)
{ {
if (TShock.players[ply].IsAdmin()) if (TShock.players[ply].group.HasPermission("maintenance"))
{ {
WebClient client = new WebClient(); 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;)"); client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705;)");

View file

@ -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> /// <summary>
/// Kicks a player from the server. /// Kicks a player from the server.
/// </summary> /// </summary>
@ -265,7 +227,7 @@ namespace TShockAPI
/// <param name="ply">int player</param> /// <param name="ply">int player</param>
public static void HandleGriefer(int ply) public static void HandleGriefer(int ply)
{ {
if (!TShock.players[ply].IsAdmin()) if (!TShock.players[ply].group.HasPermission("ignoregriefdetection"))
{ {
string cheater = Tools.FindPlayer(ply); string cheater = Tools.FindPlayer(ply);
string ip = Tools.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)); string ip = Tools.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));