Skip to content

Developer API

Dieter Nuytemans edited this page May 2, 2021 · 3 revisions

BetterSleeping v3 comes equipped with a developer API. This API is used internally to give players their (non) sleeping (de)buffs. Currently only a single event is available but more may be added later.

Add BetterSleeping as a dependency

This is easiest when working on a Maven project. Simply add the following dependency to your pom.xml. It is advised to always use the latest version, check the available versions here.

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

	<dependency>
	    <groupId>com.github.Nuytemans-Dieter</groupId>
	    <artifactId>BetterSleeping</artifactId>
	    <version>v3.0.6</version>
	</dependency>

For non-Maven projects, please refer to your IDE's documentation on how to include a jar file.

Event API

BetterSleeping will fire TimeSetToDayEvent whenever the time changes to day for any reason. This event has several methods:

getCause()

This returns the Cause of time being set to day. Possible causes are:

  • NATURAL: When it becomes morning in a world without interference of other plugins.
  • SLEEPING: When the time is set to day by BetterSleeping due to sleeping players.
  • OTHER: Any other cause, probably other plugins setting the time to day or using the /time set command.

getWorld()

Simply returns the World in which the time was set to day.

getPlayersWhoSlept()

Returns a List that contains all players that slept.

getPlayersWhoDidNotSleep()

Returns a List that contains all players in this world that did not sleep.

Wiki navigation

BetterSleeping v4

Commands and permissions

Commands & permissions

Bypass permissions

Config files

Sleeping settings

Buffs

Developer API

Dev API (see Spigot)


BetterSleeping v3

Commands and permissions

Commands

Config files

Config

Sleeping settings

Bypass permissions

Buffs

Developer API

Dev API


BetterSleeping v2

Commands and permissions

Configuration

PlaceholderAPI

Clone this wiki locally