Skip to content

Commit

Permalink
Add more messages to be suppressed by Ignores.DrawOutput
Browse files Browse the repository at this point in the history
Already shown by prompt.
    "Place or break two blocks to determine the edges."

No news is good news.
    "Created a new " + scope + " custom block"...
    "Duplicated the {0} custom block "...
    "Copied the {0} custom block "...

Any error or warning will be shown, but if the message is expected it
is suppressed, for example, a missing block for block remove command is
not a problem.
  • Loading branch information
robert authored and rdebath committed Apr 23, 2021
1 parent 31429c4 commit 4c42433
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 25 deletions.
13 changes: 8 additions & 5 deletions MCGalaxy/Blocks/BlockOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ static void ToggleBehaviour(Player p, BlockProps[] scope, BlockID block, string

static void Toggle(Player p, BlockProps[] scope, BlockID block, string type, ref bool on) {
on = !on;
string name = BlockProps.ScopedName(scope, p, block);
p.Message("Block {0} is {1}: {2}", name, type, on ? "&aYes" : "&cNo");
if (!p.Ignores.DrawOutput) {
string name = BlockProps.ScopedName(scope, p, block);
p.Message("Block {0} is {1}: {2}", name, type, on ? "&aYes" : "&cNo");
}
}

static void SetAI(Player p, BlockProps[] scope, BlockID block, string msg) {
Expand Down Expand Up @@ -150,7 +152,7 @@ static void SetStackId(Player p, BlockProps[] scope, BlockID block, string msg)
string name = BlockProps.ScopedName(scope, p, block);
if (stackBlock == Block.Air) {
p.Message("Removed stack block for {0}", name);
} else {
} else if (!p.Ignores.DrawOutput) {
p.Message("Stack block for {0} set to: {1}",
name, BlockProps.ScopedName(scope, p, stackBlock));
}
Expand All @@ -168,8 +170,9 @@ static void SetBlock(Player p, BlockProps[] scope, BlockID block,
if (other == block) { p.Message("ID of {0} must be different.", type); return; }

target = other;
p.Message("{2} for {0} set to: {1}",
name, BlockProps.ScopedName(scope, p, other), type);
if (!p.Ignores.DrawOutput && p.Supports(CpeExt.MessageTypes))
p.Message("{2} for {0} set to: {1}",
name, BlockProps.ScopedName(scope, p, other), type);
}
}
}
Expand Down
26 changes: 18 additions & 8 deletions MCGalaxy/Commands/CPE/CustomBlockCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ static void CopyAllHandler(Player p, Level lvl, string[] parts, CommandData data
copied++;

string scope = global ? "global" : "level";
p.Message("Copied the {0} custom block with id \"{1}\".", scope, Block.ToRaw(b));
if (!p.Ignores.DrawOutput)
p.Message("Copied the {0} custom block with id \"{1}\".", scope, Block.ToRaw(b));
}

