From 7d22d7511138172bf484db18e6e7e6bf9388f3e2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 11 Mar 2016 19:21:12 +1100 Subject: [PATCH] Cuboid modes holes and random should read given arguments. (Thanks goodlyay) --- Commands/building/CmdCuboid.cs | 8 ++++---- Commands/building/CmdReplaceBrush.cs | 2 +- Commands/building/DrawCmd.cs | 5 +++-- Drawing/Brushes/Brush.cs | 9 +++++++++ Player/Player.Handlers.cs | 5 ++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Commands/building/CmdCuboid.cs b/Commands/building/CmdCuboid.cs index 26d2299bb..889f7e24e 100644 --- a/Commands/building/CmdCuboid.cs +++ b/Commands/building/CmdCuboid.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Commands CatchPos cpos = (CatchPos)p.blockchangeObject; GetRealBlock(type, extType, p, ref cpos); DrawOp drawOp = null; - Brush brush = null; + Func constructor = null; switch (cpos.mode) { case DrawMode.solid: @@ -44,16 +44,16 @@ namespace MCGalaxy.Commands drawOp = new CuboidWallsDrawOp(); break; case DrawMode.holes: drawOp = new CuboidDrawOp(); - brush = new CheckeredBrush(cpos.type, cpos.extType, 0, 0); break; + constructor = CheckeredBrush.Process; break; case DrawMode.wire: drawOp = new CuboidWireframeDrawOp(); break; case DrawMode.random: drawOp = new CuboidDrawOp(); - brush = new RandomBrush(cpos.type, cpos.extType); break; + constructor = RandomBrush.Process; break; } int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1; - if (brush == null) brush = GetBrush(p, cpos, brushOffset); + Brush brush = GetBrush(p, cpos, brushOffset, constructor); if (brush == null) return; if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) return; diff --git a/Commands/building/CmdReplaceBrush.cs b/Commands/building/CmdReplaceBrush.cs index 389799acb..fc443d4cb 100644 --- a/Commands/building/CmdReplaceBrush.cs +++ b/Commands/building/CmdReplaceBrush.cs @@ -74,7 +74,7 @@ namespace MCGalaxy.Commands { Player.SendMessage(p, "Available brushes: " + CmdBrush.AvailableBrushes); return; } - + string brushMessage = parts.Length > 2 ? parts[2].ToLower() : ""; BrushArgs args = new BrushArgs(p, brushMessage, type, extType); Brush brush = Brush.Brushes[brushName](args); diff --git a/Commands/building/DrawCmd.cs b/Commands/building/DrawCmd.cs index 7a7e61bcb..1aa68b8ef 100644 --- a/Commands/building/DrawCmd.cs +++ b/Commands/building/DrawCmd.cs @@ -86,7 +86,8 @@ namespace MCGalaxy.Commands { return type; } - protected static Brush GetBrush(Player p, CatchPos cpos, int usedFromEnd) { + protected static Brush GetBrush(Player p, CatchPos cpos, + int usedFromEnd, Func constructor = null) { int end = cpos.message.Length; string brushMsg = ""; for (int i = 0; i < usedFromEnd; i++) { @@ -95,7 +96,7 @@ namespace MCGalaxy.Commands { } if (end >= 0) brushMsg = cpos.message.Substring(0, end); - var constructor = Brush.Brushes[p.BrushName]; + if (constructor == null) constructor = Brush.Brushes[p.BrushName]; BrushArgs args = new BrushArgs(p, brushMsg, cpos.type, cpos.extType); return constructor(args); } diff --git a/Drawing/Brushes/Brush.cs b/Drawing/Brushes/Brush.cs index 373081238..3802ec68f 100644 --- a/Drawing/Brushes/Brush.cs +++ b/Drawing/Brushes/Brush.cs @@ -75,6 +75,15 @@ namespace MCGalaxy.Drawing.Brushes { public override string[] Help { get { return new string[0]; } } + public static Brush Process(BrushArgs args) { + if (args.Message == "") + return new RandomBrush(args.Type, args.ExtType); + byte extType; + byte type = DrawCmd.GetBlock(args.Player, args.Message, out extType); + if (type == Block.Zero) return null; + return new RandomBrush(type, extType); + } + public override byte NextBlock(DrawOp op) { return (byte)rnd.Next(1, 11) <= 5 ? type : Block.Zero; } diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index f705559db..db5783f1f 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -1082,9 +1082,8 @@ return; overallDeath++; } - if ( Server.deathcount ) - if ( overallDeath > 0 && overallDeath % 10 == 0 ) - SendChatFrom(this, this.FullName + Server.DefaultColor + " has died &3" + overallDeath + " times", false); + if (Server.deathcount && (overallDeath > 0 && overallDeath % 10 == 0)) + Chat.GlobalChatLevel(this, FullName + " %Shas died &3" + overallDeath + " times", false); } lastDeath = DateTime.Now;