Skip to content

Commit

Permalink
Add blockdef ignores flag
Browse files Browse the repository at this point in the history
Rename to BlockdefChanges
  • Loading branch information
rdebath committed Apr 23, 2021
1 parent 4c42433 commit b3036f3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions MCGalaxy/Blocks/BlockOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ 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;
if (!p.Ignores.DrawOutput) {
if (!p.Ignores.BlockdefChanges) {
string name = BlockProps.ScopedName(scope, p, block);
p.Message("Block {0} is {1}: {2}", name, type, on ? "&aYes" : "&cNo");
}
Expand Down Expand Up @@ -152,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 if (!p.Ignores.DrawOutput) {
} else if (!p.Ignores.BlockdefChanges) {
p.Message("Stack block for {0} set to: {1}",
name, BlockProps.ScopedName(scope, p, stackBlock));
}
Expand All @@ -170,7 +170,7 @@ static void SetBlock(Player p, BlockProps[] scope, BlockID block,
if (other == block) { p.Message("ID of {0} must be different.", type); return; }

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

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

Expand Down Expand Up @@ -198,7 +198,7 @@ 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";

if (!p.Ignores.DrawOutput)
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 @@ -287,7 +287,7 @@ static bool DoRemove(Player p, Level lvl, BlockID block,
BlockDefinition[] defs = global ? BlockDefinition.GlobalDefs : lvl.CustomBlockDefs;
BlockDefinition def = defs[block];
if (!ExistsInScope(def, block, global)) {
if (!p.Ignores.DrawOutput)
if (!p.Ignores.BlockdefChanges)
MessageNoBlock(p, block, global, cmd);
return false;
}
Expand All @@ -296,7 +296,7 @@ static bool DoRemove(Player p, Level lvl, BlockID block,
ResetProps(global, lvl, block, p);

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

BlockDefinition globalDef = BlockDefinition.GlobalDefs[block];
Expand Down Expand Up @@ -533,15 +533,15 @@ static bool DoEdit(Player p, Level lvl, BlockID block, string[] parts,

def.InventoryOrder = order == def.RawID ? -1 : order;
BlockDefinition.UpdateOrder(def, global, lvl);
if (!p.Ignores.DrawOutput)
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;
}

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

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

block = def.GetBlock();
Expand Down
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.");
}
}
}
2 changes: 1 addition & 1 deletion MCGalaxy/Commands/World/CmdBlockProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void ResetProps(Player p, BlockProps[] scope, BlockID block) {
scope[block] = BlockProps.MakeDefault(scope, p.level, block);
string name = BlockProps.ScopedName(scope, p, block);

if (!p.Ignores.BlockDef)
if (!p.Ignores.BlockdefChanges)
p.Message("Reset properties of {0} to default", name);
BlockProps.ApplyChanges(scope, p.level, block, true);
}
Expand Down
7 changes: 5 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,7 +87,7 @@ public void Save(Player p) {
}

public void Output(Player p) {
bool Nothing = !(All|IRC|Titles|Nicks|EightBall|DrawOutput|WorldChanges);
bool Nothing = !(All|IRC|Titles|Nicks|EightBall|DrawOutput|WorldChanges|BlockdefChanges);
if (Names.Count > 0) {
Nothing = false;
p.Message("&cCurrently ignoring the following players:");
Expand All @@ -106,6 +108,7 @@ 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");
}
Expand Down

0 comments on commit b3036f3

Please sign in to comment.