API
For other plugins. Add BerryHomes to softdepend (or depend) in your plugin.yml, and compile against the BerryHomes jar (compileOnly).
BerryHomesAPI api = BerryHomesAPI.get();
// Online players' homes, from memory. Safe on any thread.
List<Home> homes = api.cachedHomes(player.getUniqueId());
// Anyone's homes, online or not. Completes off the main thread: never wait on it from a tick thread.
api.homes(uuid).thenAccept(list -> ...);
int limit = api.limit(player);
// The usual checks, warmup and cost (call on the player's own thread)
api.teleport(player, homes.get(0));
Home is a record: owner(), name(), display(), server(), world(), x(), y(), z(), yaw(), pitch(), icon(), description(), pinned(), slot(), created(), lastUsed().
Events
| Event | When | Cancel to |
|---|---|---|
HomeTeleportEvent | After the warmup, right before teleporting. For a home on another server, on the server they're leaving (isCrossServer()). | Stop the teleport (nothing is charged) |
HomeSetEvent | A home is set or moved. getPrevious() is the old home when it moved, otherwise null. | Stop it being saved |
HomeDeleteEvent | A home is deleted, by its owner or an admin (getDeletedBy()). | Keep it |
All are in games.berries.homes.api.event. The teleport and set events fire on the player's own thread (on Folia, their region's thread); the delete event fires on the thread of whoever deleted the home (the console's, for a console command).
@EventHandler
public void onHome(HomeTeleportEvent e) {
if (inCombat(e.getPlayer())) e.setCancelled(true);
}