diff --git a/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java b/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java index e80dd4cf7e..f010cf17cf 100644 --- a/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java +++ b/plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java @@ -2158,6 +2158,20 @@ else if (this.getWorld() == toLocation.getWorld()) { } } + // <--[tag] + // @attribute + // @returns Element + // @mechanism custom_name + // @description + // Returns the custom name of this block. + // Only works for nameable blocks, such as chests and dispensers. + // --> + if (attribute.startsWith("custom_name")) { + if (getBlock().getState() instanceof Nameable) { + return new Element(((Nameable) getBlock().getState()).getCustomName()).getAttribute(attribute.fulfill(1)); + } + } + // Iterate through this object's properties' attributes for (Property property : PropertyParser.getProperties(this)) { String returned = property.getAttribute(attribute); @@ -2419,6 +2433,28 @@ else if (getBlock().getType() == Material.FLOWER_POT) { } } + // <--[mechanism] + // @object dLocation + // @name custom_name + // @input Element + // @description + // Sets the custom name of the block. + // Use no value to reset the block's name. + // @tags + // + // --> + if (mechanism.matches("custom_name")) { + if (getBlock().getState() instanceof Nameable) { + String title = mechanism.getValue().asString(); + if (!mechanism.hasValue()) { + title = null; + } + BlockState state = getBlock().getState(); + ((Nameable) state).setCustomName(title); + state.update(true); + } + } + // <--[mechanism] // @object dLocation // @name furnace_burn_time