Custom Openers

Connor Linfoot edited this page Jun 28, 2016 · 8 revisions

This page will give basic information on what and how to register a custom "Opener" for CratesPlus.

What is an Opener

An "Opener" is what CratesPlus will call when someone opens a crate. Currently, CratesPlus features two openers, one for the Basic GUI and one without anything special and just returns the winning. Any plugin can create and add an opener to CratesPlus allowing endless possibilities for opening Crates.

Requirements for an Opener

Openers were added from CratesPlus v4.1, all documentation on this page is valid as of version 4.1. Currently, if your opener is added to a plugin with an older version of CratesPlus it will result in exceptions. I'll soon add some demo code for checking the CratesPlus version before attempting to register an Opener.

How to create an Opener

To get started you'll need to import CratesPlus into your plugin, you should be able to achieve this using something such as Maven or your IDE. Once you've imported the plugin you'll need to create a new class and extend the "Opener" class from CratesPlus and override the doOpen, doSetup and doReopen methods.

public class CustomOpener extends Opener {

	public CustomOpener(Plugin plugin, String name) {
		super(plugin, name);

	public void doSetup() {
		// Handle any custom configuration loading etc 

	public void doReopen(Player player, Crate crate, Location blockLocation) {
		// What to do if they interact with the crate again after it's already opened and not finished

	public void doOpen(Player player, Crate crate, Location blockLocation) {
		// Handle your code here


Using the doOpen method you can now handle the crate opening in any way you'd like. When a player opens a crate the key removing/handling is done for you and the enabled opener will be called running the doOpen method. To award a win to a player you can use getWinning which will return a random win and then execute the runWin(Player player) method for that. You'll need to make sure to call the finish method once you're done. Otherwise, CratesPlus won't know you've finished.

How to register an Opener

Once you've created your Opener class you now need to register it for CratesPlus to be aware it exists. You can do this using the "OpenHandler" in CratesPlus. See the example code below.

CratesPlus.getOpenHandler().registerOpener(new CustomOpener(this, "Custom"));

The second argument of an Opener is the name and must be unique. This may change in the future.

Full plugin example

For a complete example of creating a custom Opener check out the CSGO Opener created for CratesPlus.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.