Persist /hide status between sessions, closes #171. (Thanks FabTheZen)

This commit is contained in:
UnknownShadow200 2016-05-18 19:52:56 +10:00
parent a2164015ec
commit 6693443cdc
8 changed files with 47 additions and 38 deletions

View File

@ -67,7 +67,7 @@ namespace MCGalaxy.Commands {
if (unignore != null) {
p.listignored.Remove(unignore);
Player.Message(p, "No longer ignoring &a{0}", unignore);
Player.Message(p, "&aNo longer ignoring {0}", unignore);
} else {
int matches = 0;
Player who = PlayerInfo.FindOrShowMatches(p, action);
@ -80,10 +80,10 @@ namespace MCGalaxy.Commands {
if (p.listignored.Contains(who.name)) {
p.listignored.Remove(who.name);
Player.Message(p, "No longer ignoring &a{0}", who.DisplayName);
Player.Message(p, "&aNo longer ignoring {0}", who.ColoredName);
} else {
p.listignored.Add(who.name);
Player.Message(p, "Now ignoring &c{0}", who.DisplayName);
Player.Message(p, "&cNow ignoring {0}", who.ColoredName);
}
}
}

View File

@ -101,9 +101,9 @@ namespace MCGalaxy.Commands
}
static void AddStates(Player pl, ref string name) {
if (pl.hidden) name += "(hidden)";
if (pl.muted) name += "(muted)";
if (pl.frozen) name += "(frozen)";
if (pl.hidden) name += "-hidden";
if (pl.muted) name += "-muted";
if (pl.frozen) name += "-freeze";
if (pl.Game.Referee) name += "-ref";
if (pl.IsAfk) name += "-afk";
}

View File

@ -67,10 +67,12 @@ namespace MCGalaxy.Commands
Player.SendChatFrom(p, "&c- " + p.FullName + " %S" + discMsg, false);
Server.IRC.Say(p.DisplayName + " left the game (" + discMsg + ")");
if (messageOps && !p.opchat) opchat.Use(p, message);
Server.Hidden.Append(p.name);
} else {
Entities.GlobalSpawn(p, false);
p.hidden = false;
p.otherRankHidden = false;
p.oHideRank = LevelPermission.Null;
if (messageOps)
Chat.GlobalMessageAdmins("To Admins -" + p.ColoredName + "%S- is now &fvisible%S.");
@ -78,6 +80,7 @@ namespace MCGalaxy.Commands
Server.IRC.Say(p.DisplayName + " joined the game");
if (messageOps && p.opchat) opchat.Use(p, message);
if (p.adminchat) adminchat.Use(p, message);
Server.Hidden.DeleteStartsWith(p.name);
}
}

View File

