Your cart is empty
Looks like the spiders padded through here. Pick a plugin and it will show up here. Continue shoppingWrite Java add-ons that listen to crate events, decide which reward a player wins, change the items that get delivered, and register your own opening animations. The API is only available in Phoenix Crates Premium.
Maven, exactly as documented on API:
<repositories>
<repository>
<id>phoenixplugins</id>
<url>https://repo.phoenixplugins.com/</url>
</repository>
</repositories>
<dependency>
<groupId>com.phoenixplugins.phoenixcrates</groupId>
<artifactId>api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
The docs only show Maven snippets; no Gradle snippet is documented yet. Dependency details: see API.
Create an addon.yml file in your project's resources folder.
name: AddonName
main: your.path.AddonExample
author: [YourName]
version: 1.0.0
description: Small description (optional)
website: https://your-website.com (optional)
Required fields:
name: Display name of your addon.main: Fully qualified path to your addon main class.author: One or more addon authors.version: Addon version.The main value in addon.yml must point to your class that extends Addon.
package your.path;
import com.phoenixplugins.phoenixcrates.api.sdk.plugin.addons.Addon;
public class AddonExample extends Addon {
@Override
public void onLoad() {
// Called when the addon is loaded.
}
@Override
public void onEnable() {
// Register listeners, commands, tasks, etc.
}
@Override
public void onDisable() {
// Cleanup logic.
}
@Override
public String getRequiredPluginVersion() {
return "5.0.0";
}
}
plugins/PhoenixCrates/addons.Source: Custom Addons.
11 documented events, from Events. All are Bukkit events, listened to with @EventHandler.
| Event | Fires when | Cancellable | Reference |
|---|---|---|---|
CratePlaceEvent |
A player places a crate item in the world | Yes | Docs · Javadoc |
CratePreviewOpenEvent |
The rewards preview menu is about to open | Yes | Docs · Javadoc |
CratePreOpenEvent |
An opening has been requested, before any check runs | Yes | Docs · Javadoc |
CrateOpenEvent |
The opening has started | No | Docs · Javadoc |
CrateRewardSelectionEvent |
A random crate is choosing which reward to award | No | Docs · Javadoc |
CrateSelectiveConfirmEvent |
A player confirms a reward in Selective mode | Yes | Docs · Javadoc |
CratePreRerollEvent |
A reroll has been requested | Yes | Docs · Javadoc |
CrateRerollEvent |
A reroll has produced a new reward | No | Docs · Javadoc |
CrateRewardWinItemsEvent |
The item list for a win has been built, before it is given | No | Docs · Javadoc |
CrateRewardPlayerEvent |
A player has been awarded a reward | No | Docs · Javadoc |
ItemDeliveryEvent |
Items are about to be delivered to a player | No | Docs · Javadoc |
Also in the javadoc, not yet described in the docs:
RewardCommandsEvent.
Validate opening attempts before they start, verbatim from Examples:
import com.phoenixplugins.phoenixcrates.api.crate.events.CratePreOpenEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public final class OpenGuardListener implements Listener {
@EventHandler
public void onPreOpen(CratePreOpenEvent event) {
if (!event.getPlayer().hasPermission("myaddon.open")) {
event.setCancelled(true);
event.getPlayer().sendMessage("You cannot open this crate right now.");
}
}
}
The docs don't show listener registration inside an add-on yet.
More examples: Examples.
Example Crate, verbatim from Crate Configuration File:
enabled: true
identifier: example1
item:
material: custom:example_crate
amount: 1
display-name: '&eExample #1'
block-material: BROWN_WOOL
engine: VANILLA_BLOCK
open-cost:
engine: NONE
amount: 0.0
currency: ''
key-skips-cost: false
open-cooldown: 0
simultaneous-openings: true
preview-item: false
permission:
required: false
permission: phoenixcrates.crate.example1
idle-effects:
- CIRCLE;{REDSTONE;#ff0000;0.0;1.0;2.0;0.0;0.0;1}
opening-animation:
pre-open: DEFAULT
open: SPOTLIGHT_GUI
display: NONE
hologram:
type: BUILTIN
offset: 0.0
lines:
- '&e&l%name%'
- ''
- '&aRight &7Click to open'
- '&cLeft &7Click to preview'
menus:
rewards: default_rewards_preview
select-reward: default_select_reward
rerolls: default_crate_reroll
preview-actions: []
key-required: true
linked-keys-ids:
- example1
allow-open-command: true
broadcast:
message: '&ePlayer &a%player% &ejust got &6"%reward%" &ereward from the crate &6%crate%&e!'
max-win-rewards: 0
rewards-mode: RANDOM
rewards:
'0':
enabled: true
identifier: reward_1783907600221
display-item:
material: custom:example_crate
amount: 4
win-items:
'0':
material: custom:grass_block
amount: 1
win-commands: []
broadcast: false
weight: 100.0
win-limits: -1
global-win-limit: -1
cooldowns:
win-limit-cooldown: 0
global-win-limit-cooldown: 0
time-limited-cooldown: 0
time-limited-expiry: 0
guaranteed-win: -1
required-keys: 1
allow-win-message: false
notification-type: CHAT
share-players-online: false
restricted-permissions: []
required-permissions: []
max-win:
item-amount: 1
command-amount: -1
alternative-reward:
enabled: false
reward:
item:
material: DIAMOND_PICKAXE
display-name: '&aAlternative Item'
amount: 1
virtual: false
broadcast: false
allow-win-message: true
share-players-online: false
commands: []
guaranteed-reward-type: DISABLED
reroll:
enabled: false
free-rolls: 0
groups:
'0':
namespace: common
rerolls: 3
replay-animation: false
skip-same-reward: false
extra-settings:
animation:
display-item-position:
x: 0.0
y: 2.0
z: 0.0
display-item-name-position:
x: 0.0
y: 0.3
z: 0.0
skip-on-esc: false
clicks:
open: RIGHT
preview: LEFT
event-actions:
open: []
win: []
close: []
denied: []
For offline reading, scripts and tools, all Phoenix Crates docs are available as one text file. Any docs page can be read as plain markdown by adding .md to its URL.
Your cart is empty
Looks like the spiders padded through here. Pick a plugin and it will show up here. Continue shopping