p.Message("{0} custom blocks were copied from level {1}",
Expand Down Expand Up @@ -197,7 +198,8 @@ static void CopyHandler(Player p, Level lvl, string[] parts, CommandData data,
if (!DoCopy(p, lvl, global, cmd, false, defs[src], src, dst)) continue;
string scope = global ? "global" : "level";

p.Message("Duplicated the {0} custom block with id \"{1}\" to \"{2}\".",
if (!p.Ignores.DrawOutput)
p.Message("Duplicated the {0} custom block with id \"{1}\" to \"{2}\".",
scope, i, Block.ToRaw(dst));
changed = true;
}
Expand Down Expand Up @@ -284,13 +286,18 @@ static bool DoRemove(Player p, Level lvl, BlockID block,
bool global, string cmd) {
BlockDefinition[] defs = global ? BlockDefinition.GlobalDefs : lvl.CustomBlockDefs;
BlockDefinition def = defs[block];
if (!ExistsInScope(def, block, global)) { MessageNoBlock(p, block, global, cmd); return false; }
if (!ExistsInScope(def, block, global)) {
if (!p.Ignores.DrawOutput)
MessageNoBlock(p, block, global, cmd);
return false;
}

BlockDefinition.Remove(def, defs, lvl);
ResetProps(global, lvl, block, p);

string scope = global ? "global" : "level";
p.Message("Removed " + scope + " custom block " + def.Name + "(" + def.RawID + ")");
if (!p.Ignores.DrawOutput)
p.Message("Removed " + scope + " custom block " + def.Name + "(" + def.RawID + ")");

BlockDefinition globalDef = BlockDefinition.GlobalDefs[block];
if (!global && globalDef != null)
Expand Down Expand Up @@ -526,14 +533,16 @@ static bool DoEdit(Player p, Level lvl, BlockID block, string[] parts,

def.InventoryOrder = order == def.RawID ? -1 : order;
BlockDefinition.UpdateOrder(def, global, lvl);
p.Message("Set inventory order for {0} to {1}", blockName,
if (!p.Ignores.DrawOutput)
p.Message("Set inventory order for {0} to {1}", blockName,
order == def.RawID ? "default" : order.ToString());
return true;
default:
p.Message("Unrecognised property: " + arg); return false;
}

p.Message("Set {0} for {1} to {2}", arg, blockName, value);
if (!p.Ignores.DrawOutput)
p.Message("Set {0} for {1} to {2}", arg, blockName, value);
BlockDefinition.Add(def, defs, lvl);
if (changedFallback) {
BlockDefinition.UpdateFallback(global, def.GetBlock(), lvl);
Expand Down Expand Up @@ -570,7 +579,8 @@ static void UpdateBlock(Player p, Level lvl, BlockDefinition def, bool global) {
BlockID block = def.GetBlock();

string scope = global ? "global" : "level";
p.Message("Created a new " + scope + " custom block " + def.Name + "(" + def.RawID + ")");
if (!p.Ignores.DrawOutput)
p.Message("Created a new " + scope + " custom block " + def.Name + "(" + def.RawID + ")");

block = def.GetBlock();
BlockDefinition.Add(def, defs, lvl);
Expand Down Expand Up @@ -906,4 +916,4 @@ public override void Help(Player p, string message) {
CustomBlockCommand.Help(p, "/lb", message);
}
}
}
}
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/Fun/CmdLavaSurvival.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ void HandleSetOther(Player p, string[] args, LSMapConfig cfg) {

string prop = args[2];
if (prop.CaselessEq("safe")) {
p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
p.MakeSelection(2, cfg, SetSafeZone);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/Moderation/CmdHighlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public override void Use(Player p, string message, CommandData data) {
Vec3S32[] marks = new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal };
HighlightPlayer(p, delta, parts[0], ids, marks);
} else {
p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
HighlightAreaArgs args = new HighlightAreaArgs();
args.ids = ids; args.who = parts[0]; args.delta = delta;
p.MakeSelection(2, "Selecting region for &SHighlight", args, DoHighlightArea);
Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/Moderation/CmdUndoPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public override void Use(Player p, string message, CommandData data) {
Vec3S32[] marks = new Vec3S32[] { Vec3U16.MinVal, Vec3U16.MaxVal };
UndoPlayer(p, delta, names, ids, marks);
} else {
p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
UndoAreaArgs args = new UndoAreaArgs();
args.ids = ids; args.names = names; args.delta = delta;
p.MakeSelection(2, "Selecting region for &SUndo player", args, DoUndoArea);
Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/Moderation/ZoneCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void CreateZone(Player p, string[] args, CommandData data, int offset) {
if (!PermissionCmd.Do(p, args, offset + 1, false, z.Access, data, p.level)) return;

p.Message("Creating zone " + z.ColoredName);
p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
p.MakeSelection(2, "Selecting region for &SNew zone", z, AddZone);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/World/CmdBlockProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void ResetProps(Player p, BlockProps[] scope, BlockID block) {
scope[block] = BlockProps.MakeDefault(scope, p.level, block);
string name = BlockProps.ScopedName(scope, p, block);

p.Message("Reset properties of {0} to default", name);
if (!p.Ignores.BlockDef)
p.Message("Reset properties of {0} to default", name);
BlockProps.ApplyChanges(scope, p.level, block, true);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/CmdCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public sealed class CmdCenter : Command2 {
public override string type { get { return CommandTypes.Building; } }

public override void Use(Player p, string message, CommandData data) {
p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
p.MakeSelection(2, "Selecting region for &SCenter", null, DoCentre);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/CmdCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void HandleOther(Player p, string[] parts, int offsetIndex) {
}
}

p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
int marks = cArgs.offsetIndex != -1 ? 3 : 2;
p.MakeSelection(marks, "Selecting region for &SCopy", cArgs, DoCopy, DoCopyMark);
}
Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/CmdDrill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public override void Use(Player p, string message, CommandData data) {
ushort dist = 20;
if (message.Length > 0 && !CommandParser.GetUShort(p, message, "Distance", ref dist)) return;

p.Message("Destroy the block you wish to drill.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Destroy the block you wish to drill.");
p.MakeSelection(1, "Selecting location for &SDrill", dist, DoDrill);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/CmdImageprint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public override void Use(Player p, string message, CommandData data) {
dArgs.Data = File.ReadAllBytes(path);
}

p.Message("Place or break two blocks to determine direction.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine direction.");
p.MakeSelection(2, "Selecting direction for &SImagePrint", dArgs, DoImage);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/CmdMeasure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public override void Use(Player p, string message, CommandData data) {
}
}

p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
p.MakeSelection(2, "Selecting region for &SMeasure", toCount, DoMeasure);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/CmdRestartPhysics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public override void Use(Player p, string message, CommandData data) {
message = message.ToLower();
if (message.Length > 0 && !ParseArgs(p, message, ref extraInfo)) return;

p.Message("Place or break two blocks to determine the edges.");
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message("Place or break two blocks to determine the edges.");
p.MakeSelection(2, "Selecting region for &SRestart physics", extraInfo, DoRestart);
}

Expand Down
3 changes: 2 additions & 1 deletion MCGalaxy/Commands/building/DrawCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public override void Use(Player p, string message, CommandData data) {
BrushArgs bArgs = new BrushArgs(p, dArgs.BrushArgs, dArgs.Block);
if (!factory.Validate(bArgs)) return;

p.Message(PlaceMessage);
if (!p.Ignores.DrawOutput || !p.Supports(CpeExt.MessageTypes))
p.Message(PlaceMessage);
p.MakeSelection(MarksCount, "Selecting " + SelectionType + " for &S" + dArgs.Op.Name, dArgs, DoDraw);
}

Expand Down

0 comments on commit 4c42433

Please sign in to comment.