DriftCrates
Crates with animations you can write yourself.
Crates for Paper 26.3: keys, opening animations you can make yourself, an in-game editor, pick-your-reward crates, crate items, particle effects, previews with real chances, reward limits that reset, milestones and virtual keys that work across a network. Part of DriftSuite.
Features
- In-game editor:
/crate editormakes, changes and deletes crates, keys, rewards and milestones from menus. Every change is saved to the crate's file straight away. - Crates as files: one file per crate in
crates/, with an example made on first start. - Animations you can make: every animation is a file in
animations/. Copy one, change the slots, speed, items and sounds, and give it to a crate. Comes with:roulette, a row that slows down onto the prize;csgo, a fast spinner with flashing panes;vertical, a slot machine;wheel, a ring;reveal, covered slots turning over one by one;rise, where the prize rises out of the crate block in the world;instant, built in.
- Rewards:
- Weights and rarities.
- Up to 27 items per reward, plus any number of console commands.
- Exact copies of items added in game, or items from Nexo, ItemsAdder and Oraxen.
- Broadcasts.
- A permission needed to win it, or a permission that hides it (like a starter kit VIPs already have).
- Pick-your-reward crates: the player chooses 1 or more rewards from a menu instead of a random one.
- Keys:
- Physical keys are items with the crate's id hidden on them, so a renamed tripwire hook can't pass for a key.
- Virtual keys are a number saved per player, given online or offline, and shared across servers.
- A crate can use several keys per opening, and keys from other crates too ("a vote key and a rare key").
- Crate items:
/crate itemgives a crate as an item that opens when right-clicked, anywhere. - Crate blocks:
- Any block becomes a crate with
/crate set. Each crate is on one block at a time: setting it somewhere else moves it. - Floating text and particle effects (helix, ring, pulse, beacon, tornado, sparkle) sit around it.
- It can't be broken, blown up, burnt or moved.
- Any block becomes a crate with
- Opening:
- Right-click with a key.
- Shift-right-click for the "open how many?" menu, which opens 1, 5, 10, 25, 64 or all at once with a summary of everything won.
/crate openuses virtual keys from anywhere.
- Previews: left-click a crate (or
/crate preview) to see every reward with the player's real chance. - Reward limits: how many times one player, or anyone, can win a reward, ever or within so many hours ("once a day").
- Milestones: bonuses after a number of openings, once or every so many.
- Costs, cooldowns, permissions and pushback:
- An optional money cost per opening.
- A cooldown per crate.
- A permission needed to open it.
- Players without a key get knocked back.
- Rewards never lost: anything that doesn't fit waits for
/crate claiminstead of dropping on the floor. - Roll log: every reward given is written to
data/logs/rolls-<date>.log. - Extras: PlaceholderAPI placeholders and an API with events. Folia supported.
Requirements
- Paper (or a fork) 26.3, Java 25
- Optional: Vault with an economy plugin, or DriftEconomy, for open costs
- Optional: PlaceholderAPI
- Optional: Nexo, ItemsAdder or Oraxen, for their items as rewards and keys
Getting started
- Put
DriftCrates-<version>.jarinplugins/and start the server. It works without any changes:crates/example.ymland theanimations/folder are made for you inplugins/DriftCrates/, and its own data goes toplugins/DriftCrates/data/(see Folder layout). - Look at a block (a chest, an ender chest, anything) and run
/crate set example. /crate key give <you> example 3, then right-click the crate.- Make your own with
/crate editor→ New crate. Hold items and click Rewards → Add the item in your hand.
Commands
| Command | What it does | Permission |
|---|---|---|
/crate preview <crate> | See what a crate can give, and your chances | driftcrates.use |
/crate open <crate> | Open a crate with a virtual key | driftcrates.use |
/crate keys | Your virtual keys | driftcrates.use |
/crate claim | Rewards that didn't fit in your inventory | driftcrates.use |
/crate list | Every crate | driftcrates.use |
/crate editor | Make and change crates from menus | driftcrates.admin |
/crate key <give|take> <player|*> <crate> [amount] | Give or take keys (* is everyone online) | driftcrates.admin |
/crate item <player|*> <crate> [amount] | Give crates as items | driftcrates.admin |
/crate set <crate> | Make the block you're looking at a crate (moves it if it was placed somewhere else) | driftcrates.admin |
/crate remove | Turn the crate you're looking at back into a normal block | driftcrates.admin |
/crate create <name> | Make a new crate file | driftcrates.admin |
/crate addreward <crate> <name> [weight] | Add the item in your hand as a reward; use an existing name to add it to that reward | driftcrates.admin |
/crate help | The crate commands you can use (staff see the staff ones too) | driftcrates.use |
/driftcrates reload (/dcrates) | Reload every file and say how many problems were found | driftcrates.admin |
/driftcrates version | Show the version | driftcrates.admin |
/driftcrates help | The admin commands | driftcrates.admin |
/crate is also /crates. The help lines can be clicked to fill in the command.
Permissions
| Permission | Default | What it allows |
|---|---|---|
driftcrates.use | everyone | Open crates and use /crate preview, open, keys, claim and list. |
driftcrates.admin | op | /driftcrates, the editor, giving keys and crate items, placing crates and adding rewards. |
driftcrates.bypass.cooldown | op | Open crates without waiting for their cooldown. |
driftcrates.bypass.cost | op | Open crates without paying their open-cost. |
driftcrates.bypass.creative | nobody | Open crates in creative and spectator. |
A crate can need a permission to open (permission: in its file). A reward can need one to win it
(permission:) or be hidden from one (hidden-from:).
Animations
Every file in animations/ is an animation, named after the file. A crate picks one with
animation: <file name>. To make your own, copy a file, rename it, change it and run /driftcrates reload.
Every option is explained in roulette.yml.
There are three types:
spin: rewards travel along apathof slots and slow down until the prize stops onwin-slot.- A row makes a roulette, a column a slot machine, and a ring a wheel.
- You set the menu size, title,
spins, start and end speed, fixeditems(like pointers), the background (optionally flashing random colours) and the tick and win sounds.
reveal: coveredslotsturn over one at a time, in order or at random. The last one is the prize, and the rest can go dark once it's shown.block: the prize rises out of the crate block in the world, spinning and changing between rewards, then shows its name. You set the height, speed, size, particles and sounds.- It can't play when the crate is opened from a command, a crate item, or while another prize is rising from
the same block. Then its
fallbackanimation plays.
- It can't play when the crate is opened from a command, a crate item, or while another prize is rising from
the same block. Then its
instant is built in and gives the prize straight away. Opening several at once is always instant.
# animations/my-spinner.yml
type: spin
title: "<dark_gray>ᴏᴘᴇɴɪɴɢ <dark_gray>» <crate>"
rows: 3
path: ["9-17"] # rewards come in at the end and move towards the start; "17-9" reverses it
win-slot: 13
spins: 30
speed: {start-ticks: 1, end-ticks: 6, slow-down-steps: 14}
items:
pointer: {slots: [4, 22], material: LIME_STAINED_GLASS_PANE, name: "<bold>▼ ▲"}
background: {material: BLACK_STAINED_GLASS_PANE, random-colours: false}
sounds: {tick: "ui.button.click:0.4:1.8", win: "entity.player.levelup:0.6:1.2"}
Making a crate
/crate editor covers everything. Every setting is also explained in crates/example.yml. In short:
name: "<color:#2dd4bf><bold>Vote Crate"
key:
material: TRIPWIRE_HOOK # or "nexo:<id>", "itemsadder:<namespace:id>", "oraxen:<id>"
name: "<color:#2dd4bf><bold>Vote Key"
virtual: false # true: keys are a number per player instead of an item
amount: 1 # keys used per opening
also-needs: {} # other crates' keys also used, like {rare: 1}
crate-item: # what /crate item gives
material: CHEST
animation: roulette # a file in animations/, or instant
pick: 0 # how many rewards the player chooses themselves (0: random)
permission: "" # needed to open it
open-cost: 0 # money on top of the key
cooldown-seconds: 0
mass-open: 10 # the most opened at once
pushback: true
effect: {type: helix, particle: "END_ROD"}
hologram:
- "<color:#2dd4bf><bold>Vote Crate"
rewards:
diamonds:
weight: 10 # 10 is twice as likely as 5
rarity: rare # from rarities in config.yml
items: # up to 27
- material: DIAMOND
amount: 3
- "nexo:ruby"
commands: [] # console commands, {player} is the winner
broadcast: false
player-limit: -1 # times one player can win it
global-limit: -1 # times anyone can win it
limit-reset-hours: 0 # only count wins this many hours back (24: once a day)
permission: "" # needed to win it
hidden-from: "" # can't be won with this permission
milestones:
"25":
repeat: true
message: "<prefix> <color:#4ade80>25 openings! Here's a bonus."
commands:
- "eco give {player} 500"
Rewards added in game are saved as base64: lines: an exact copy of the item with every enchantment, name and
piece of data on it.
Turning features on and off
The features section at the top of config.yml. Changes need a restart.
| Switch | Default | What it covers |
|---|---|---|
preview | true | Left-click previews and /crate preview. |
limits | true | player-limit and global-limit on rewards. |
milestones | true | Milestone bonuses. |
animations | true | Opening animations. Off, every crate opens instantly. |
pushback | true | Knocking back players who click without a key. |
prices | false | open-cost on crates. |
holograms | true | Floating text above crate blocks. |
effects | true | Particles around crate blocks. |
crate-items | true | /crate item and opening crates from items. |
roll-log | true | Writing every reward given to data/logs/. |
placeholders | true | The %driftcrates_...% placeholders. |
Can't be cheated
- One key, one opening:
- A player can only open one crate at a time, so clicking fast can't use a key twice.
- The keys are taken before anything else. Virtual keys are taken in one database transaction that only goes through if the player has every key needed, so nothing can be spent twice, even from two servers at once.
- Key items and crate items are counted again after the database answers, in case they were moved meanwhile.
- If the opening can't go ahead, every key it used is given back. That covers payment failing, nothing left to win, or logging out at the wrong moment.
- The prize is decided first:
- The prize is picked on the server before any animation starts. Animations are only for show and can't be stopped on a better reward, whatever an animation file says.
- The prize is given exactly once: when the animation ends, or straight away if the menu is closed, the player logs out or the server stops.
- Pick crates:
- Each reward is given the moment it's clicked, and can't be picked twice.
- Limits are checked again on every click.
- Closing early picks the rest at random, so nothing paid for is lost.
- Locked menus: nothing can be taken out of any animation, preview, pick or editor menu.
- Leftover rewards: anything that doesn't fit waits in the database for
/crate claim, instead of being dropped where others could take it. Each item is removed from the database before it's given, so it can only be claimed once. - Keys can't be faked or wasted:
- Keys and crate items are recognised by hidden data, not their name or look, so renaming an item can't make one.
- They can't be placed or used in crafting.
- Crates can't be opened in creative or spectator, where items can be copied (
rules.block-creative).
- Crate blocks stay put: they can't be broken, blown up, burnt, pushed by pistons or changed by mobs.
- Limits hold: reward limits count each win straight away. Until a player's wins have loaded, rewards with a player limit can't be won.
- Editor: staff only, and every click checks the permission again. Text is typed in chat that nobody else sees.
PlaceholderAPI
| Placeholder | What it shows |
|---|---|
%driftcrates_keys_<crate>% | The player's virtual keys for a crate |
%driftcrates_opened_<crate>% | How many times they've opened it |
Developer API
DriftCratesAPI crates = DriftCratesAPI.get(); // null when DriftCrates isn't enabled
ItemStack key = crates.keyItem("vote", 1);
crates.giveVirtualKeys(uuid, "vote", 5); // works offline
String crate = crates.keyOf(item); // which crate an item is a key for
CrateOpenEvent fires before the key is taken and can be cancelled. CrateRewardEvent fires when a reward is given.
Configuration files
| File | What's in it |
|---|---|
config.yml | Feature switches, rarities, the open-cost currency, rules, holograms, effects, the roll log and storage |
crates/*.yml | One file per crate |
animations/*.yml | One file per opening animation |
commands.yml | Command names, aliases and permissions |
messages.yml | Every message, in MiniMessage |
menus.yml | The preview, "open how many?" and pick menus |
Every file starts with a boxed header saying how to apply changes, is split into sections, and has a note above
every option saying what it does, its unit and the values it takes. The prefix is DRIFTCRATES in bold solid
teal (#2dd4bf), followed by a dark grey ». For a network, set storage.type: MYSQL on every server so virtual
keys, limits and milestones are shared.
When you update, new options are added with their notes and everything you changed is kept. When the notes
themselves change, config.yml, commands.yml, messages.yml and menus.yml are rebuilt once with the new notes and
your values written back in; the old file is kept in data/backups/. Messages you never changed get the new
default wording. Your crate and animation files are never rewritten.
Mistakes in the files
A value DriftCrates can't use never stops the plugin. The console says which file and option, what was wrong and what is used instead, for example:
[DriftCrates] crates/vote.yml: animation "spinny" isn't a file in the animations folder or instant, using "instant"
/driftcrates reload tells you how many problems it found, so you know to look.
Folder layout
plugins/DriftCrates/
config.yml settings, starting with the features: switches
messages.yml every message
menus.yml every menu
commands.yml command names, aliases and permissions
crates/ one file per crate (yours to edit, or use /crate editor)
animations/ one file per opening animation (yours to edit)
data/ the plugin's own files, no need to open them
database.mv.db virtual keys, open counts, limits and waiting rewards (H2 storage)
blocks.yml which blocks are crates (saved by /crate set)
logs/ rolls-<date>.log, every reward given
backups/ old copies of files DriftCrates replaced
*.version which version of each file you have
Older versions kept data.mv.db, blocks.yml, logs/ and the .version markers next to config.yml (and
.bundled in animations/). They are moved into data/ the first time the new version starts (one console line
per file), and nothing is overwritten or deleted.