Skip to content

Commit

Permalink
Add some javadoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre601 authored Apr 24, 2019
1 parent a1d15b8 commit 3867194
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,74 @@
import me.clip.placeholderapi.expansion.PlaceholderExpansion;

public class ExampleExpansion extends PlaceholderExpansion {

private final String VERSION = getClass().getPackage().getImplementationVersion();
private DeluxeTags deluxeTags;

/**
* Defines the name of the expansion that is also used in the
* placeholder itself.
*
* @return {@code example} as String
*/
@Override
public String getIdentifier() {
return "example";
}

/**
* The author of the expansion.
*
* @return {@code everyone} as String
*/
@Override
public String getAuthor() {
return "everyone";
}

/**
* Returns the version of the expansion as String.
*
* @return The VERSION String
*/
@Override
public String getVersion() {
return VERSION;
}

/**
* Returns the name of the required plugin.
*
* @return {@code DeluxeTags} as String
*/
@Override
public String getRequiredPlugin() {
return "DeluxeTags";
}

/**
* Used to check if the expansion is able to register.
*
* @return true or false depending on if the required plugin is installed
*/
@Override
public boolean canRegister() {
if (!Bukkit.getPluginManager().isPluginEnabled(getRequiredPlugin())) { return false; }
deluxeTags = (DeluxeTags) Bukkit.getPluginManager().getPlugin(getRequiredPlugin());
return super.register() && deluxeTags != null;
}

/**
* This method is called when a placeholder is used and maches the set
* {@link #getIdentifier() identifier}
*
* @param offlinePlayer
* The player to parse placeholders for
* @param params
* The part after the identifier ({@code %identifier_params%})
*
* @return Possible-null String
*/
@Override
public String onRequest(OfflinePlayer offlinePlayer, String params) {
if (params.equals("test")) { return "success"; }
Expand All @@ -48,15 +85,20 @@ public String onRequest(OfflinePlayer offlinePlayer, String params) {
switch (params) {
case "name":
return player.getName();

case "display_name":
return player.getDisplayName();

case "gamemode":
return player.getGameMode().name();

case "health":
return Double.toString(player.getHealth());

case "tag_menu_name":
String name = deluxeTags.getGuiOptions().getMenuName();
return name != null ? name : "";

default:
return null;
}
Expand Down

0 comments on commit 3867194

Please sign in to comment.