mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-01 01:23:12 -04:00
Obsolete PlayerList.AddUnique
This commit is contained in:
parent
aac7b7c99b
commit
fb4745e8fc
@ -26,7 +26,7 @@ namespace MCGalaxy.Commands.Chatting {
|
||||
p.parseEmotes = !p.parseEmotes;
|
||||
bool addToList = p.parseEmotes != Server.Config.ParseEmotes;
|
||||
if (!addToList) Server.noEmotes.Remove(p.name);
|
||||
else Server.noEmotes.AddUnique(p.name);
|
||||
else Server.noEmotes.Add(p.name);
|
||||
Server.noEmotes.Save();
|
||||
p.Message("Emote parsing is {0}.", p.parseEmotes ? "enabled" : "disabled");
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace MCGalaxy.Commands.Info {
|
||||
if (!Server.Config.AgreeToRulesOnEntry) { p.Message("agree-to-rules-on-entry is not enabled."); return; }
|
||||
if (!p.hasreadrules) { p.Message("&9You must read %T/Rules &9before agreeing."); return; }
|
||||
|
||||
if (!Server.agreed.AddUnique(p.name)) {
|
||||
if (!Server.agreed.Add(p.name)) {
|
||||
p.Message("You have already agreed to the rules.");
|
||||
} else {
|
||||
p.agreed = true;
|
||||
|
@ -61,7 +61,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
|
||||
if (!p.opchat) opchat.Use(p, "", data);
|
||||
Server.hidden.AddUnique(p.name);
|
||||
Server.hidden.Add(p.name);
|
||||
} else {
|
||||
AnnounceOps(p, "To Ops -λNICK%S- is now &fvisible");
|
||||
p.hideRank = LevelPermission.Banned;
|
||||
|
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
case "add":
|
||||
if (parts.Length < 2) { p.Message("You need to provide a name to add."); return; }
|
||||
|
||||
if (!Server.ircControllers.AddUnique(parts[1])) {
|
||||
if (!Server.ircControllers.Add(parts[1])) {
|
||||
p.Message(parts[1] + " is already an IRC controller.");
|
||||
} else {
|
||||
Server.ircControllers.Save();
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
name = PlayerInfo.FindMatchesPreferOnline(p, name);
|
||||
if (name == null) return;
|
||||
|
||||
if (!Server.vip.AddUnique(name)) {
|
||||
if (!Server.vip.Add(name)) {
|
||||
p.Message(PlayerInfo.GetColoredName(p, name) + " %Sis already a VIP.");
|
||||
} else {
|
||||
Server.vip.Save();
|
||||
|
@ -47,7 +47,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
}
|
||||
|
||||
static void Add(Player p, string player) {
|
||||
if (!Server.whiteList.AddUnique(player)) {
|
||||
if (!Server.whiteList.Add(player)) {
|
||||
p.Message(player + " %Sis already on the whitelist!"); return;
|
||||
} else {
|
||||
Chat.MessageFromOps(p, "λNICK %Sadded &f" + player + " %Sto the whitelist.");
|
||||
|
@ -35,16 +35,13 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
map = Matcher.FindMaps(p, map);
|
||||
if (map == null) return;
|
||||
|
||||
bool unlocking = Server.lockdown.Contains(map);
|
||||
string action = unlocking ? "unlocked" : "locked";
|
||||
Chat.MessageGlobal("Map " + map + " was " + action);
|
||||
|
||||
if (unlocking) {
|
||||
Server.lockdown.Remove(map);
|
||||
|
||||
if (Server.lockdown.Remove(map)) {
|
||||
Chat.MessageGlobal("Map " + map + " was unlocked");
|
||||
Chat.MessageFromOps(p, "Map " + map + " unlocked by: λNICK");
|
||||
} else {
|
||||
Server.lockdown.AddUnique(map);
|
||||
Server.lockdown.Add(map);
|
||||
Chat.MessageGlobal("Map " + map + " was locked");
|
||||
Chat.MessageFromOps(p, "Map " + map + " locked by: λNICK");
|
||||
}
|
||||
Server.lockdown.Save();
|
||||
|
@ -56,7 +56,7 @@ namespace MCGalaxy.DB {
|
||||
|
||||
/// <summary> Returns a non-database ID for the given name </summary>
|
||||
public static int InvalidNameID(string name) {
|
||||
bool added = Server.invalidIds.AddUnique(name);
|
||||
bool added = Server.invalidIds.Add(name);
|
||||
if (added) Server.invalidIds.Save();
|
||||
|
||||
int index = Server.invalidIds.IndexOf(name);
|
||||
|
@ -23,7 +23,7 @@ using System.Text;
|
||||
namespace MCGalaxy {
|
||||
|
||||
/// <summary> Represents a list of player names and simple associated data. Case insensitive. Thread safe. </summary>
|
||||
public sealed class PlayerExtList {
|
||||
public class PlayerExtList {
|
||||
public char Separator = ' ';
|
||||
public string Path;
|
||||
|
||||
|
@ -23,7 +23,7 @@ using System.Text;
|
||||
namespace MCGalaxy {
|
||||
|
||||
/// <summary> Represents a list of player names. Case insensitive. Thread safe. </summary>
|
||||
public sealed class PlayerList {
|
||||
public class PlayerList {
|
||||
public string Path;
|
||||
|
||||
List<string> names = new List<string>();
|
||||
@ -37,27 +37,11 @@ namespace MCGalaxy {
|
||||
lock (locker) return new List<string>(names);
|
||||
}
|
||||
|
||||
/// <summary> Returns number of names that are in this list. </summary>
|
||||
public int Count { get { lock (locker) return names.Count; } }
|
||||
|
||||
public void Add(string name) {
|
||||
lock (locker) names.Add(name);
|
||||
}
|
||||
|
||||
public bool Remove(string name) {
|
||||
lock (locker) return names.CaselessRemove(name);
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the given name is caselessly in this list. </summary>
|
||||
public bool Contains(string name) {
|
||||
lock (locker) return names.CaselessContains(name);
|
||||
}
|
||||
|
||||
/// <summary> Removes all names from this list. </summary>
|
||||
public void Clear() {
|
||||
lock (locker) names.Clear();
|
||||
}
|
||||
|
||||
public bool AddUnique(string name) {
|
||||
/// <summary> Returns whether the given name was actually added to this list. </summary>
|
||||
public bool Add(string name) {
|
||||
lock (locker) {
|
||||
int idx = names.CaselessIndexOf(name);
|
||||
if (idx >= 0) return false;
|
||||
@ -66,8 +50,26 @@ namespace MCGalaxy {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the given name was removed from this list. </summary>
|
||||
public bool Remove(string name) {
|
||||
lock (locker) return names.CaselessRemove(name);
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the given name is in this list. </summary>
|
||||
public bool Contains(string name) {
|
||||
lock (locker) return names.CaselessContains(name);
|
||||
}
|
||||
|
||||
/// <summary> Removes all names from this list. </summary>
|
||||
public void Clear() {
|
||||
lock (locker) names.Clear();
|
||||
}
|
||||
|
||||
|
||||
[Obsolete("Use Add instead")]
|
||||
public bool AddUnique(string name) { return Add(name); }
|
||||
|
||||
// only used for NameConverter
|
||||
internal int IndexOf(string name) {
|
||||
lock (locker) return names.CaselessIndexOf(name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user