Skip to content

Structure Configuration Signs

Ryandw11 edited this page Mar 19, 2023 · 1 revision

Using CustomStructure Addons, developers can define custom Structure Configuration Signs for use.

To create a custom configuration sign, create a new class that extends the abstract class StructureSign:

public class CustomSign extends StructureSign {
    @Override
    public boolean onStructureSpawn(@NotNull Location location, @NotNull Structure structure) {
        return true;
    }
}

Your class is required to implement the onStructureSpawn method. This method is called when your structure sign is detected within a spawned structure and is being replaced. The return value determines whether or not the sign should be replaced with air. If you return true, then the sign will be removed. If false is returned, then the sign is not removed.

Note: The default constructor must exist.

Example

In this example, the sign broadcasts the messages specified on the second line, x amount of times. x is defined by the third line on the sign.

[CustomSign]
{message}
{count}
public class CustomSign extends StructureSign {
    @Override
    public boolean onStructureSpawn(@NotNull Location location, @NotNull Structure structure) {
        if(!hasArgument(0)) {
            Bukkit.broadcastMessage("No message defined!");
            return true;
        }

        String message = getStringArgument(0);

        int messageCount = 1;
        if(hasArgument(1)) {
            messageCount = getStylizedIntArgument(1);
        }

        for(int i = 0; i < messageCount; i++) {
            Bukkit.broadcastMessage(message);
        }

        return true;
    }
}

Registering a Custom Sign

You register a custom sign using your CustomStructureAddon class.

myAddon.registerStructureSign("CustomSign", CustomSign.class);

Examples