Java Code Examples for me.clip.placeholderapi.PlaceholderAPI#registerPlaceholderHook()

The following examples show how to use me.clip.placeholderapi.PlaceholderAPI#registerPlaceholderHook() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClipPlaceholderAPIHook.java    From factions-top with MIT License 6 votes vote down vote up
@Override
public boolean initialize(List<Integer> enabledRanks) {
    return PlaceholderAPI.registerPlaceholderHook("factionstop", new me.clip.placeholderapi.PlaceholderHook() {
        @Override
        public String onPlaceholderRequest(Player player, String identifier) {
            if ("name:last".equals(identifier)) {
                return lastReplacer.get();
            } else if ("rank:player".equals(identifier)) {
                return playerReplacer.apply(player);
            } else if (identifier.startsWith("name:")) {
                String[] split = identifier.split(":");
                if (split.length > 1) {
                    try {
                        int rank = Integer.parseInt(split[1]);
                        return rankReplacer.apply(rank);
                    } catch (NumberFormatException ignored) {}
                }
            }
            return null;
        }
    });
}
 
Example 2
Source File: PAPIHook.java    From Parties with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean register() {
	boolean ret = false;
	try {
		Class.forName("me.clip.placeholderapi.PlaceholderHook").getMethod("onRequest", OfflinePlayer.class, String.class);
		
		if (PlaceholderAPI.isRegistered(plugin.getPluginFallbackName())) {
			PlaceholderAPI.unregisterPlaceholderHook(plugin.getPluginFallbackName());
		}
		ret = PlaceholderAPI.registerPlaceholderHook(plugin.getPluginFallbackName(), this);
	} catch (Exception ex) {
		plugin.getLoggerManager().printError(Constants.DEBUG_ADDON_OUTDATED
				.replace("{addon}", "PlaceholderAPI"));
	}
	return ret;
}
 
Example 3
Source File: EZPlaceholderHook.java    From PlaceholderAPI with GNU General Public License v3.0 4 votes vote down vote up
public boolean hook() {
  return PlaceholderAPI.registerPlaceholderHook(identifier, this);
}