MVdW Placeholders - Custom Placeholders

Nov 29, 2016
MVdW Placeholders - Custom Placeholders
  • Custom placeholders for MVdW-Software plugins

    When talking about custom placeholders there are two types.
    • Custom placeholders coded in a separate plugin that hooks into a MVdW-Software plugin
    • A javascript based placeholder that is created in the placeholder_custom.yml file under the directory /placeholders/ inside the plugins data folder.
    Custom coded placeholder plugins can be created using the API made available in each plugin.
    http://dl.mvdw-software.be/manuals/SpigotAnimationPluginsDevelopersGuide.pdf
    This API example is from ActionBar, but the same applies to other plugins

    Code (Text):
    package be.maximvdw.rainbownamesplaceholder;

    import org.bukkit.ChatColor;
    import org.bukkit.plugin.java.JavaPlugin;

    import be.maximvdw.featherboard.api.PlaceholderAPI;
    import be.maximvdw.featherboard.api.PlaceholderAPI.PlaceholderRequestEvent;
    import be.maximvdw.featherboard.api.PlaceholderAPI.PlaceholderRequestEventHandler;

    public class RainbowNamesPlaceholder extends JavaPlugin {

        @Override
        public void onEnable() {
            super.onEnable();

            PlaceholderAPI.registerOfflinePlaceholder("rainbowname", true,
                    new PlaceholderRequestEventHandler() {

                        @Override
                        public String onPlaceholderRequest(PlaceholderRequestEvent e) {
                            String playerName = e.getOfflinePlayer().getName();
                            String newName = "";
                            for (int i = 0; i < playerName.length(); i++) {
                                newName += ChatColor.values()[i]
                                        + String.valueOf(playerName.charAt(i));
                            }
                            return newName;
                        }
                    });
        }

    }

    The other type of custom placeholders are the javascript boolean placeholders. These placeholders can return a true and false state (at the moment) that changes depeding on the evaluated result of a javascript expression that can contain placeholders.

    Code (Text):
    ## --------------------------------------- ##
    ## Custom Skript Placeholders
    ## --------------------------------------- ##

    ## Do not edit this config version
    config: 1

    # Add your own placeholders under this category
    placeholders:
      ismaximcool: # this would be used as {ismaximcool}
        condition: "true" # has to be 'true' or 'false'  (in this case ofc true)
        true: "Ofc he is"
        false: "ERROR"
      healthyornot: # this would be used as {healthyornot}
        condition: "{health} > 10" # You can use other placeholders here
        true: "&aYou are healthy!"
        false: "&cEat something ..."
      nearbed: # this would be used as {nearbed}
        # So, this gets the absolute difference of your position minus your bed position and checks if its closer then 10
        condition: "(Math.abs({x} - {bed_x}) < 10) && (Math.abs({y} - {bed_y}) < 10) && (Math.abs({z} - {bed_z}) < 10)"
        true: "You are close"
        false: "Not so close"
    The condition is a javascript expression that can contain any placeholders. In the last example with {nearbed} it uses the {x} y,z... positions and the {bed_x} ,y,z positions
  • Loading...
  • Loading...