From 02f14cd50fe81057d3cc5cef1397ed3d0d0dee9d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 27 Feb 2017 15:28:10 +1100 Subject: [PATCH] cleanup --- MCGalaxy/Blocks/Behaviour/BlockBehaviour.cs | 6 ++- MCGalaxy/Blocks/Block.CoreProps.cs | 2 +- MCGalaxy/Blocks/Block.ID.cs | 50 +++++++++---------- MCGalaxy/Blocks/Block.Permissions.cs | 43 ++++------------ MCGalaxy/Commands/World/CmdBlockProperties.cs | 2 +- 5 files changed, 41 insertions(+), 62 deletions(-) diff --git a/MCGalaxy/Blocks/Behaviour/BlockBehaviour.cs b/MCGalaxy/Blocks/Behaviour/BlockBehaviour.cs index d8ece0bfc..ce66dd2e4 100644 --- a/MCGalaxy/Blocks/Behaviour/BlockBehaviour.cs +++ b/MCGalaxy/Blocks/Behaviour/BlockBehaviour.cs @@ -42,7 +42,8 @@ namespace MCGalaxy.Blocks { internal static HandlePhysics[] physicsHandlers = new HandlePhysics[Block.Count]; internal static HandlePhysics[] physicsDoorsHandlers = new HandlePhysics[Block.Count]; - internal static void SetupCoreHandlers() { + /// Initalises deleting, placing, and walkthrough handling behaviour for the core blocks. + internal static void InitCoreHandlers() { for (int i = 0; i < Block.Count; i++) { deleteHandlers[i] = null; placeHandlers[i] = null; @@ -94,7 +95,8 @@ namespace MCGalaxy.Blocks { deleteHandlers[Block.door_green_air] = DeleteBehaviour.RevertDoor; } - internal static void SetupCorePhysicsHandlers() { + /// Initalise physics handling behaviour for the core blocks. + internal static void InitCorePhysicsHandlers() { physicsHandlers[Block.birdblack] = BirdPhysics.Do; physicsHandlers[Block.birdwhite] = BirdPhysics.Do; physicsHandlers[Block.birdlava] = BirdPhysics.Do; diff --git a/MCGalaxy/Blocks/Block.CoreProps.cs b/MCGalaxy/Blocks/Block.CoreProps.cs index cba8fb586..a38c34cc2 100644 --- a/MCGalaxy/Blocks/Block.CoreProps.cs +++ b/MCGalaxy/Blocks/Block.CoreProps.cs @@ -140,7 +140,7 @@ namespace MCGalaxy { SetDefaultAliases(); for (int i = 0; i < names.Length; i++) { string name = names[i]; - if (name == null) name = "unknown"; + if (name == null) name = "unknown"; if (i > 0 && i < Block.CpeCount) { BlockDefinition def = BlockDefinition.GlobalDefs[i]; if (def != null) name = def.Name; diff --git a/MCGalaxy/Blocks/Block.ID.cs b/MCGalaxy/Blocks/Block.ID.cs index bffd28e4c..cee5315b8 100644 --- a/MCGalaxy/Blocks/Block.ID.cs +++ b/MCGalaxy/Blocks/Block.ID.cs @@ -97,15 +97,15 @@ namespace MCGalaxy public const byte crate = 64; public const byte stonebrick = 65; - public const byte door_darkpink_air = 66; // unused in core - public const byte door_darkgrey_air = 67; // unused in core - public const byte door_lightgrey_air = 68; // unused in core - public const byte door_white_air = 69; // unused in core + public const byte door_darkpink_air = 66; // unused in core + public const byte door_darkgrey_air = 67; // unused in core + public const byte door_lightgrey_air = 68; // unused in core + public const byte door_white_air = 69; // unused in core public const byte flagbase = 70; //Seasons - //public const byte fallsnow = 71; // unused in core - //public const byte snow = 72; // unused in core + //public const byte fallsnow = 71; // unused in core + //public const byte snow = 72; // unused in core public const byte fastdeathlava = 73; @@ -116,7 +116,7 @@ namespace MCGalaxy public const byte door_cobblestone = 80; public const byte door_cobblestone_air = 81; // unused in core public const byte door_red = 83; - public const byte door_red_air = 84; // unused in core + public const byte door_red_air = 84; // unused in core public const byte door_orange = 85; public const byte door_yellow = 86; @@ -269,19 +269,19 @@ namespace MCGalaxy public const byte air_flood_layer = 202; public const byte air_flood_down = 203; public const byte air_flood_up = 204; - public const byte door_obsidian_air = 205; // unused in core - public const byte door_glass_air = 206; // unused in core - public const byte door_stone_air = 207; // unused in core - public const byte door_leaves_air = 208; // unused in core - public const byte door_sand_air = 209; // unused in core - public const byte door_wood_air = 210; // unused in core + public const byte door_obsidian_air = 205; // unused in core + public const byte door_glass_air = 206; // unused in core + public const byte door_stone_air = 207; // unused in core + public const byte door_leaves_air = 208; // unused in core + public const byte door_sand_air = 209; // unused in core + public const byte door_wood_air = 210; // unused in core public const byte door_green_air = 211; public const byte door_tnt_air = 212; - public const byte door_stair_air = 213; // unused in core - public const byte air_switch_air = 214; // unused in core - public const byte water_door_air = 215; // unused in core - public const byte lava_door_air = 216; // unused in core - public const byte air_door_air = 217; // unused in core + public const byte door_stair_air = 213; // unused in core + public const byte air_switch_air = 214; // unused in core + public const byte water_door_air = 215; // unused in core + public const byte lava_door_air = 216; // unused in core + public const byte air_door_air = 217; // unused in core // 218, 219 free public const byte door_iron = 220; @@ -289,11 +289,11 @@ namespace MCGalaxy public const byte door_grass = 222; public const byte door_blue = 223; public const byte door_book = 224; - public const byte door_iron_air = 225; // unused in core - public const byte door_dirt_air = 226; // unused in core - public const byte door_grass_air = 227; // unused in core - public const byte door_blue_air = 228; // unused in core - public const byte door_book_air = 229; // unused in core + public const byte door_iron_air = 225; // unused in core + public const byte door_dirt_air = 226; // unused in core + public const byte door_grass_air = 227; // unused in core + public const byte door_blue_air = 228; // unused in core + public const byte door_book_air = 229; // unused in core public const byte train = 230; @@ -324,9 +324,9 @@ namespace MCGalaxy public const byte snaketail = 252; public const byte door_gold = 253; - public const byte door_gold_air = 254; // unused in core + public const byte door_gold_air = 254; // unused in core public const byte Zero = 0xff; // backwards compatibility public const byte Invalid = 0xff; } -} +} \ No newline at end of file diff --git a/MCGalaxy/Blocks/Block.Permissions.cs b/MCGalaxy/Blocks/Block.Permissions.cs index 8a515937d..402d3ebda 100644 --- a/MCGalaxy/Blocks/Block.Permissions.cs +++ b/MCGalaxy/Blocks/Block.Permissions.cs @@ -34,19 +34,19 @@ namespace MCGalaxy public static void SetBlocks() { SetCoreProperties(); - BlockBehaviour.SetupCorePhysicsHandlers(); - InitDefaults(); + BlockBehaviour.InitCorePhysicsHandlers(); + SetDefaultPerms(); BlockProps.Load("core", Block.Props); - BlockBehaviour.SetupCoreHandlers(); + BlockBehaviour.InitCoreHandlers(); // Custom permissions set by the user. if (File.Exists(Paths.BlockPermsFile)) { string[] lines = File.ReadAllLines(Paths.BlockPermsFile); if (lines.Length > 0 && lines[0] == "#Version 2") { - LoadVersion2(lines); + LoadPermsVersion2(lines); } else { - LoadVersion1(lines); + LoadPermsVersion1(lines); } } SaveBlocks(BlockList); @@ -87,7 +87,7 @@ namespace MCGalaxy } - static void LoadVersion2(string[] lines) { + static void LoadPermsVersion2(string[] lines) { string[] colon = new string[] { " : " }; foreach (string line in lines) { if (line == "" || line[0] == '#') continue; @@ -121,7 +121,7 @@ namespace MCGalaxy } } - static void LoadVersion1(string[] lines) { + static void LoadPermsVersion1(string[] lines) { foreach (string line in lines) { if (line == "" || line[0] == '#') continue; @@ -141,13 +141,13 @@ namespace MCGalaxy public static void SaveBlocks(IEnumerable givenList) { try { lock (saveLock) - SaveBlocksCore(givenList); + SaveBlocksPermsCore(givenList); } catch (Exception e) { Server.ErrorLog(e); } } - static void SaveBlocksCore(IEnumerable givenList) { + static void SaveBlocksPermsCore(IEnumerable givenList) { using (StreamWriter w = new StreamWriter(Paths.BlockPermsFile)) { w.WriteLine("#Version 2"); w.WriteLine("# This file dictates which ranks may use what blocks"); @@ -170,7 +170,7 @@ namespace MCGalaxy } - static void InitDefaults() { + static void SetDefaultPerms() { for (int i = 0; i < Block.Count; i++) { Blocks b = new Blocks(); b.type = (byte)i; @@ -228,31 +228,8 @@ namespace MCGalaxy case lava_sponge: case door_tree_air: - case door_obsidian_air: - case door_glass_air: - case door_stone_air: - case door_leaves_air: - case door_sand_air: - case door_wood_air: case door_green_air: case door_tnt_air: - case door_stair_air: - case air_switch_air: - case water_door_air: - case lava_door_air: - case air_door_air: - case door_iron_air: - case door_gold_air: - case door_cobblestone_air: - case door_grass_air: - case door_dirt_air: - case door_blue_air: - case door_book_air: - case door_red_air: - case door_darkpink_air: - case door_darkgrey_air: - case door_lightgrey_air: - case door_white_air: case odoor1_air: case odoor2_air: diff --git a/MCGalaxy/Commands/World/CmdBlockProperties.cs b/MCGalaxy/Commands/World/CmdBlockProperties.cs index 38e069307..bf91174cd 100644 --- a/MCGalaxy/Commands/World/CmdBlockProperties.cs +++ b/MCGalaxy/Commands/World/CmdBlockProperties.cs @@ -157,7 +157,7 @@ namespace MCGalaxy.Commands.World { scope[id].Changed = true; if (scope == Block.Props) { - BlockBehaviour.SetupCoreHandlers(); + BlockBehaviour.InitCoreHandlers(); BlockProps.Save("core", scope); } else if (scope == BlockDefinition.GlobalProps) { Level[] loaded = LevelInfo.Loaded.Items;