Placeholders and API
PlaceholderAPI placeholders and the Java API for other plugins.
Placeholders
With PlaceholderAPI installed, PandaDuels registers its placeholders at start and logs PlaceholderAPI found: %pandaduels_...% placeholders are on. No eCloud download is needed.
<kit> is a kit's id, such as nodebuff. Leave the kit off to get the player's overall numbers across all kits.
Player stats
These work for online players. For offline players they return an empty value.
| Placeholder | Returns |
|---|---|
%pandaduels_elo% | Overall Elo: the average of the kits the player has played ranked. ranked.start-elo before their first ranked match. |
%pandaduels_elo_<kit>% | Elo in a kit. |
%pandaduels_wins%, %pandaduels_wins_<kit>% | Wins. |
%pandaduels_losses%, %pandaduels_losses_<kit>% | Losses. |
%pandaduels_kills%, %pandaduels_kills_<kit>% | Kills. |
%pandaduels_deaths%, %pandaduels_deaths_<kit>% | Deaths. |
%pandaduels_streak%, %pandaduels_streak_<kit>% | Current win streak. |
%pandaduels_beststreak%, %pandaduels_beststreak_<kit>% | Best win streak. |
%pandaduels_winrate%, %pandaduels_winrate_<kit>% | Share of matches won, as a whole percentage such as 57%. |
%pandaduels_division%, %pandaduels_division_<kit>% | The division's key from config.yml, such as gold. Empty if no division matches. |
Player state
| Placeholder | Returns |
|---|---|
%pandaduels_in_match% | yes or no. |
%pandaduels_opponent% | Names of the players on the other side, separated by commas. Empty when not in a match. |
Server
| Placeholder | Returns |
|---|---|
%pandaduels_queued_<kit>% | Players waiting in the kit's unranked queue. A party of two counts as 2. |
%pandaduels_queued_<kit>_ranked% | Players waiting in the kit's ranked queue. |
%pandaduels_playing% | Players in a match right now. |
%pandaduels_playing_<kit>% | Players in a match of that kit right now. |
Leaderboards
%pandaduels_top_<column>_<kit>_<position>_<name|value>%| Part | Values |
|---|---|
<column> | elo, wins, kills or best_streak |
<kit> | A kit id, or all for all kits together |
<position> | 1 up to leaderboards.size (10 by default) |
name or value | The player's name, or their number |
Examples:
| Placeholder | Returns |
|---|---|
%pandaduels_top_elo_nodebuff_1_name% | Name of the player with the highest Nodebuff Elo. |
%pandaduels_top_elo_nodebuff_1_value% | That player's Elo. |
%pandaduels_top_wins_all_3_name% | Third most wins across all kits. |
%pandaduels_top_best_streak_all_1_value% | The best streak on the server. |
An empty position returns - for name and 0 for value. Leaderboard placeholders use the same cached boards as /leaderboard, refreshed every leaderboards.refresh-seconds.
Developer API
Other plugins can read PandaDuels' state and listen to its events. Add PandaDuels to your plugin's plugin.yml:
softdepend: [PandaDuels]Build against the PandaDuels jar, for example as a compileOnly file dependency in Gradle or a provided dependency in Maven. The API is in the dev.pandascript.pandaduels package.
Getting the plugin
PandaDuelsPlugin.get() returns the running plugin. From it you can reach every part of PandaDuels, for example:
| Method | Gives you |
|---|---|
matches() | Running matches. matches().of(uuid) returns the player's Match, or null. |
queues() | Queues. queues().isQueued(uuid) says whether a player is queued. |
profiles() | Online players' stats. profiles().get(uuid).elo("nodebuff") is their Elo in a kit. |
kits() | Kits. kits().get("nodebuff") returns a Kit, or null. |
arenas() | Arenas. |
parties() | Parties. parties().of(uuid) returns the player's Party, or null. |
tournaments() | The tournament. |
leaderboards() | The cached leaderboards. |
isBusy(uuid) | true while a player is in a match, queued, spectating, editing a kit or in a running tournament. |
Events
All events are in dev.pandascript.pandaduels.api.
| Event | When | Cancellable | Thread |
|---|---|---|---|
MatchStartEvent | A match starts its first countdown. getMatch() returns the Match. | No | Global thread |
MatchEndEvent | A match has ended, including cancelled matches. getResult() returns a MatchResult. | No | Global thread |
QueueJoinEvent | A player is about to join a queue. getPlayer(), getKit() (the kit id) and isRanked(). | Yes | The player's thread |
MatchResult has matchId(), spec(), winnerTeam() (-1 for a draw or a cancelled match), winners(), losers() and cancelled(). spec() gives the kit, the kind of match (DUEL, QUEUE, PARTY_DUEL, PARTY_FFA, PARTY_SPLIT or TOURNAMENT), whether it was ranked, the teams (lists of player UUIDs), the bet, whether it was a stake duel, and the rounds asked for (0 means the kit's own setting).
On Folia, the "global thread" is the global region thread, not the thread that owns any player. Don't change a player directly in a MatchStartEvent or MatchEndEvent handler on Folia; schedule the work on the player's own scheduler with player.getScheduler().run(...). On Paper both run on the main thread.
Example
This listener gives ranked winners a reward and keeps players below level 10 out of ranked queues.
import dev.pandascript.pandaduels.PandaDuelsPlugin;
import dev.pandascript.pandaduels.api.MatchEndEvent;
import dev.pandascript.pandaduels.api.QueueJoinEvent;
import dev.pandascript.pandaduels.match.MatchResult;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.UUID;
public final class DuelHooks implements Listener {
private final Plugin plugin;
public DuelHooks(Plugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onMatchEnd(MatchEndEvent event) {
MatchResult result = event.getResult();
if (result.cancelled() || result.winnerTeam() < 0 || !result.spec().ranked()) {
return;
}
for (UUID winner : result.winners()) {
Player player = Bukkit.getPlayer(winner);
if (player != null) {
player.getScheduler().run(plugin, task -> player.giveExp(50), null);
}
}
}
@EventHandler
public void onQueueJoin(QueueJoinEvent event) {
if (event.isRanked() && event.getPlayer().getLevel() < 10) {
event.setCancelled(true);
event.getPlayer().sendMessage("You need level 10 for ranked.");
}
}
public static boolean inMatch(Player player) {
return PandaDuelsPlugin.get().matches().of(player.getUniqueId()) != null;
}
}Register it in your plugin's onEnable with getServer().getPluginManager().registerEvents(new DuelHooks(this), this);.