Join our discord
In partnership with NodeCraft Logo NodeCraft


You are not logged in! Create an account or login to contribute! Log in here!

Difference between revisions of "Forge Placeholder API"

From Pixelmon Wiki
(creation of page for Forge Placeholder API)
 
m (added missing info)
Line 18: Line 18:
  
 
Required permission: papi.command
 
Required permission: papi.command
 +
 +
==Creating Custom Placeholders==
 +
 +
Add the follow to your build.gradle:
 +
 +
    repositories {
 +
        maven { url 'https://jitpack.io' }
 +
    }
 +
 +
    dependencies {
 +
        compileOnly 'com.github.Pixelmon-Development.ForgePlaceholderAPI:api:0.0.1'
 +
    }
 +
 +
The repository allows you to add the dependency directly from jitpack. Ensure to replace the version tag (0.0.1) with the latest release from this repository.
 +
 +
==Custom Placeholders==
 +
 +
Upon adding the dependency you will then be able to extend the PlaceholderManager interface like so:
 +
 +
public class ReforgedPlaceholders implements PlaceholderManager<EntityPlayerMP> {
 +
 +
    @Override
 +
    public String getIdentifier() {
 +
        return "reforged";
 +
    }
 +
 +
    @Override
 +
    public String[] getAuthors() {
 +
      return new String[] { "Envyful" };
 +
    }
 +
 +
    @Override
 +
    public String getVersion() {
 +
        return "1.0.0";
 +
    }
 +
 +
    @Override
 +
    public String getName() {
 +
        return getIdentifier();
 +
    }
 +
 +
    @Override
 +
    public String onPlaceholderRequest(EntityPlayerMP player, String placeholder) {
 +
        PlayerPartyStorage party = Pixelmon.storageManager.getParty(player);
 +
 +
        switch (placeholder.toLowerCase()) {
 +
            case "dex":
 +
                return String.format(
 +
                        "%.2f",
 +
                        ((party.pokedex.countCaught() + 0.000) / Pokedex.pokedexSize) * 100
 +
                ) + "%";
 +
        }
 +
 +
        return "UNDEFINED";
 +
    }
 +
}
 +
 +
Once this interface is registered it will add the "%reforged_dex%" placeholder returning the logic found in the switch statement.
 +
 +
==Registering Placeholders==
 +
 +
In order for your Placeholders to be registered place your jar file inside the "mods/ForgePlaceholderAPI/" directory on your server. Alternatively, you can register the placeholder directly using the method "PlaceholderFactory#register"
 +
 +
==Placeholder Extensions==
 +
 +
To add placeholder extensions navigate to the "mods/ForgePlaceholderAPI" directory (will auto-generate when the mod is first loaded) and place the jars into that folder. Upon the next server reboot the placeholders will be loaded into the ForgePlaceholderAPI mod and work for any mods/plugins using it.

Revision as of 08:44, 25 November 2021


Forge Placeholder API is a Pixelmon sidemod that manages placeholders.

Commands

Note: Command syntax is displayed in the standard Minecraft command format. An explanation of this format can be found here. There is currently only one command to list all active placeholder managers:

  • /placeholderapi
  • /papi
  • /forgeplaceholderapi
  • /fpapi

Required permission: papi.command

Creating Custom Placeholders

Add the follow to your build.gradle:

   repositories {
       maven { url 'https://jitpack.io' }
   }
   dependencies {
       compileOnly 'com.github.Pixelmon-Development.ForgePlaceholderAPI:api:0.0.1'
   }

The repository allows you to add the dependency directly from jitpack. Ensure to replace the version tag (0.0.1) with the latest release from this repository.

Custom Placeholders

Upon adding the dependency you will then be able to extend the PlaceholderManager interface like so:

public class ReforgedPlaceholders implements PlaceholderManager<EntityPlayerMP> {

   @Override
   public String getIdentifier() {
       return "reforged";
   }
   @Override
   public String[] getAuthors() {
      return new String[] { "Envyful" };
   }
   @Override
   public String getVersion() {
       return "1.0.0";
   }
   @Override
   public String getName() {
       return getIdentifier();
   }
   @Override
   public String onPlaceholderRequest(EntityPlayerMP player, String placeholder) {
       PlayerPartyStorage party = Pixelmon.storageManager.getParty(player);
       switch (placeholder.toLowerCase()) {
           case "dex":
               return String.format(
                       "%.2f",
                       ((party.pokedex.countCaught() + 0.000) / Pokedex.pokedexSize) * 100
               ) + "%";
       }
       return "UNDEFINED";
   }

}

Once this interface is registered it will add the "%reforged_dex%" placeholder returning the logic found in the switch statement.

Registering Placeholders

In order for your Placeholders to be registered place your jar file inside the "mods/ForgePlaceholderAPI/" directory on your server. Alternatively, you can register the placeholder directly using the method "PlaceholderFactory#register"

Placeholder Extensions

To add placeholder extensions navigate to the "mods/ForgePlaceholderAPI" directory (will auto-generate when the mod is first loaded) and place the jars into that folder. Upon the next server reboot the placeholders will be loaded into the ForgePlaceholderAPI mod and work for any mods/plugins using it.

© 2012 - 2025 Pixelmon Mod