mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fixes and cleanup for whitelist code.
Can no longer join when you are on the whitelist but are banned, fix whitelist not saving when adding/removing someone from console, /whitelist [name] is now implicitly treated as /whitelist add [name].
This commit is contained in:
parent
96d6ac3029
commit
9b1fc58bfe
@ -62,7 +62,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
|
||||
Entities.DespawnEntities(who, false);
|
||||
who.group = Group.findPerm(LevelPermission.Banned);
|
||||
who.group = Group.findPerm(LevelPermission.Banned);
|
||||
who.color = who.group.color;
|
||||
Entities.SpawnEntities(who, false);
|
||||
}
|
||||
|
@ -35,30 +35,40 @@ namespace MCGalaxy.Commands {
|
||||
string names = Server.whiteList.All().Concatenate(", ");
|
||||
Player.Message(p, "Whitelist: &f" + names); return;
|
||||
}
|
||||
if (player == "") { Help(p); return; }
|
||||
if (player == "") { Add(p, action); return; }
|
||||
|
||||
if (action.CaselessEq("add")) {
|
||||
if (Server.whiteList.Contains(player)) {
|
||||
Player.Message(p, "&f" + player + " %Sis already on the whitelist!"); return;
|
||||
}
|
||||
|
||||
Server.whiteList.Add(player);
|
||||
Chat.GlobalMessageOps(p.ColoredName + " %Sadded &f" + player + " %Sto the whitelist.");
|
||||
Server.whiteList.Save();
|
||||
Server.s.Log("WHITELIST: Added " + player);
|
||||
} else if (action.CaselessEq("del")) {
|
||||
if (!Server.whiteList.Contains(player)) {
|
||||
Player.Message(p, "&f" + player + " %Sis not on the whitelist!"); return;
|
||||
}
|
||||
|
||||
Server.whiteList.Remove(player);
|
||||
Chat.GlobalMessageOps(p.ColoredName + " %Sremoved &f" + player + " %Sfrom the whitelist.");
|
||||
Server.whiteList.Save();
|
||||
Server.s.Log("WHITELIST: Removed " + player);
|
||||
Add(p, player);
|
||||
} else if (action.CaselessEq("del") || action.CaselessEq("remove")) {
|
||||
Remove(p, player);
|
||||
} else {
|
||||
Help(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void Add(Player p, string player) {
|
||||
if (Server.whiteList.Contains(player)) {
|
||||
Player.Message(p, "&f" + player + " %Sis already on the whitelist!"); return;
|
||||
}
|
||||
|
||||
Server.whiteList.Add(player);
|
||||
string src = p == null ? "(console)" : p.ColoredName;
|
||||
Chat.GlobalMessageOps(src + " %Sadded &f" + player + " %Sto the whitelist.");
|
||||
Server.whiteList.Save();
|
||||
Server.s.Log("WHITELIST: Added " + player);
|
||||
}
|
||||
|
||||
static void Remove(Player p, string player) {
|
||||
if (!Server.whiteList.Contains(player)) {
|
||||
Player.Message(p, "&f" + player + " %Sis not on the whitelist!"); return;
|
||||
}
|
||||
|
||||
Server.whiteList.Remove(player);
|
||||
string src = p == null ? "(console)" : p.ColoredName;
|
||||
Chat.GlobalMessageOps(src + " %Sremoved &f" + player + " %Sfrom the whitelist.");
|
||||
Server.whiteList.Save();
|
||||
Server.s.Log("WHITELIST: Removed " + player);
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/whitelist <add/del> [player]");
|
||||
|
@ -333,7 +333,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
} catch { }
|
||||
|
||||
if (!CheckWhitelist()) return;
|
||||
if (!CheckWhitelist()) { Leave("This is a private server!", true); return; }
|
||||
Group foundGrp = Group.findPlayerGroup(name);
|
||||
|
||||
// ban check
|
||||
@ -341,16 +341,14 @@ namespace MCGalaxy {
|
||||
Kick(Server.defaultBanMessage, true); return;
|
||||
}
|
||||
|
||||
if (foundGrp == Group.findPerm(LevelPermission.Banned)) {
|
||||
if (!Server.useWhitelist || !onWhitelist) {
|
||||
string[] data = Ban.GetBanData(name);
|
||||
if (data != null) {
|
||||
Kick(Ban.FormatBan(data[0], data[1]), true);
|
||||
} else {
|
||||
Kick(Server.defaultBanMessage, true);
|
||||
}
|
||||
return;
|
||||
if (foundGrp.Permission == LevelPermission.Banned) {
|
||||
string[] data = Ban.GetBanData(name);
|
||||
if (data != null) {
|
||||
Kick(Ban.FormatBan(data[0], data[1]), true);
|
||||
} else {
|
||||
Kick(Server.defaultBanMessage, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// maxplayer check
|
||||
@ -439,27 +437,14 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
bool CheckWhitelist() {
|
||||
if (!Server.useWhitelist) return true;
|
||||
if (!Server.useWhitelist) return true;
|
||||
if (Server.verify) return Server.whiteList.Contains(name);
|
||||
|
||||
if (Server.verify) {
|
||||
if (Server.whiteList.Contains(name))
|
||||
onWhitelist = true;
|
||||
} else {
|
||||
// Verify Names is off. Gotta check the hard way.
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@IP", ip);
|
||||
DataTable ipQuery = Database.fillData(query, "SELECT Name FROM Players WHERE IP = @IP");
|
||||
|
||||
if (ipQuery.Rows.Count > 0) {
|
||||
if (ipQuery.Rows.Contains(name) && Server.whiteList.Contains(name)) {
|
||||
onWhitelist = true;
|
||||
}
|
||||
}
|
||||
ipQuery.Dispose();
|
||||
}
|
||||
if (!onWhitelist)
|
||||
Leave("This is a private server!", true); //i think someone forgot this?
|
||||
return onWhitelist;
|
||||
// Verify names is off, check if the player is on the same IP.
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@IP", ip);
|
||||
using (DataTable ipQuery = Database.fillData(query, "SELECT Name FROM Players WHERE IP = @IP"))
|
||||
return ipQuery.Rows.Contains(name) && Server.whiteList.Contains(name);
|
||||
}
|
||||
|
||||
void CompleteLoginProcess() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user