Skip to main content

Plugin API

Your own plugin can ask BloodNight what is going on, and react when something happens.

Add the API​

The API is published with every release:

repositories {
maven("https://eldonexus.de/repository/maven-public/")
}

dependencies {
compileOnly("de.eldoria.bloodnight:api:<version>")
}

Add BloodNight as a dependency in your paper-plugin.yml, so your plugin loads after it.

Ask BloodNight​

BloodNightService bloodNight = BloodNightProvider.get();

if (bloodNight.isRunning(world)) {
// a blood night runs in this world
}
bloodNight.next(world, 30).ifPresent(next -> {
// next.ticksUntil() game ticks until the next blood night
});
bloodNight.customMobId(entity).ifPresent(id -> {
// the entity is the special mob with this id
});
MethodWhat it gives you
isRunning(world)Whether a blood night runs
running(world)The running night: its number, ticks left, how much is left, whether a dragon fight holds it
next(world, horizon)The next blood night within horizon nights
probability(world, nightsAhead)The chance of a coming night, 0 to 100
force(world), cancel(world)Make the coming night a blood night, or keep it normal
runningWorlds()Every world with a blood night
isCustomMob(entity), customMobId(entity)Whether an entity is a special mob, or rides or carries one
customMobIds()Every special mob on the server
spawn(mobId, location)Spawn a special mob

You can also get the service from Paper's services manager.

On Folia, call force and cancel on the global region and spawn on the region of the location.

Events​

EventWhenCan be cancelled
BloodNightBeginEventA blood night is about to beginYes. The night stays normal.
BloodNightEndEventA blood night ended. reason() says why.No
CustomMobSpawnEventA spawning mob is about to become a special mobYes. The mob stays normal.
CustomMobDeathEventA special mob died. You can still change its drops.No

The night events are world events, so getWorld() tells you the world. night() gives the night's number.

@EventHandler
public void onBegin(BloodNightBeginEvent event) {
if (event.getWorld().getName().equals("lobby")) {
event.setCancelled(true);
}
}

@EventHandler
public void onSpecialMob(CustomMobSpawnEvent event) {
if (event.getEntity().getLocation().getY() > 200) {
event.setCancelled(true);
}
}

BloodNightEndEvent.reason() is one of:

ReasonMeaning
TIMEThe night is over
CANCELLEDSomeone cancelled it
DISABLEDThe world no longer has blood nights
RELEASEDThe dragon fight that held it is over
SHUTDOWNThe server or plugin stopped