From 1beb8de57bef010bd160a9248fa58e45672a8eaa Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 8 Sep 2019 13:30:03 +1000 Subject: [PATCH] Move logic for determining user type into player class, change Packet.UserType to allow user type as an argument --- MCGalaxy/Commands/Moderation/ModActionCmd.cs | 3 ++- MCGalaxy/Network/Packets/Packet.cs | 9 +++------ MCGalaxy/Player/Player.cs | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MCGalaxy/Commands/Moderation/ModActionCmd.cs b/MCGalaxy/Commands/Moderation/ModActionCmd.cs index c2fe1fee9..75ee17157 100644 --- a/MCGalaxy/Commands/Moderation/ModActionCmd.cs +++ b/MCGalaxy/Commands/Moderation/ModActionCmd.cs @@ -90,7 +90,8 @@ namespace MCGalaxy.Commands.Moderation { who.SetPrefix(); Entities.DespawnEntities(who, false); - who.Send(Packet.UserType(who)); + who.Send(Packet.UserType(who, who.UserType())); + who.SendCurrentBlockPermissions(); Entities.SpawnEntities(who, false); CheckBlockBindings(who); diff --git a/MCGalaxy/Network/Packets/Packet.cs b/MCGalaxy/Network/Packets/Packet.cs index ea9803b0c..5e8b12385 100644 --- a/MCGalaxy/Network/Packets/Packet.cs +++ b/MCGalaxy/Network/Packets/Packet.cs @@ -40,7 +40,7 @@ namespace MCGalaxy.Network { NetUtils.Write(motd, buffer, 66, p.hasCP437); } - buffer[130] = p.group.Blocks[Block.Bedrock] ? (byte)100 : (byte)0; + buffer[130] = p.UserType(); return buffer; } @@ -108,11 +108,8 @@ namespace MCGalaxy.Network { return buffer; } - public static byte[] UserType(Player p) { - byte[] buffer = new byte[2]; - buffer[0] = Opcode.SetPermission; - buffer[1] = p.group.Blocks[Block.Bedrock] ? (byte)100 : (byte)0; - return buffer; + public static byte[] UserType(Player p, byte type) { + return new byte[] { Opcode.SetPermission, type }; } #endregion diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index 6e2cfd49c..fc5f82d9a 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -310,6 +310,8 @@ namespace MCGalaxy { } return true; } + + internal byte UserType() { return group.Blocks[Block.Bedrock] ? (byte)100 : (byte)0; } #endregion