Fix /hide not updating tab list. (Thanks VenkSociety)

This commit is contained in:
UnknownShadow200 2017-10-27 22:04:41 +11:00
parent c36334e64f
commit b152ca9726
7 changed files with 30 additions and 39 deletions

View File

@ -25,68 +25,63 @@ namespace MCGalaxy.Commands.Moderation {
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override bool SuperUseable { get { return false; } }
public override CommandPerm[] ExtraPerms {
get { return new[] { new CommandPerm(LevelPermission.Admin, "+ can hide/unhide without showing a message to ops") }; }
get { return new[] { new CommandPerm(LevelPermission.Admin, "+ can hide silently") }; }
}
public override CommandAlias[] Aliases {
get { return new CommandAlias[] { new CommandAlias("XHide", "silent") }; }
}
public override void Use(Player p, string message) {
if (message.CaselessEq("check")) {
string state = p.hidden ? "" : "not ";
Player.Message(p, "You are " + state + "currently hidden!"); return;
}
if (message.Length > 0 && p.possess.Length > 0) {
Player.Message(p, "Stop your current possession first."); return;
}
bool messageOps = true;
bool announceToOps = true;
if (message.CaselessEq("silent")) {
if (!CheckExtraPerm(p, 1)) return;
messageOps = false;
announceToOps = false;
}
Command opchat = Command.all.FindByName("OpChat");
Command adminchat = Command.all.FindByName("AdminChat");
Entities.GlobalDespawn(p, false);
p.hidden = !p.hidden;
//Possible to use /hide myrank, but it accomplishes the same as regular /hide if you use it on yourself.
if (message.CaselessEq("myrank")) {
p.otherRankHidden = !p.otherRankHidden;
p.hidden = p.otherRankHidden;
}
if (p.hidden) {
Entities.GlobalDespawn(p, false);
if (messageOps && !p.otherRankHidden)
if (p.hidden) {
if (announceToOps && !p.otherRankHidden) {
Chat.MessageOps("To Ops -" + p.ColoredName + "%S- is now &finvisible%S.");
}
string discMsg = PlayerDB.GetLogoutMessage(p);
Chat.MessageGlobal(p, "&c- " + p.FullName + " %S" + discMsg, false);
Server.IRC.Say(p.DisplayName + " %Sleft the game (disconnected%S)");
if (messageOps && !p.opchat) opchat.Use(p, message);
if (announceToOps && !p.opchat) opchat.Use(p, "");
Server.hidden.AddIfNotExists(p.name);
} else {
Entities.GlobalSpawn(p, false);
} else {
p.otherRankHidden = false;
p.oHideRank = LevelPermission.Null;
if (messageOps)
Chat.MessageAdmins("To Admins -" + p.ColoredName + "%S- is now &fvisible%S.");
if (announceToOps) {
Chat.MessageOps("To Ops -" + p.ColoredName + "%S- is now &fvisible%S.");
}
Chat.MessageGlobal(p, "&a+ " + p.FullName + " %S" + PlayerDB.GetLoginMessage(p), false);
Server.IRC.Say(p.DisplayName + " %Sjoined the game");
if (messageOps && p.opchat) opchat.Use(p, message);
if (p.adminchat) adminchat.Use(p, message);
if (announceToOps && p.opchat) opchat.Use(p, "");
Server.hidden.Remove(p.name);
}
Entities.GlobalSpawn(p, false);
TabList.Add(p, p, Entities.SelfID);
Server.hidden.Save(false);
}
public override void Help(Player p) {
Player.Message(p, "%T/Hide %H- Toggles your visibility to other players, also toggles opchat.");
Player.Message(p, "%T/Hide check %H- Checks your hidden status.");
Player.Message(p, "%T/Hide silent %H- hides without sending a message to other ops/admins.");
Player.Message(p, "%T/Hide silent %H- Hides without sending a message to opchat");
Player.Message(p, "%HUse %T/OHide %Hto hide other players.");
}
}

View File

@ -158,7 +158,7 @@ namespace MCGalaxy.Eco {
Player.Message(p, "Lasts for &a{0} %Sseconds. You can buy &a{1} %Smore this round.", Duration, left);
Server.zombie.Map.ChatLevel(p.ColoredName + " %Svanished. &a*POOF*");
Entities.GlobalDespawn(p, false);
Entities.GlobalDespawn(p, false, false);
Economy.MakePurchase(p, Price, "%3Invisibility: " + Duration);
}

View File

@ -30,9 +30,9 @@ namespace MCGalaxy {
#region Spawning / Despawning
/// <summary> Respawns this player to all players (including self) that can see the player in the current world. </summary>
public static void GlobalRespawn(Player p) {
GlobalDespawn(p, true);
GlobalSpawn(p, true);
public static void GlobalRespawn(Player p, bool self = true) {
GlobalDespawn(p, self);
GlobalSpawn(p, self);
}
/// <summary> Spawns this player to all other players that can see the player in the current world. </summary>
@ -59,9 +59,9 @@ namespace MCGalaxy {
}
}
/// <summary> Despawns this player to all other players that cannot
/// (or can if 'toVisible' is true) see the player in the current world. </summary>
public static void GlobalDespawn(Player p, bool self, bool toVisible = false) {
/// <summary> Despawns this player to all other players that can
/// (or cannot if 'toVisible' is false) see the player in the current world. </summary>
public static void GlobalDespawn(Player p, bool self, bool toVisible = true) {
Player[] players = PlayerInfo.Online.Items;
TabList.RemoveAll(p, self, toVisible);
@ -116,7 +116,7 @@ namespace MCGalaxy {
foreach (Player other in players) {
if (p.level == other.level && p != other) Despawn(p, other);
}
GlobalDespawn(p, true, true);
GlobalDespawn(p, true);
if (!bots) return;
PlayerBot[] botsList = p.level.Bots.Items;

View File

@ -43,7 +43,6 @@ namespace MCGalaxy.Games
{
if (p.Game.team != null) { p.Game.team.RemoveMember(p); }
p.Game.team = this;
Entities.GlobalDespawn(p, false);
//p.CTFtempcolor = p.color;
//p.CTFtempprefix = p.prefix;
p.color = "&" + color;
@ -52,7 +51,7 @@ namespace MCGalaxy.Games
p.prefix = p.color + "[" + Colors.Name(color).ToUpper() + "] ";
players.Add(p);
mapOn.ChatLevel(p.ColoredName + " %Shas joined the " + teamstring + ".");
Entities.GlobalSpawn(p, false);
Entities.GlobalRespawn(p, false);
}
}
@ -61,14 +60,13 @@ namespace MCGalaxy.Games
if (p.Game.team == this)
{
p.Game.team = null;
Entities.GlobalDespawn(p, false);
//p.color = p.CTFtempcolor;
//p.prefix = p.CTFtempprefix;
//p.carryingFlag = false;
p.Game.hasflag = null;
players.Remove(p);
mapOn.ChatLevel(p.ColoredName + " %Shas left the " + teamstring + ".");
Entities.GlobalSpawn(p, false);
Entities.GlobalRespawn(p, false);
}
}

View File

@ -100,8 +100,7 @@ namespace MCGalaxy.Games.ZS {
pl.SetMoney(pl.money + 1);
}
Entities.GlobalDespawn(pl, false);
Entities.GlobalSpawn(pl, false);
Entities.GlobalRespawn(pl, false);
TabList.Add(pl, pl, Entities.SelfID);
HUD.UpdateTertiary(pl);
}

View File

@ -121,7 +121,7 @@ namespace MCGalaxy.Games.ZS {
p.Send(Hacks.MakeHackControl(p));
} else {
HandlePlayerDisconnect(p, null);
Entities.GlobalDespawn(p, false, true);
Entities.GlobalDespawn(p, false, false);
p.Game.Referee = true;
if (p.Supports(CpeExt.HackControl))
@ -129,7 +129,7 @@ namespace MCGalaxy.Games.ZS {
}
Entities.GlobalSpawn(p, false, "");
TabList.Add(p, p, Entities.SelfID);
TabList.Update(p, true);
p.SetPrefix();
}

View File

@ -313,8 +313,7 @@ namespace MCGalaxy.Games {
static void UpdatePlayerColor(Player p, string color) {
if (p.Game.lastSpawnColor == color) return;
p.Game.lastSpawnColor = color;
Entities.GlobalDespawn(p, false);
Entities.GlobalSpawn(p, false);
Entities.GlobalRespawn(p, false);
TabList.Add(p, p, Entities.SelfID);
}