From a48be853c66289ecb31dab5fb620ca6c6cbcfd48 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Wed, 23 Oct 2019 16:53:41 -0700 Subject: [PATCH] add tag player.fake_block_locations and fake_block[loc] --- .../denizen/objects/PlayerTag.java | 47 +++++++++++++++++++ .../commands/player/ShowFakeCommand.java | 3 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java index a6e0476f80..0d9d2be381 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/PlayerTag.java @@ -5,6 +5,7 @@ import com.denizenscript.denizen.scripts.commands.player.SidebarCommand; import com.denizenscript.denizen.utilities.DenizenAPI; import com.denizenscript.denizen.utilities.Utilities; +import com.denizenscript.denizen.utilities.blocks.FakeBlock; import com.denizenscript.denizen.utilities.debugging.Debug; import com.denizenscript.denizen.utilities.depends.Depends; import com.denizenscript.denizen.utilities.entity.BossBarHelper; @@ -2653,6 +2654,52 @@ public ObjectTag run(Attribute attribute, PlayerTag object) { return new ElementTag(suffix); } }); + + // <--[tag] + // @attribute + // @returns ListTag(LocationTag) + // @description + // Returns a list of locations that the player will see a fake block at, as set by <@link command showfake> or connected commands. + // --> + registerTag("fake_block_locations", new TagRunnable.ObjectForm() { + @Override + public ObjectTag run(Attribute attribute, PlayerTag object) { + ListTag list = new ListTag(); + FakeBlock.FakeBlockMap map = FakeBlock.blocks.get(object.getOfflinePlayer().getUniqueId()); + if (map != null) { + for (LocationTag loc : map.byLocation.keySet()) { + list.addObject(loc.clone()); + } + } + return list; + } + }); + + // <--[tag] + // @attribute ]> + // @returns MaterialTag + // @description + // Returns the fake material that the player will see at the input location, as set by <@link command showfake> or connected commands. + // Works best alongside <@link tag PlayerTag.fake_block_locations>. + // Returns null if the player doesn't have a fake block at the location. + // --> + registerTag("fake_block", new TagRunnable.ObjectForm() { + @Override + public ObjectTag run(Attribute attribute, PlayerTag object) { + if (!attribute.hasContext(1)) { + return null; + } + LocationTag input = LocationTag.valueOf(attribute.getContext(1)); + FakeBlock.FakeBlockMap map = FakeBlock.blocks.get(object.getOfflinePlayer().getUniqueId()); + if (map != null) { + FakeBlock block = map.byLocation.get(input); + if (block != null) { + return block.material; + } + } + return null; + } + }); } public static ObjectTagProcessor tagProcessor = new ObjectTagProcessor<>(); diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ShowFakeCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ShowFakeCommand.java index fb9e286d27..aab0a0ea91 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ShowFakeCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/player/ShowFakeCommand.java @@ -48,7 +48,8 @@ public class ShowFakeCommand extends AbstractCommand { // Note as well that some clientside block effects may occur (eg fake fire may appear momentarily to actually ignite things, but won't actually damage them). // // @Tags - // None + // + // ]> // // @Usage // Use to place a fake gold block at where the player is looking