mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -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);
|
Entities.DespawnEntities(who, false);
|
||||||
who.group = Group.findPerm(LevelPermission.Banned);
|
who.group = Group.findPerm(LevelPermission.Banned);
|
||||||
who.color = who.group.color;
|
who.color = who.group.color;
|
||||||
Entities.SpawnEntities(who, false);
|
Entities.SpawnEntities(who, false);
|
||||||
}
|
}
|
||||||
|
@ -35,30 +35,40 @@ namespace MCGalaxy.Commands {
|
|||||||
string names = Server.whiteList.All().Concatenate(", ");
|
string names = Server.whiteList.All().Concatenate(", ");
|
||||||
Player.Message(p, "Whitelist: &f" + names); return;
|
Player.Message(p, "Whitelist: &f" + names); return;
|
||||||
}
|
}
|
||||||
if (player == "") { Help(p); return; }
|
if (player == "") { Add(p, action); return; }
|
||||||
|
|
||||||
if (action.CaselessEq("add")) {
|
if (action.CaselessEq("add")) {
|
||||||
if (Server.whiteList.Contains(player)) {
|
Add(p, player);
|
||||||
Player.Message(p, "&f" + player + " %Sis already on the whitelist!"); return;
|
} else if (action.CaselessEq("del") || action.CaselessEq("remove")) {
|
||||||
}
|
Remove(p, player);
|
||||||
|
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
Help(p);
|
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) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/whitelist <add/del> [player]");
|
Player.Message(p, "%T/whitelist <add/del> [player]");
|
||||||
|
@ -333,7 +333,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
if (!CheckWhitelist()) return;
|
if (!CheckWhitelist()) { Leave("This is a private server!", true); return; }
|
||||||
Group foundGrp = Group.findPlayerGroup(name);
|
Group foundGrp = Group.findPlayerGroup(name);
|
||||||
|
|
||||||
// ban check
|
// ban check
|
||||||
@ -341,16 +341,14 @@ namespace MCGalaxy {
|
|||||||
Kick(Server.defaultBanMessage, true); return;
|
Kick(Server.defaultBanMessage, true); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundGrp == Group.findPerm(LevelPermission.Banned)) {
|
if (foundGrp.Permission == LevelPermission.Banned) {
|
||||||
if (!Server.useWhitelist || !onWhitelist) {
|
string[] data = Ban.GetBanData(name);
|
||||||
string[] data = Ban.GetBanData(name);
|
if (data != null) {
|
||||||
if (data != null) {
|
Kick(Ban.FormatBan(data[0], data[1]), true);
|
||||||
Kick(Ban.FormatBan(data[0], data[1]), true);
|
} else {
|
||||||
} else {
|
Kick(Server.defaultBanMessage, true);
|
||||||
Kick(Server.defaultBanMessage, true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// maxplayer check
|
// maxplayer check
|
||||||
@ -439,27 +437,14 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CheckWhitelist() {
|
bool CheckWhitelist() {
|
||||||
if (!Server.useWhitelist) return true;
|
if (!Server.useWhitelist) return true;
|
||||||
|
if (Server.verify) return Server.whiteList.Contains(name);
|
||||||
|
|
||||||
if (Server.verify) {
|
// Verify names is off, check if the player is on the same IP.
|
||||||
if (Server.whiteList.Contains(name))
|
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||||
onWhitelist = true;
|
query.AddParam("@IP", ip);
|
||||||
} else {
|
using (DataTable ipQuery = Database.fillData(query, "SELECT Name FROM Players WHERE IP = @IP"))
|
||||||
// Verify Names is off. Gotta check the hard way.
|
return ipQuery.Rows.Contains(name) && Server.whiteList.Contains(name);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompleteLoginProcess() {
|
void CompleteLoginProcess() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user