From 4328ff25e236359a6e9a82c669479a60d37a1365 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 24 Sep 2017 09:07:42 +1000 Subject: [PATCH] fix physics blocks losing block permissions from recent commits --- MCGalaxy/Blocks/BlockPerms.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/MCGalaxy/Blocks/BlockPerms.cs b/MCGalaxy/Blocks/BlockPerms.cs index 260fb6b8f..34b4a553f 100644 --- a/MCGalaxy/Blocks/BlockPerms.cs +++ b/MCGalaxy/Blocks/BlockPerms.cs @@ -52,7 +52,7 @@ namespace MCGalaxy.Blocks { public static BlockPerms[] List = new BlockPerms[Block.Count]; - /// Returns whether the given rank can modify the given block. + /// Returns whether the given rank can modify the given block. public static bool UsableBy(Player p, byte block) { BlockPerms b = List[block]; LevelPermission perm = p.Rank; @@ -74,13 +74,13 @@ namespace MCGalaxy.Blocks { int count = pl.hasCustomBlocks ? Block.CpeCount : Block.OriginalCount; if (block < count) { bool usable = UsableBy(pl, block); - pl.Send(Packet.BlockPermission(block, - usable && pl.level.CanPlace, + pl.Send(Packet.BlockPermission(block, + usable && pl.level.CanPlace, usable && pl.level.CanDelete)); } } } - + public void MessageCannotUse(Player p, string action) { StringBuilder builder = new StringBuilder("Only "); Formatter.PrintRanks(MinRank, Allowed, Disallowed, builder); @@ -125,7 +125,7 @@ namespace MCGalaxy.Blocks { } - /// Loads the list of all block permissions. + /// Loads the list of all block permissions. public static void Load() { SetDefaultPerms(); @@ -153,11 +153,14 @@ namespace MCGalaxy.Blocks { //Name/ID : Lowest : Disallow : Allow line.Replace(" ", "").FixedSplit(args, ':'); - byte block = Block.Byte(args[0]); + byte block; + if (!byte.TryParse(args[0], out block)) { + block = Block.Byte(args[0]); + } if (block == Block.Invalid) continue; + BlockPerms perms = new BlockPerms(); perms.BlockID = block; - try { perms.MinRank = (LevelPermission)int.Parse(args[1]); string disallowRaw = args[2], allowRaw = args[3]; @@ -184,7 +187,7 @@ namespace MCGalaxy.Blocks { List[block].MinRank = group.Permission; else throw new InvalidDataException("Line " + line + " is invalid."); - } catch { + } catch { Logger.Log(LogType.Warning, "Could not find the rank given on {0}. Using default", line); } }