Developer API
On this page(6)
SnFullPvpCore exposes a public developer API for other plugins: custom Bukkit events and a
read-only query service. The API lives in the com.sn.fullpvpcore.api package inside the
plugin jar. There is no separate artifact.
Only com.sn.fullpvpcore.api is a stable, kept contract. Everything else in the jar is
obfuscated and internal. Do not call it.
Getting the jar
-
Download the latest release jar.
-
Install it into your local Maven repository:
mvn install:install-file -Dfile=SnFullPvpCore-<version>.jar -DgroupId=com.sn \ -DartifactId=SnFullPvpCore -Dversion=<version> -Dpackaging=jar -
Depend on it with
providedscope. Never shade it.
Quick start
Declare the dependency in your plugin.yml:
depend: [SnFullPvpCore] # or softdepend if optionalResolve the API when you need it:
SnFullPvpCoreAPI api = SnFullPvpCoreProvider.get();
if (api != null) {
// use the api
}Resolve the reference when you need it. Do not cache it across a SnFullPvpCore reload.
SnFullPvpCore is modular. A query whose module is turned off answers its neutral value: not
tagged, not protected, a zero balance, no item. Call isModuleEnabled when the difference
matters.
Master switch
API events can be disabled by the server owner with api-events.enabled: false in
config.yml. The query service stays available either way.
Events
Cancellable events fire before the action. Cancelling aborts it. All of them fire on the main thread.
| Event | Fired when | Cancel effect |
|---|---|---|
PlayerCombatTagEvent | A player who is not tagged is about to be combat-tagged. A refresh of a running tag does not fire it. A PvP hit fires one event per player, victim first. | The player stays untagged. No timer, no command block, no combat log. The hit itself still lands. |
PlayerPvpToggleEvent | A player runs /pvp on or /pvp off, after the zone rule, combat tag, cooldown and newbie confirmation checks passed. | The PvP state stays as it is and no cooldown starts. |
ItemUpgradeEvent | A player confirms an upgrade in the upgrade menu, after validation and before any cost is charged. | Nothing is charged and the item stays as it is. The menu stays open. |
Payload of each event:
| Event | Getters |
|---|---|
PlayerCombatTagEvent | getPlayer(), getOpponent() (null for a tag without one), isAttacker(), getDurationMillis() |
PlayerPvpToggleEvent | getPlayer(), isEnabling() (true for /pvp on, which also ends a running newbie protection) |
ItemUpgradeEvent | getPlayer(), getFromItemId(), getToItemId(), getItem() (a fresh copy on every call) |
SnFullPvpCore sends no message when a listener cancels. Tell the player why yourself.
Admin changes (/fullpvp pvp set) and the natural end of the newbie timer do not fire
PlayerPvpToggleEvent.
Listen like any Bukkit event:
@EventHandler
public void on(PlayerCombatTagEvent event) {
if (event.getPlayer().hasPermission("myplugin.notag")) {
event.setCancelled(true);
}
}Event payloads are read-only. setCancelled is the only change a listener can make.
Query service
Synchronous methods read in-memory state. Call them on the main thread.
| Method | Returns | Notes |
|---|---|---|
isModuleEnabled(String moduleId) | boolean | The id as written under modules: in config.yml. False for an unknown id. |
isTagged(UUID player) | boolean | Always false while the combat module is off. |
getTagRemainingMillis(UUID player) | long | 0 when the player is not tagged. |
isPvpProtected(Player player) | boolean | True when other players cannot damage this player where they stand. Follows PvP off, newbie protection, combat tag and zone rules. |
isNewbie(UUID player) | boolean | True while the newbie timer of an online, loaded player has time left. |
getCurrencies() | List<CurrencyView> | Every loaded currency, in file order. Immutable. |
getCurrency(String currencyId) | CurrencyView or null | Null for an unknown currency. |
getBalanceStored(UUID player, String currencyId) | long | Online players only. Stored in hundredths: 12345 means 123.45. 0 when offline or not loaded. |
getCoreItemId(ItemStack stack) | String or null | The core item id of an armor tier piece or an item of items/. |
getCoreItemIds() | List<String> | Every loaded core item id. Immutable. |
createItem(String itemId, int amount) | ItemStack or null | A fresh stack, exactly as the plugin gives it. The amount is clamped to the max stack size. |
getStreak(UUID player) | int | Current kill streak of an online player. Valid kills only. |
getApiVersion() | String | The API contract version. |
CurrencyView is an immutable record with id(), displayName(), symbol(), decimals()
and transferable(). The display name and symbol are raw &-code text.
Balances are always stored in hundredths, whatever the currency's decimals. Divide by 100
for the major unit.
Versioning
Call getApiVersion() for the API contract version. It is independent of the plugin version.
Additions bump the minor component. Existing members are never removed or changed; deprecated
members keep working.