me.clip.placeholderapi.PlaceholderAPI Java Examples
The following examples show how to use
me.clip.placeholderapi.PlaceholderAPI.
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: PlaceHolderVariables.java From ScoreboardStats with MIT License | 6 votes |
@Override public void register() { Set<String> variables = Sets.newHashSet(); Collection<PlaceholderHook> hooks = PlaceholderAPI.getPlaceholders().values(); for (PlaceholderHook hook : hooks) { String variablePrefix = null; if (hook instanceof EZPlaceholderHook) { variablePrefix = ((EZPlaceholderHook) hook).getPlaceholderName(); } else if (hook instanceof PlaceholderExpansion) { variablePrefix = ((PlaceholderExpansion) hook).getIdentifier(); } if (variablePrefix != null) { variables.add(variablePrefix + "_*"); } } for (String variable : variables) { register(variable).supply(player -> PlaceholderAPI.setPlaceholders(player, '%' + variable + '%')); } }
Example #2
Source File: Item.java From TrMenu with MIT License | 6 votes |
public Item(List<String> names, List<Mat> materials, List<List<String>> lores, List<List<Integer>> slots, List<ItemFlag> itemFlags, NBTCompound nbtCompound, String shiny, String amount) { this.names = names; this.materials = materials; this.lores = lores; this.rawSlots = slots; this.itemFlags = itemFlags; this.nbtCompound = nbtCompound; this.shiny = shiny; this.amount = amount; this.finalShiny = Boolean.parseBoolean(shiny); this.finalAmount = NumberUtils.toInt(amount, -1); this.curSlots = new HashMap<>(); this.slots = new HashMap<>(); this.indexMap = new HashMap<>(); this.updateNbt = PlaceholderAPI.containsPlaceholders(nbtCompound.toJsonSimplified()); }
Example #3
Source File: CommandTask.java From DungeonsXL with GNU General Public License v3.0 | 6 votes |
@Override public void run() { if (sign.isWorldFinished()) { sign.deactivate(); return; } if (k >= script.getCommands().size()) { sign.deactivate(); k = 0; } String command = script.getCommands().get(k++) .replace("%player%", sender.getName()).replace("%player_name%", sender.getName()) .replace("%world%", sign.getGameWorld().getWorld().getName()).replace("%world_name%", sign.getGameWorld().getWorld().getName()); if (papi) { Bukkit.getServer().dispatchCommand(sender, PlaceholderAPI.setPlaceholders(player, command)); } else { Bukkit.getServer().dispatchCommand(sender, command); } }
Example #4
Source File: MsgUtil.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
/** * 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 #5
Source File: ClipPlaceholderAPIHook.java From factions-top with MIT License | 6 votes |
@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 #6
Source File: PluginHooks.java From TAB with Apache License 2.0 | 5 votes |
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 #7
Source File: ClipsPlaceholderHook.java From MarriageMaster with GNU General Public License v3.0 | 5 votes |
@Override public void close() { if(PlaceholderAPI.unregisterExpansion(this)) { plugin.getLogger().info(ConsoleColor.GREEN + "PlaceholderAPI hook was successfully unregistered!" + ConsoleColor.RESET); } else { plugin.getLogger().info(ConsoleColor.RED + "PlaceholderAPI hook failed to unregistered!" + ConsoleColor.RESET); } }
Example #8
Source File: PlaceholderAPIBridge.java From ChestCommands with GNU General Public License v3.0 | 5 votes |
public static String setPlaceholders(String message, Player executor) { if (!hasValidPlugin()) { throw new IllegalStateException("PlaceholderAPI plugin was not found!"); } return PlaceholderAPI.setPlaceholders(executor, message); }
Example #9
Source File: PlaceholderAPIBridge.java From ChestCommands with GNU General Public License v3.0 | 5 votes |
public static boolean hasPlaceholders(String message) { if (!hasValidPlugin()) { throw new IllegalStateException("PlaceholderAPI plugin was not found!"); } return PlaceholderAPI.containsPlaceholders(message); }
Example #10
Source File: PlaceholderAPIDataAccess.java From BungeeTabListPlus with GNU General Public License v3.0 | 5 votes |
public PlaceholderAPIDataAccess(Logger logger, Plugin plugin) { super(logger, plugin); addProvider(BTLPDataKeys.PAPIPlaceholder, (player, key) -> { try { return PlaceholderAPI.setPlaceholders(player, key.getParameter()); } catch (Throwable th) { logger.log(Level.WARNING, "Failed to query value for placeholder \"" + key.getParameter() + "\" from PlaceholderAPI", th); return null; } }); }
Example #11
Source File: PAPIHook.java From Parties with GNU Affero General Public License v3.0 | 5 votes |
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 #12
Source File: PlaceholderAPIEvaluateTaskType.java From Quests with MIT License | 5 votes |
@Override public void onReady() { this.poll = new BukkitRunnable() { @Override public void run() { for (Player player : Bukkit.getOnlinePlayers()) { QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(player.getUniqueId(), true); QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile(); for (Quest quest : PlaceholderAPIEvaluateTaskType.super.getRegisteredQuests()) { if (questProgressFile.hasStartedQuest(quest)) { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(PlaceholderAPIEvaluateTaskType.super.getType())) { TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { continue; } String placeholder = (String) task.getConfigValue("placeholder"); String evaluates = (String) task.getConfigValue("evaluates"); if (placeholder != null) { if (PlaceholderAPI.setPlaceholders(player, placeholder).equals(evaluates)) { taskProgress.setCompleted(true); } } } } } } } }.runTaskTimer(Quests.get(), 30L, 30L); }
Example #13
Source File: TabExpansion.java From TAB with Apache License 2.0 | 5 votes |
@Override public void unload() { try { PlaceholderAPI.unregisterExpansion(this); } catch (Exception ExpansionUnregisterEventMayOnlyBeTriggeredSynchronously) { // java.lang.IllegalStateException: ExpansionUnregisterEvent may only be triggered synchronously. } }
Example #14
Source File: PluginHooks.java From TAB with Apache License 2.0 | 5 votes |
public static String PlaceholderAPI_setRelationalPlaceholders(ITabPlayer viewer, ITabPlayer target, String placeholder) { if (!placeholderAPI) return placeholder; try { return PlaceholderAPI.setRelationalPlaceholders(viewer.getBukkitEntity(), target.getBukkitEntity(), placeholder); } catch (Throwable t) { Plugin papi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI"); if (papi != null) { Shared.errorManager.printError("PlaceholderAPI v" + papi.getDescription().getVersion() + " generated an error when setting relational placeholder " + placeholder + " for viewer " + viewer.getName() + " and target " + target.getName(), t, false, Configs.papiErrorFile); } else { placeholderAPI = false; } } return placeholder; }
Example #15
Source File: Menu.java From TrMenu with MIT License | 5 votes |
/** * 检测菜单需要的 PlaceholderAPI 依赖并自动下载 * * @return 未安装的 */ @Deprecated private List<String> checkDepends() { List<String> unInstalled = Lists.newArrayList(); if (PlaceholderAPIPlugin.getInstance().getExpansionCloud() == null) { return unInstalled; } try { if (dependExpansions != null && dependExpansions.size() > 0) { if (PlaceholderAPIPlugin.getInstance().getExpansionCloud().getCloudExpansions().isEmpty()) { PlaceholderAPIPlugin.getInstance().getExpansionCloud().fetch(false); return dependExpansions.stream().filter(d -> PlaceholderAPI.getExpansions().stream().noneMatch(e -> e.getName().equalsIgnoreCase(d))).collect(Collectors.toList()); } unInstalled = dependExpansions.stream().filter(d -> PlaceholderAPI.getExpansions().stream().noneMatch(e -> e.getName().equalsIgnoreCase(d)) && PlaceholderAPIPlugin.getInstance().getExpansionCloud().getCloudExpansion(d) != null && !PlaceholderAPIPlugin.getInstance().getExpansionCloud().isDownloading(d)).collect(Collectors.toList()); if (unInstalled.size() > 0) { unInstalled.forEach(ex -> { CloudExpansion cloudExpansion = PlaceholderAPIPlugin.getInstance().getExpansionCloud().getCloudExpansion(ex); PlaceholderAPIPlugin.getInstance().getExpansionCloud().downloadExpansion(null, cloudExpansion); }); Bukkit.getScheduler().runTaskLater(TrMenu.getPlugin(), () -> PlaceholderAPIPlugin.getInstance().reloadConf(Bukkit.getConsoleSender()), 20 * 5); } } } catch (Throwable ignored) { } return unInstalled; }
Example #16
Source File: ExpansionManager.java From PlaceholderAPI with GNU General Public License v3.0 | 5 votes |
public PlaceholderExpansion getRegisteredExpansion(String name) { for (Entry<String, PlaceholderHook> hook : PlaceholderAPI.getPlaceholders().entrySet()) { if (hook.getValue() instanceof PlaceholderExpansion) { if (name.equalsIgnoreCase(hook.getKey())) { return (PlaceholderExpansion) hook.getValue(); } } } return null; }
Example #17
Source File: AbstractAction.java From TrMenu with MIT License | 5 votes |
public void run(Player player) { MetricsHandler.increase(1); if (options.containsKey(EnumOption.CHANCE) && !Numbers.random(NumberUtils.toDouble(options.get(EnumOption.CHANCE), 1))) { return; } if (options.containsKey(EnumOption.REQUIREMENT) && !(boolean) JavaScript.run(player, options.get(EnumOption.REQUIREMENT))) { return; } if (options.containsKey(EnumOption.PLAYERS)) { Bukkit.getOnlinePlayers().stream().filter(p -> (boolean) JavaScript.run(p, options.get(EnumOption.PLAYERS))).collect(Collectors.toList()).forEach(x -> onExecute(x, getContent() != null ? PlaceholderAPI.setBracketPlaceholders(player, getContent()) : null)); return; } if (options.containsKey(EnumOption.DELAY)) { int delay = NumberUtils.toInt(options.get(EnumOption.DELAY), -1); if (delay > 0) { Bukkit.getScheduler().runTaskLaterAsynchronously(TrMenu.getPlugin(), () -> { if (options.containsKey(EnumOption.PLAYERS)) { Bukkit.getOnlinePlayers().stream().filter(p -> (boolean) JavaScript.run(p, getContent())).collect(Collectors.toList()).forEach(this::onExecute); return; } onExecute(player); }, delay); } return; } onExecute(player); }
Example #18
Source File: MsgUtil.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
/** * 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 #19
Source File: HookPlaceholderAPI.java From CombatLogX with GNU General Public License v3.0 | 4 votes |
public static String replacePlaceholders(Player player, String string) { return PlaceholderAPI.setPlaceholders(player, string); }
Example #20
Source File: Vars.java From TrMenu with MIT License | 4 votes |
private static String setPlaceholders(Player player, String string) { return PlaceholderAPI.setPlaceholders(player, replaceMenuVariables(player, string)); }
Example #21
Source File: PlaceholderAPIHook.java From FunnyGuilds with Apache License 2.0 | 4 votes |
public static String replacePlaceholders(Player user, String base) { return PlaceholderAPI.setPlaceholders(user, base, PLACEHOLDER_PATTERN); }
Example #22
Source File: PlaceholderAPIHook.java From BungeeTabListPlus with GNU General Public License v3.0 | 4 votes |
public List<String> getRegisteredPlaceholderPlugins() { return Lists.newArrayList(PlaceholderAPI.getRegisteredPlaceholderPlugins()); }
Example #23
Source File: DependPlaceHolderAPI.java From HubBasics with GNU Lesser General Public License v3.0 | 4 votes |
public String setPlaceHolders(Player player, String message) { return PlaceholderAPI.setPlaceholders(player, message); }
Example #24
Source File: PlaceholderVariable.java From BetonQuest with GNU General Public License v3.0 | 4 votes |
@Override public String getValue(String playerID) { return PlaceholderAPI.setPlaceholders(PlayerConverter.getPlayer(playerID), '%' + placeholder + '%'); }
Example #25
Source File: PremiumPlaceholder.java From FastLogin with MIT License | 4 votes |
public static void unregisterAll(FastLoginBukkit plugin) { PlaceholderAPI.unregisterPlaceholderHook(plugin.getName()); }
Example #26
Source File: PlaceholderAPIHook.java From SuperVanish with Mozilla Public License 2.0 | 4 votes |
public static String translatePlaceholders(String msg, Player p) { return PlaceholderAPI.setPlaceholders(p, msg); }
Example #27
Source File: PAPIHook.java From Parties with GNU Affero General Public License v3.0 | 4 votes |
public String setPlaceholders(OfflinePlayer player, String msg) { return PlaceholderAPI.setPlaceholders(player, msg); }
Example #28
Source File: LocaleManager.java From Civs with GNU General Public License v3.0 | 4 votes |
public String replacePlaceholders(OfflinePlayer player, String input) { if (Civs.placeholderAPI == null) { return input; } return PlaceholderAPI.setPlaceholders(player, input); }
Example #29
Source File: ExpansionCloudManager.java From PlaceholderAPI with GNU General Public License v3.0 | 4 votes |
public int getToUpdateCount() { return ((int) PlaceholderAPI.getExpansions() .stream() .filter(ex -> getCloudExpansion(ex.getName()) != null && getCloudExpansion(ex.getName()).shouldUpdate()) .count()); }
Example #30
Source File: BridgeImpl.java From TabooLib with MIT License | 4 votes |
@Override public List<String> setPlaceholders(Player player, List<String> args) { return placeholder ? PlaceholderAPI.setPlaceholders(player, args) : args; }