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

The following examples show how to use me.clip.placeholderapi.PlaceholderAPI#setPlaceholders() . 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: MsgUtil.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
/**
 * getMessage in messages.yml
 *
 * @param loc    location
 * @param player The sender will send the message to
 * @param args   args
 * @return message
 */
public static String getMessageOfflinePlayer(
        @NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) {
    try {
        Optional<String> raw = messagei18n.getString(loc);
        if (!raw.isPresent()) {
            return invaildMsg + ": " + loc;
        }
        String filled = fillArgs(raw.get(), args);
        if (player != null) {
            if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled() && plugin.getConfig().getBoolean("plugin.PlaceHolderAPI")) {
                filled = PlaceholderAPI.setPlaceholders(player, filled);
                Util.debugLog("Processed message " + filled + " by PlaceHolderAPI.");
            }
        }
        return filled;
    } catch (Throwable th) {
        plugin.getSentryErrorReporter().ignoreThrow();
        th.printStackTrace();
        return "Cannot load language key: " + loc + " because something not right, check the console for details.";
    }
}
 
Example 2
Source File: PluginHooks.java    From TAB with Apache License 2.0 5 votes vote down vote up
public static String PlaceholderAPI_setPlaceholders(Player player, String placeholder) {
	if (!placeholderAPI) return placeholder;
	try {
		return PlaceholderAPI.setPlaceholders(player, placeholder);
	} catch (Throwable t) {
		String playername = (player == null ? "null" : player.getName());
		Plugin papi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
		if (papi != null) {
			Shared.errorManager.printError("PlaceholderAPI v" + papi.getDescription().getVersion() + " generated an error when setting placeholder " + placeholder + " for player " + playername, t, false, Configs.papiErrorFile);
		} else {
			placeholderAPI = false;
		}
		return "ERROR";
	}
}
 
Example 3
Source File: MsgUtil.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
/**
 * getMessage in messages.yml
 *
 * @param loc    location
 * @param args   args
 * @param player The sender will send the message to
 * @return message
 */
public static String getMessage(
        @NotNull String loc, @Nullable CommandSender player, @NotNull String... args) {
    try {
        final Optional<String> raw = messagei18n.getString(loc);
        if (!raw.isPresent()) {
            Util.debugLog("ERR: MsgUtil cannot find the the phrase at " + loc + ", printing the all readed datas: " + messagei18n);

            return invaildMsg + ": " + loc;
        }
        String filled = fillArgs(raw.get(), args);
        if (player instanceof OfflinePlayer) {
            if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled() && plugin.getConfig().getBoolean("plugin.PlaceHolderAPI")) {
                try {
                    filled = PlaceholderAPI.setPlaceholders((OfflinePlayer) player, filled);
                } catch (Exception ignored) {
                    if (((OfflinePlayer) player).getPlayer() != null) {
                        try {
                            filled = PlaceholderAPI.setPlaceholders(((OfflinePlayer) player).getPlayer(), filled);
                        } catch (Exception ignore) {
                        }
                    }
                }
            }
        }
        return filled;
    } catch (Throwable th) {
        plugin.getSentryErrorReporter().ignoreThrow();
        th.printStackTrace();
        return "Cannot load language key: " + loc + " because something not right, check the console for details.";
    }
}
 
Example 4
Source File: PlaceholderAPIBridge.java    From ChestCommands with GNU General Public License v3.0 5 votes vote down vote up
public static String setPlaceholders(String message, Player executor) {
	if (!hasValidPlugin()) {
		throw new IllegalStateException("PlaceholderAPI plugin was not found!");
	}

	return PlaceholderAPI.setPlaceholders(executor, message);
}
 
Example 5
Source File: Vars.java    From TrMenu with MIT License 4 votes vote down vote up
private static String setPlaceholders(Player player, String string) {
    return PlaceholderAPI.setPlaceholders(player, replaceMenuVariables(player, string));
}
 
Example 6
Source File: BridgeImpl.java    From TabooLib with MIT License 4 votes vote down vote up
@Override
public String setPlaceholders(Player player, String args) {
    return placeholder ? PlaceholderAPI.setPlaceholders(player, args) : args;
}
 
Example 7
Source File: BridgeImpl.java    From TabooLib with MIT License 4 votes vote down vote up
@Override
public List<String> setPlaceholders(Player player, List<String> args) {
    return placeholder ? PlaceholderAPI.setPlaceholders(player, args) : args;
}
 
Example 8
Source File: LocaleManager.java    From Civs with GNU General Public License v3.0 4 votes vote down vote up
public String replacePlaceholders(OfflinePlayer player, String input) {
    if (Civs.placeholderAPI == null) {
        return input;
    }
    return PlaceholderAPI.setPlaceholders(player, input);
}
 
Example 9
Source File: PAPIHook.java    From Parties with GNU Affero General Public License v3.0 4 votes vote down vote up
public String setPlaceholders(OfflinePlayer player, String msg) {
	return PlaceholderAPI.setPlaceholders(player, msg);
}
 
Example 10
Source File: HookPlaceholderAPI.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static String replacePlaceholders(Player player, String string) {
    return PlaceholderAPI.setPlaceholders(player, string);
}
 
Example 11
Source File: PlaceholderAPIHook.java    From SuperVanish with Mozilla Public License 2.0 4 votes vote down vote up
public static String translatePlaceholders(String msg, Player p) {
    return PlaceholderAPI.setPlaceholders(p, msg);
}
 
Example 12
Source File: PlaceholderVariable.java    From BetonQuest with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String getValue(String playerID) {
    return PlaceholderAPI.setPlaceholders(PlayerConverter.getPlayer(playerID), '%' + placeholder + '%');
}
 
Example 13
Source File: DependPlaceHolderAPI.java    From HubBasics with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String setPlaceHolders(Player player, String message) {
    return PlaceholderAPI.setPlaceholders(player, message);
}
 
Example 14
Source File: PlaceholderAPIHook.java    From FunnyGuilds with Apache License 2.0 4 votes vote down vote up
public static String replacePlaceholders(Player user, String base) {
    return PlaceholderAPI.setPlaceholders(user, base, PLACEHOLDER_PATTERN);
}
 
Example 15
Source File: PlaceholderAPIHook.java    From AntiVPN with MIT License votes vote down vote up
public String withPlaceholders(Player player, String input) { return PlaceholderAPI.setPlaceholders(player, input); } 
Example 16
Source File: PlaceholderAPIHook.java    From AntiVPN with MIT License votes vote down vote up
public String withPlaceholders(OfflinePlayer player, String input) { return PlaceholderAPI.setPlaceholders(player, input); }