mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-01 09:36:03 -04:00
Obsolete PlayerExtList.Add/AddOrReplace
This commit is contained in:
parent
fb4745e8fc
commit
a5c9eb45e1
@ -44,7 +44,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
|
||||
protected override void SetPlayerData(Player p, Player who, string args) {
|
||||
if (!ParseArgs(p, args, who)) return;
|
||||
Server.rotations.AddOrReplace(who.name, who.Rot.RotX + " " + who.Rot.RotZ);
|
||||
Server.rotations.Update(who.name, who.Rot.RotX + " " + who.Rot.RotZ);
|
||||
Server.rotations.Save();
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
}
|
||||
|
||||
if (!model.CaselessEq("humanoid")) {
|
||||
Server.models.AddOrReplace(who.name, model);
|
||||
Server.models.Update(who.name, model);
|
||||
} else {
|
||||
Server.models.Remove(who.name);
|
||||
}
|
||||
@ -70,7 +70,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
|
||||
if (!changedAxisScale) return;
|
||||
if (who.ScaleX != 0 || who.ScaleY != 0 || who.ScaleZ != 0) {
|
||||
Server.modelScales.AddOrReplace(who.name, who.ScaleX + " " + who.ScaleY + " " + who.ScaleZ);
|
||||
Server.modelScales.Update(who.name, who.ScaleX + " " + who.ScaleY + " " + who.ScaleZ);
|
||||
} else {
|
||||
Server.modelScales.Remove(who.name);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
p.Send(Packet.ClickDistance((short)packedDist));
|
||||
p.ReachDistance = dist;
|
||||
p.Message("Set your reach distance to {0} blocks.", dist);
|
||||
Server.reach.AddOrReplace(p.name, packedDist.ToString());
|
||||
Server.reach.Update(p.name, packedDist.ToString());
|
||||
Server.reach.Save();
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
if (skin == who.truename) {
|
||||
Server.skins.Remove(who.name);
|
||||
} else {
|
||||
Server.skins.AddOrReplace(who.name, skin);
|
||||
Server.skins.Update(who.name, skin);
|
||||
}
|
||||
Server.skins.Save();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy.Core {
|
||||
if (who != null) who.frozen = true;
|
||||
LogAction(e, who, "&bfrozen");
|
||||
|
||||
Server.frozen.AddOrReplace(e.Target, FormatModTaskData(e));
|
||||
Server.frozen.Update(e.Target, FormatModTaskData(e));
|
||||
ModerationTasks.FreezeCalcNextRun();
|
||||
Server.frozen.Save();
|
||||
}
|
||||
@ -84,7 +84,7 @@ namespace MCGalaxy.Core {
|
||||
if (who != null) who.muted = true;
|
||||
LogAction(e, who, "&8muted");
|
||||
|
||||
Server.muted.AddOrReplace(e.Target, FormatModTaskData(e));
|
||||
Server.muted.Update(e.Target, FormatModTaskData(e));
|
||||
ModerationTasks.MuteCalcNextRun();
|
||||
Server.muted.Save();
|
||||
}
|
||||
@ -107,7 +107,7 @@ namespace MCGalaxy.Core {
|
||||
if (e.Duration.Ticks != 0) {
|
||||
string banner = e.Actor.truename;
|
||||
DateTime end = DateTime.UtcNow.Add(e.Duration);
|
||||
Server.tempBans.AddOrReplace(e.Target, Ban.PackTempBanData(e.Reason, banner, end));
|
||||
Server.tempBans.Update(e.Target, Ban.PackTempBanData(e.Reason, banner, end));
|
||||
Server.tempBans.Save();
|
||||
|
||||
if (who != null) who.Kick("Banned for " + e.Duration.Shorten(true) + "." + e.ReasonSuffixed);
|
||||
@ -224,7 +224,7 @@ namespace MCGalaxy.Core {
|
||||
|
||||
static void AddTempRank(ModAction e, Group newRank) {
|
||||
string data = FormatModTaskData(e) + " " + e.TargetGroup.Name + " " + newRank.Name;
|
||||
Server.tempRanks.AddOrReplace(e.Target, data);
|
||||
Server.tempRanks.Update(e.Target, data);
|
||||
ModerationTasks.TemprankCalcNextRun();
|
||||
Server.tempRanks.Save();
|
||||
}
|
||||
|
@ -40,14 +40,22 @@ namespace MCGalaxy {
|
||||
lock (locker) return new List<string>(lines);
|
||||
}
|
||||
|
||||
/// <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, string data) {
|
||||
/// <summary> Sets the data associated with the given name. </summary>
|
||||
public void Update(string name, string data) {
|
||||
lock (locker) {
|
||||
names.Add(name); lines.Add(name + Separator + data);
|
||||
int idx = names.CaselessIndexOf(name);
|
||||
if (idx == -1) {
|
||||
names.Add(name); lines.Add(name + Separator + data);
|
||||
} else {
|
||||
lines[idx] = name + Separator + data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the given name was removed from this list. </summary>
|
||||
public bool Remove(string name) {
|
||||
lock (locker) {
|
||||
int idx = names.CaselessIndexOf(name);
|
||||
@ -59,22 +67,13 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the given name is in this list. </summary>
|
||||
public bool Contains(string name) {
|
||||
lock (locker)
|
||||
return names.CaselessContains(name);
|
||||
}
|
||||
|
||||
public void AddOrReplace(string name, string data) {
|
||||
lock (locker) {
|
||||
int idx = names.CaselessIndexOf(name);
|
||||
if (idx == -1) {
|
||||
names.Add(name); lines.Add(name + Separator + data);
|
||||
} else {
|
||||
lines[idx] = name + Separator + data;
|
||||
}
|
||||
}
|
||||
lock (locker) return names.CaselessContains(name);
|
||||
}
|
||||
|
||||
/// <summary> Retrieves the data associated with the given name. </summary>
|
||||
/// <remarks> Returns null if there is no data associated. </remarks>
|
||||
public string FindData(string name) {
|
||||
lock (locker) {
|
||||
int idx = names.CaselessIndexOf(name);
|
||||
@ -85,6 +84,13 @@ namespace MCGalaxy {
|
||||
return idx == -1 ? null : line.Substring(idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Obsolete("Use Update instead")]
|
||||
public void Add(string name, string data) { Update(name, data); }
|
||||
|
||||
[Obsolete("Use Update instead")]
|
||||
public void AddOrReplace(string name, string data) { Update(name, data); }
|
||||
|
||||
|
||||
public void Save() { Save(true); }
|
||||
@ -118,7 +124,7 @@ namespace MCGalaxy {
|
||||
while ((line = r.ReadLine()) != null) {
|
||||
list.lines.Add(line);
|
||||
int sepIndex = line.IndexOf(separator);
|
||||
string name = sepIndex >= 0 ? line.Substring(0, sepIndex) : line;
|
||||
string name = sepIndex >= 0 ? line.Substring(0, sepIndex) : line;
|
||||
list.names.Add(name);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ using System.IO;
|
||||
namespace MCGalaxy {
|
||||
|
||||
/// <summary> Represents a list of metadata about players. (such as rank info, ban info, notes). </summary>
|
||||
/// <remarks> Unlike other player lists, this list is NOT kept in memory. </remarks>
|
||||
public sealed class PlayerMetaList {
|
||||
|
||||
public readonly string file;
|
||||
|
Loading…
x
Reference in New Issue
Block a user