@ -161,23 +161,23 @@ namespace MCGalaxy {
/// <summary> Returns whether the given player is able to see the other player (e.g. in /who). </summary>
public static bool CanSee(Player p, Player who) {
if (p == null || !who.hidden || p == who) return true;
if (who.otherRankHidden) return p.group.Permission >= who.oHideRank;
return p.group.Permission > who.group.Permission;
public static bool CanSee(Player p, Player target) {
if (p == null || !target.hidden || p == target) return true;
if (target.otherRankHidden) return p.group.Permission >= target.oHideRank;
return p.group.Permission > target.group.Permission;
}
/// <summary> Returns whether the given player is able to see the other player as an in-game entity. </summary>
public static bool CanSeeEntity(Player p, Player who) {
bool mayBeHidden = who.hidden;
mayBeHidden |= (who.Game.Referee || who.Game.Invisible) && Server.zombie.Running;
if (p == null || !mayBeHidden || p == who) return true;
if (who.Game.Referee && !p.Game.Referee
public static bool CanSeeEntity(Player p, Player target) {
bool mayBeHidden = target.hidden;
mayBeHidden |= (target.Game.Referee || target.Game.Invisible) && Server.zombie.Running;
if (p == null || !mayBeHidden || p == target) return true;
if (target.Game.Referee && !p.Game.Referee
&& Server.zombie.Running) return false;
if (who.Game.Invisible && !p.Game.Referee
if (target.Game.Invisible && !p.Game.Referee
&& Server.zombie.Running) return false;
if (who.otherRankHidden) return p.group.Permission >= who.oHideRank;
return p.group.Permission >= who.group.Permission;
if (target.otherRankHidden) return p.group.Permission >= target.oHideRank;
return p.group.Permission >= target.group.Permission;
}
/// <summary> Updates the model of the entity with the specified id to all other players. </summary>

View File

@ -531,16 +531,20 @@ namespace MCGalaxy {
adminpen = true;
if (emoteList.Contains(name)) parseSmiley = false;
string joinm = "&a+ " + FullName + " %S" + PlayerDB.GetLoginMessage(this);
if (group.Permission < Server.adminchatperm || !Server.adminsjoinsilent) {
if ((Server.guestJoinNotify && group.Permission <= LevelPermission.Guest) || group.Permission > LevelPermission.Guest) {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { Player.Message(pl, joinm); }
}
}
hidden = group.CanExecute("hide") && Server.Hidden.Find(name).FirstOrDefault() != null;
if (hidden) SendMessage("&8Reminder: You are still hidden.");
if (group.Permission >= Server.adminchatperm && Server.adminsjoinsilent) {
hidden = true;
adminchat = true;
hidden = true; adminchat = true;
}
string joinm = "&a+ " + FullName + " %S" + PlayerDB.GetLoginMessage(this);
if (hidden) joinm = "&8(hidden)" + joinm;
const LevelPermission perm = LevelPermission.Guest;
if (group.Permission > perm || (Server.guestJoinNotify && group.Permission <= perm)) {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (Entities.CanSee(pl, this)) Player.Message(pl, joinm);
}
}
if (PlayerConnect != null)

View File

@ -97,7 +97,7 @@ namespace MCGalaxy {
public string ip;
public string color;
public Group group;
public LevelPermission oHideRank;
public LevelPermission oHideRank = LevelPermission.Null;
public bool otherRankHidden = false;
public bool hidden = false;
public bool painting = false;
@ -591,14 +591,15 @@ namespace MCGalaxy {
Entities.DespawnEntities(this, false);
if (discMsg != null) {
if (!hidden) {
string leavem = "&c- " + FullName + " %S" + discMsg;
if ((Server.guestLeaveNotify && group.Permission <= LevelPermission.Guest) || group.Permission > LevelPermission.Guest) {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { Player.Message(pl, leavem); }
}
}
Server.s.Log(name + " disconnected (" + discMsg + ").");
string leavem = "&c- " + FullName + " %S" + discMsg;
const LevelPermission perm = LevelPermission.Guest;
if (group.Permission > perm || (Server.guestLeaveNotify && group.Permission <= perm)) {
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (Entities.CanSee(pl, this)) Player.Message(pl, leavem);
}
}
Server.s.Log(name + " disconnected (" + discMsg + ").");
} else {
totalKicked++;
SendChatFrom(this, "&c- " + color + prefix + DisplayName + " %Skicked (" + kickMsg + "%S).", false);

View File

@ -83,6 +83,7 @@ namespace MCGalaxy
public static PlayersFile Jailed = new PlayersFile("ranks/jailed.txt");
public static PlayersFile TempRanks = new PlayersFile("text/tempranks.txt");
public static PlayersFile Notes = new PlayersFile("text/notes.txt");
public static PlayersFile Hidden = new PlayersFile("ranks/hidden.txt");
public static PlayersFile Skins = new PlayersFile("extra/skins.txt");
public static PlayersFile Models = new PlayersFile("extra/models.txt");
public static Version Version { get { return System.Reflection.Assembly.GetAssembly(typeof(Server)).GetName().Version; } }