Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(MaterialMode.class, MaterialTag.class);
PropertyParser.registerProperty(MaterialNote.class, MaterialTag.class);
PropertyParser.registerProperty(MaterialPersistent.class, MaterialTag.class);
PropertyParser.registerProperty(MaterialPowerable.class, MaterialTag.class);
PropertyParser.registerProperty(MaterialPower.class, MaterialTag.class);
PropertyParser.registerProperty(MaterialShape.class, MaterialTag.class);
PropertyParser.registerProperty(MaterialSides.class, MaterialTag.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.denizenscript.denizen.objects.properties.material;

import com.denizenscript.denizen.objects.MaterialTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.block.data.Powerable;

public class MaterialPowerable extends MaterialProperty<ElementTag> {

// <--[property]
// @object MaterialTag
// @name powered
// @input ElementTag(Boolean)
// @description
// Controls whether the material is powered.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say something about redstone, both for ease of searching and to make it clearer - redstone powered, is powered (receiving a redstone signal of above 0). or something like that

// -->

public static boolean describes(MaterialTag material) {
return material.getModernData() instanceof Powerable;
}

public MaterialPowerable(MaterialTag material) {
super(material);
}
Comment on lines +22 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed with the modern property syntax?


@Override
public ElementTag getPropertyValue() {
if (getBlockData() instanceof Powerable powerable) {
return new ElementTag(powerable.isPowered());
}
return null;
}

@Override
public String getPropertyId() {
return "powered";
}

@Override
public void setPropertyValue(ElementTag elementTag, Mechanism mechanism) {
if (getBlockData() instanceof Powerable powerable && mechanism.requireBoolean()) {
powerable.setPowered(elementTag.asBoolean());
}
}

public static void register() {
autoRegister("powered", MaterialPowerable.class, ElementTag.class, false);
}
}