-
Notifications
You must be signed in to change notification settings - Fork 15
Developer API
Ricardo Borutta edited this page Sep 10, 2023
·
1 revision
You have to add this plugin as a dependency or soft dependency. Then you can get the death chest service.
public class TestPlugin extends JavaPlugin {
@Override
public void onEnable() {
DeathChestService load = getServer().getServicesManager().load(DeathChestService.class);
if (load != null) {
// Code
}
}
}With the service you can create new death chests.
public class TestPlugin extends JavaPlugin {
@Override
public void onEnable() {
DeathChestService load = getServer().getServicesManager().load(DeathChestService.class);
if (load != null) {
DeathChest chest = load.createDeathChest(location, items); // This creates a new chest with the items in the world
}
}
}Or you can use the service in other events.
public class TestPlugin extends JavaPlugin implements Listener {
private DeathChestService deathChestService;
@Override
public void onEnable() {
this.deathChestService = getServer().getServicesManager().load(DeathChestService.class);
if (this.deathChestService != null) {
getServer().getPluginManager().registerEvents(this, this); // Registers only if the service is available
}
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
ItemStack[] items = null; // Items code here
this.deathChestService.createDeathChest(player.getLocation(), items); // This creates a new chest with the items in the world
}
}