-
-
Notifications
You must be signed in to change notification settings - Fork 8
Hook into Blood Night
Blood Night uses maven as dependency management.
Gradle
repositories {
maven("https://eldonexus.de/repository/maven-public")
}
dependencies {
implementation("de.eldoria", "bloodnight-api", "version")
}
Maven
<repository>
<id>EldoNexus</id>
<url>https://eldonexus.de/repository/maven-public/</url>
</repository>
<dependency>
<groupId>de.eldoria</groupId>
<artifactId>bloodnight-api</artifactId>
<version>version</version>
</dependency>
To hook into Blood Night you can get yourself a BloodNightAPI instance.
IBloodNightAPI bloodNightAPI = BloodNight.getBloodNightAPI();
This API is a interface which provides basic access to the internal Blood Night Manager instances.
This API instance will withstand a full reload of the plugin or server and will still be usable.
public interface IBloodNightAPI {
/**
* Checks if a blood night is active.
*
* @param world world
* @return true if a blood night is active.
*/
boolean isBloodNightActive(World world);
/**
* Force the next night to be a blood night in a world.
* <p>
* This will not set the time in the world.
*
* @param world world
*/
void forceNight(World world);
/**
* Cancels a blood night a world if one is active.
*
* @param world world
*/
void cancelNight(World world);
/**
* Get all worlds where a blood night is currently active.
*
* @return set of worlds.
*/
Set<World> getBloodWorlds();
/**
* Returns how many seconds of the blood night are left.
*
* @return the amount of seconds or 0 if not blood night is active.
*/
int getSecondsLeft(World world);
/**
* Get the percent of blood night duration left.
* <p>
* The start is 100 and the end is 0.
* <p>
* If no blood night is active this method will always return 0.
*
* @return the percent between 100 and 0.
*/
double getPercentleft(World world);
/**
* Get the probability of the next night to become a blood night.
*
* Calling this function is equal to {@link #nextProbability(World, int)} with offset 1;
*
* @param world world to check
* @return probability between 0 and 100. Where 100 is a guaranteed blood night.
*/
default int nextProbability(World world) {
return nextProbability(world, 1);
}
/**
* Get the probability of the next night to become a blood night.
*
* @param world world to check
* @param offset offset of nights. The next night has a offset of 1. The last night has a offset of 0.
* @return probability between 0 and 100. Where 100 is a guaranteed blood night.
*/
int nextProbability(World world, int offset);
}
Blood night provides some events.
This event is called when a blood night has been started.
This event is cancelable. A blood night will not be started if the event has been canceled.
/**
* Event which is fired when a blood nights begins.
* <p>
* This event is {@link Cancellable}. If the event is canceled, no Blood Night will be initialized.
*/
public class BloodNightBeginEvent extends WorldEvent implements Cancellable {
private static final HandlerList HANDLERS = new HandlerList();
private boolean cancelled;
/**
* Create a new Blood Night Begin Event.
*
* @param world world where the blood night has begun.
*/
public BloodNightBeginEvent(World world) {
super(world);
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
This event is called when a blood night has ended.
/**
* Event which is fired when a blood nights ends.
*/
public class BloodNightEndEvent extends WorldEvent {
private static final HandlerList HANDLERS = new HandlerList();
/**
* Create a new Blood Night End Event.
*
* @param world world where the blood night has ended.
*/
public BloodNightEndEvent(World world) {
super(world);
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
}
Blood Night
Features:
Features
Special Mobs
Configuration:
Getting Started
Configuration
Preconfigured Mobs
Commands & Permissions
Placeholders
Contributing:
Add a Special Mob
Hook into Blood Night