diff --git a/Commands/Information/CmdOpStats.cs b/Commands/Information/CmdOpStats.cs index 9cb0bda25..67e122a50 100644 --- a/Commands/Information/CmdOpStats.cs +++ b/Commands/Information/CmdOpStats.cs @@ -72,8 +72,8 @@ namespace MCGalaxy.Commands { if (target != null) { message = target.name; } else { - message = PlayerInfo.FindName(message); - if (message == null) { Player.Message(p, "Unable to find player"); return; } + message = PlayerInfo.FindOfflineNameMatches(p, message); + if (message == null) return; } Player.Message(p, (p == null ? "" : "&d") + "OpStats for " + (p == null ? "" : "&c") + message); // Use colorcodes if in game, don't use color if in console diff --git a/Commands/Moderation/CmdPlayerEditDB.cs b/Commands/Moderation/CmdPlayerEditDB.cs index 7fba044ed..92ce96f40 100644 --- a/Commands/Moderation/CmdPlayerEditDB.cs +++ b/Commands/Moderation/CmdPlayerEditDB.cs @@ -34,8 +34,8 @@ namespace MCGalaxy.Commands { string[] args = message.SplitSpaces(3); Player who = PlayerInfo.Find(args[0]); if (who == null) { - string target = PlayerInfo.FindName(args[0]); - if (target == null) { Player.Message(p, "Player &b" + args[0] + " %Swas not found in the database."); return; } + string target = PlayerInfo.FindOfflineNameMatches(p, args[0]); + if (target == null) return; args[0] = target; } if (args.Length == 1) { diff --git a/Commands/Moderation/CmdPossess.cs b/Commands/Moderation/CmdPossess.cs index ffd977ef4..94231786b 100644 --- a/Commands/Moderation/CmdPossess.cs +++ b/Commands/Moderation/CmdPossess.cs @@ -37,7 +37,7 @@ namespace MCGalaxy.Commands { if (message == "" || message == p.possess) { if (message == "" && p.possess == "") { Help(p); return; } - Player who = PlayerInfo.Find(p.possess); + Player who = PlayerInfo.FindExact(p.possess); if (who == null) { p.possess = ""; Player.Message(p, "Possession disabled."); return; diff --git a/Commands/building/CmdFill.cs b/Commands/building/CmdFill.cs index 95baae47a..275c3237d 100644 --- a/Commands/building/CmdFill.cs +++ b/Commands/building/CmdFill.cs @@ -40,7 +40,7 @@ namespace MCGalaxy.Commands.Building { } protected override DrawOp GetDrawOp(DrawArgs dArg) { - return null; + return new CuboidDrawOp(); } protected override bool DoDraw(Player p, Vec3S32[] marks, @@ -66,13 +66,16 @@ namespace MCGalaxy.Commands.Building { p.level.IntToPos(pos, out x, out y, out z); FloodFill(p, x, y, z, oldBlock, oldExtBlock, dArgs.Mode, bits, buffer, origins, 0); totalFill = origins.Count; - } - + } FillDrawOp op = new FillDrawOp(); op.Positions = buffer; - int offset = dArgs.Mode == DrawMode.normal ? 0 : 1; - Brush brush = ParseBrush(p, dArgs, offset); - if (brush == null || !DrawOp.DoDrawOp(op, brush, p, marks)) return false; + + int offset = dArgs.Mode == DrawMode.normal ? 0 : 1; + BrushFactory factory = BrushFactory.Find(p.BrushName); + BrushArgs bArgs = GetBrushArgs(dArgs, offset); + Brush brush = factory.Construct(bArgs); + + if (brush == null || !DrawOp.DoDrawOp(op, brush, p, marks)) return false; bits.Clear(); op.Positions = null; return true; diff --git a/Commands/building/DrawCmd.cs b/Commands/building/DrawCmd.cs index f2deaff50..d9822625d 100644 --- a/Commands/building/DrawCmd.cs +++ b/Commands/building/DrawCmd.cs @@ -41,8 +41,8 @@ namespace MCGalaxy.Commands.Building { // Validate the brush syntax is correct int offset = 0; BrushFactory factory = BrushFactory.Find(GetBrush(p, dArgs, ref offset)); - Brush brush = ParseBrush(p, dArgs, offset, factory); - if (brush == null) return; + BrushArgs bArgs = GetBrushArgs(dArgs, offset); + if (!factory.Validate(bArgs)) return; Player.Message(p, PlaceMessage); p.MakeSelection(MarksCount, dArgs, DoDraw); @@ -57,7 +57,8 @@ namespace MCGalaxy.Commands.Building { int offset = 0; BrushFactory factory = BrushFactory.Find(GetBrush(p, dArgs, ref offset)); - Brush brush = ParseBrush(p, dArgs, offset, factory); + BrushArgs bArgs = GetBrushArgs(dArgs, offset); + Brush brush = factory.Construct(bArgs); return brush != null && DrawOp.DoDrawOp(dArgs.Op, brush, p, marks); } @@ -65,10 +66,6 @@ namespace MCGalaxy.Commands.Building { get { return "Place two blocks to determine the edges."; } } - protected virtual bool OnUse(Player p, string msg, string[] parts, ref DrawArgs dArgs) { - return true; - } - protected virtual DrawMode GetMode(string[] parts) { return DrawMode.normal; } @@ -104,8 +101,7 @@ namespace MCGalaxy.Commands.Building { return block; } - protected static Brush ParseBrush(Player p, DrawArgs dArgs, - int usedFromEnd, BrushFactory factory = null) { + protected static BrushArgs GetBrushArgs(DrawArgs dArgs, int usedFromEnd) { int end = dArgs.Message.Length; string brushMsg = ""; for (int i = 0; i < usedFromEnd; i++) { @@ -114,10 +110,8 @@ namespace MCGalaxy.Commands.Building { } if (end >= 0) brushMsg = dArgs.Message.Substring(0, end); - if (brushMsg == "") brushMsg = p.DefaultBrushArgs; - if (factory == null) factory = BrushFactory.Find(p.BrushName); - BrushArgs args = new BrushArgs(p, brushMsg, dArgs.Block, dArgs.ExtBlock); - return factory.Construct(args); + if (brushMsg == "") brushMsg = dArgs.Player.DefaultBrushArgs; + return new BrushArgs(dArgs.Player, brushMsg, dArgs.Block, dArgs.ExtBlock); } protected struct DrawArgs { diff --git a/Drawing/BrushFactories/BrushFactory.cs b/Drawing/BrushFactories/BrushFactory.cs index 4f561fb84..deaff142a 100644 --- a/Drawing/BrushFactories/BrushFactory.cs +++ b/Drawing/BrushFactories/BrushFactory.cs @@ -33,6 +33,9 @@ namespace MCGalaxy.Drawing.Brushes { /// returning null if invalid arguments are specified. public abstract Brush Construct(BrushArgs args); + /// Validates the given arguments, returning false if they are invalid. + public virtual bool Validate(BrushArgs args) { return Construct(args) != null; } + public static List Brushes = new List() { new SolidBrushFactory(), new CheckeredBrushFactory(), new StripedBrushFactory(), new PasteBrushFactory(), diff --git a/Player/PlayerInfo.cs b/Player/PlayerInfo.cs index a6459ec4a..d5914662b 100644 --- a/Player/PlayerInfo.cs +++ b/Player/PlayerInfo.cs @@ -91,8 +91,8 @@ namespace MCGalaxy { } - /// Retrieves the player data for the player whose name - /// caselessly exactly matches the given name. + /// Retrieves from the database the player data for the player + /// whose name caselessly exactly matches the given name. /// PlayerData instance if found, null if not. public static PlayerData FindData(string name) { using (DataTable results = Query(name, "*")) { @@ -101,8 +101,8 @@ namespace MCGalaxy { } } - /// Retrieves the actual name for the player whose name - /// caselessly exactly matches the given name. + /// Retrieves from the database the actual name for the player + /// whose name caselessly exactly matches the given name. /// Correctly cased name if found, null if not. public static string FindName(string name) { using (DataTable playerDB = Query(name, "Name")) { @@ -111,8 +111,8 @@ namespace MCGalaxy { } } - /// Retrieves the last IP address for the player whose name - /// caselessly exactly matches the given name. + /// Retrieves from the database the last IP address for the + /// player whose name caselessly exactly matches the given name. /// Last IP address if found, null if not. public static string FindIP(string name) { using (DataTable results = Query(name, "IP")) { @@ -149,8 +149,8 @@ namespace MCGalaxy { } } - /// Retrieves the names of all players whose last IP address - /// matches the given IP address. + /// Retrieves from the database the names of all players whose + /// last IP address matches the given IP address. public static List FindAccounts(string ip) { DataTable clones = Database.Fill("SELECT Name FROM Players WHERE IP=@0", ip); List alts = new List();