Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to ignoring messages. #598

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.BlockdefChanges) {
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.BlockdefChanges) {
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.BlockdefChanges)
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 @@ -161,7 +161,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.BlockdefChanges)
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 @@ -196,7 +197,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.BlockdefChanges)
p.Message("Duplicated the {0} custom block with id \"{1}\" to \"{2}\".",
scope, i, Block.ToRaw(dst));
changed = true;
}
Expand Down Expand Up @@ -283,13 +285,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.BlockdefChanges)
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.BlockdefChanges)
p.Message("Removed " + scope + " custom block " + def.Name + "(" + def.RawID + ")");

BlockDefinition globalDef = BlockDefinition.GlobalDefs[block];
if (!global && globalDef != null)
Expand Down Expand Up @@ -525,14 +532,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.BlockdefChanges)
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.BlockdefChanges)
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 @@ -569,7 +578,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.BlockdefChanges)
p.Message("Created a new " + scope + " custom block " + def.Name + "(" + def.RawID + ")");

block = def.GetBlock();
BlockDefinition.Add(def, defs, lvl);
Expand Down Expand Up @@ -905,4 +915,4 @@ public override void Help(Player p, string message) {
CustomBlockCommand.Help(p, "/lb", message);
}
}
}
}
3 changes: 3 additions & 0 deletions MCGalaxy/Commands/Chat/CmdIgnore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public override void Use(Player p, string message, CommandData data) {
Toggle(p, ref p.Ignores.DrawOutput, "{0} ignoring draw command output"); return;
} else if (action == "worldchanges") {
Toggle(p, ref p.Ignores.WorldChanges, "{0} ignoring world changes"); return;
} else if (action == "blockdefchanges") {
Toggle(p, ref p.Ignores.BlockdefChanges, "{0} ignoring block definition messages"); return;
} else if (IsListCommand(action)) {
p.Ignores.Output(p); return;
}
Expand Down Expand Up @@ -113,6 +115,7 @@ public override void Help(Player p, string message) {
p.Message("&H 8ball - &T/8ball &His ignored.");
p.Message("&H drawoutput - drawing command output is ignored.");
p.Message("&H worldchanges - world change messages are ignored.");
p.Message("&H blockdefchanges - block definition messages are ignored.");
}
}
}
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.BlockdefChanges)
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
12 changes: 10 additions & 2 deletions MCGalaxy/Player/PlayerIgnores.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace MCGalaxy {

public class PlayerIgnores {
public List<string> Names = new List<string>(), IRCNicks = new List<string>();
public bool All, IRC, Titles, Nicks, EightBall, DrawOutput, WorldChanges;
public bool All, IRC, Titles, Nicks, EightBall, DrawOutput, WorldChanges, BlockdefChanges;

public void Load(Player p) {
string path = "ranks/ignore/" + p.name + ".txt";
Expand All @@ -42,6 +42,7 @@ public void Load(Player p) {
if (line == "&8ball") { EightBall = true; continue; }
if (line == "&drawoutput") { DrawOutput = true; continue; }
if (line == "&worldchanges") { WorldChanges = true; continue; }
if (line == "&blockdefchanges") { BlockdefChanges = true; continue; }

if (line.StartsWith("&irc_")) {
IRCNicks.Add(line.Substring("&irc_".Length));
Expand Down Expand Up @@ -75,6 +76,7 @@ public void Save(Player p) {
if (EightBall) w.WriteLine("&8ball");
if (DrawOutput) w.WriteLine("&drawoutput");
if (WorldChanges) w.WriteLine("&worldchanges");
if (BlockdefChanges) w.WriteLine("&blockdefchanges");

foreach (string nick in IRCNicks) { w.WriteLine("&irc_" + nick); }
foreach (string name in Names) { w.WriteLine(name); }
Expand All @@ -85,11 +87,14 @@ public void Save(Player p) {
}

public void Output(Player p) {
bool Nothing = !(All|IRC|Titles|Nicks|EightBall|DrawOutput|WorldChanges|BlockdefChanges);
if (Names.Count > 0) {
Nothing = false;
p.Message("&cCurrently ignoring the following players:");
p.Message(Names.Join(n => p.FormatNick(n)));
}
if (IRCNicks.Count > 0) {
Nothing = false;
p.Message("&cCurrently ignoring the following IRC nicks:");
p.Message(IRCNicks.Join());
}
Expand All @@ -103,6 +108,9 @@ public void Output(Player p) {
if (EightBall) p.Message("&cIgnoring &T/8ball");
if (DrawOutput) p.Message("&cIgnoring draw command output");
if (WorldChanges) p.Message("&cIgnoring world change messages");
if (BlockdefChanges) p.Message("&cIgnoring block definition messages");

if (Nothing) p.Message("&cIgnoring nothing and nobody");
}
}
}
}