mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Now /unban partially matches player names.
This commit is contained in:
parent
cb51be2d6a
commit
7116c49e8f
@ -15,8 +15,7 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdUnban : Command {
|
||||
public override string name { get { return "unban"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
@ -39,31 +38,34 @@ namespace MCGalaxy.Commands {
|
||||
string srcFull = p == null ? "(console)" : p.ColoredName + "%S";
|
||||
string src = p == null ? "(console)" : p.name;
|
||||
|
||||
if (!Group.IsBanned(name)) {
|
||||
foreach (Server.TempBan tban in Server.tempBans) {
|
||||
if (!tban.name.CaselessEq(name)) continue;
|
||||
|
||||
Server.tempBans.Remove(tban);
|
||||
Player.GlobalMessage(name + " had their temporary ban lifted by " + srcFull + ".");
|
||||
Server.s.Log("UNBANNED: " + name + " by " + src);
|
||||
Server.IRC.Say(name + " was unbanned by " + src + ".");
|
||||
return;
|
||||
}
|
||||
Player.Message(p, "Player \"" + name + "\" is not banned.");
|
||||
} else {
|
||||
Player.GlobalMessage(name + " was &8(unbanned) %Sby " + srcFull + ".");
|
||||
// Check tempbans first
|
||||
foreach (Server.TempBan tban in Server.tempBans) {
|
||||
if (!tban.name.CaselessEq(name)) continue;
|
||||
|
||||
Server.tempBans.Remove(tban);
|
||||
Player.GlobalMessage(name + " had their temporary ban lifted by " + srcFull + ".");
|
||||
Server.s.Log("UNBANNED: " + name + " by " + src);
|
||||
Server.IRC.Say(name + " was unbanned by " + src + ".");
|
||||
|
||||
Ban.UnbanPlayer(p, name, reason);
|
||||
Group.findPerm(LevelPermission.Banned).playerList.Remove(name);
|
||||
Group.findPerm(LevelPermission.Banned).playerList.Save();
|
||||
|
||||
if (who != null) {
|
||||
who.group = Group.standard; who.color = who.group.color;
|
||||
Entities.GlobalDespawn(who, false);
|
||||
Entities.GlobalSpawn(who, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Group banned = Group.findPerm(LevelPermission.Banned);
|
||||
int matches = 0;
|
||||
name = banned.playerList.FindMatches(p, name, "banned players", out matches);
|
||||
if (name == null) return;
|
||||
|
||||
Player.GlobalMessage(name + " was &8(unbanned) %Sby " + srcFull + ".");
|
||||
Server.s.Log("UNBANNED: " + name + " by " + src);
|
||||
Server.IRC.Say(name + " was unbanned by " + src + ".");
|
||||
|
||||
Ban.UnbanPlayer(p, name, reason);
|
||||
Group.findPerm(LevelPermission.Banned).playerList.Remove(name);
|
||||
Group.findPerm(LevelPermission.Banned).playerList.Save();
|
||||
|
||||
if (who != null) {
|
||||
who.group = Group.standard; who.color = who.group.color;
|
||||
Entities.GlobalDespawn(who, false);
|
||||
Entities.GlobalSpawn(who, false);
|
||||
}
|
||||
|
||||
string ip = PlayerInfo.FindIP(name);
|
||||
|
@ -382,7 +382,8 @@ namespace MCGalaxy {
|
||||
object locker = ThreadSafeCache.DBCache.Get(name);
|
||||
lock (locker) {
|
||||
LevelDB.LoadZones(level, name);
|
||||
LevelDB.LoadMetadata(level, name);
|
||||
LevelDB.LoadPortals(level, name);
|
||||
LevelDB.LoadMessages(level, name);
|
||||
}
|
||||
|
||||
Server.s.Log(string.Format("Level \"{0}\" loaded.", level.name));
|
||||
|
@ -21,7 +21,7 @@ using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MCGalaxy {
|
||||
public sealed class PlayerList {
|
||||
public sealed class PlayerList {
|
||||
string path;
|
||||
List<string> players = new List<string>();
|
||||
readonly object locker = new object();
|
||||
@ -60,6 +60,13 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public string FindMatches(Player p, string name, string type, out int matches) {
|
||||
lock (locker) {
|
||||
return Extensions.FindMatches<string>(p, name, out matches, players,
|
||||
n => true, n => n, type, 20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Save() { Save(true); }
|
||||
public void Save(bool console) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user