mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Fix /fill.
This commit is contained in:
parent
384596f7f8
commit
fe90f18a0e
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -33,6 +33,9 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
/// returning null if invalid arguments are specified. </summary>
|
||||
public abstract Brush Construct(BrushArgs args);
|
||||
|
||||
/// <summary> Validates the given arguments, returning false if they are invalid. </summary>
|
||||
public virtual bool Validate(BrushArgs args) { return Construct(args) != null; }
|
||||
|
||||
public static List<BrushFactory> Brushes = new List<BrushFactory>() {
|
||||
new SolidBrushFactory(), new CheckeredBrushFactory(),
|
||||
new StripedBrushFactory(), new PasteBrushFactory(),
|
||||
|
@ -91,8 +91,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Retrieves the player data for the player whose name
|
||||
/// caselessly exactly matches the given name. </summary>
|
||||
/// <summary> Retrieves from the database the player data for the player
|
||||
/// whose name caselessly exactly matches the given name. </summary>
|
||||
/// <returns> PlayerData instance if found, null if not. </returns>
|
||||
public static PlayerData FindData(string name) {
|
||||
using (DataTable results = Query(name, "*")) {
|
||||
@ -101,8 +101,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Retrieves the actual name for the player whose name
|
||||
/// caselessly exactly matches the given name. </summary>
|
||||
/// <summary> Retrieves from the database the actual name for the player
|
||||
/// whose name caselessly exactly matches the given name. </summary>
|
||||
/// <returns> Correctly cased name if found, null if not. </returns>
|
||||
public static string FindName(string name) {
|
||||
using (DataTable playerDB = Query(name, "Name")) {
|
||||
@ -111,8 +111,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Retrieves the last IP address for the player whose name
|
||||
/// caselessly exactly matches the given name. </summary>
|
||||
/// <summary> Retrieves from the database the last IP address for the
|
||||
/// player whose name caselessly exactly matches the given name. </summary>
|
||||
/// <returns> Last IP address if found, null if not. </returns>
|
||||
public static string FindIP(string name) {
|
||||
using (DataTable results = Query(name, "IP")) {
|
||||
@ -149,8 +149,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Retrieves the names of all players whose last IP address
|
||||
/// matches the given IP address. </summary>
|
||||
/// <summary> Retrieves from the database the names of all players whose
|
||||
/// last IP address matches the given IP address. </summary>
|
||||
public static List<string> FindAccounts(string ip) {
|
||||
DataTable clones = Database.Fill("SELECT Name FROM Players WHERE IP=@0", ip);
|
||||
List<string> alts = new List<string>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user