Spigot

Utility object providing Spigot-specific implementations of the VitalUtils abstraction.

This object offers a collection of methods tailored for the Spigot server API, enabling formatted messaging, broadcasting actions, handling titles and action bars, and applying or clearing effects on players. It defines actions for efficiently working with Spigot's CommandSender and Player entities.

Functions

Link copied to clipboard
open override fun broadcastAction(predicate: Predicate<SpigotPlayer> = Predicate { true }, action: Consumer<SpigotPlayer>)

Broadcasts an action to a collection of players based on a specified condition.

Link copied to clipboard
fun broadcastClearPotionEffect(potionEffectType: PotionEffectType, playerPredicate: Predicate<SpigotPlayer> = Predicate { true })

Broadcasts the removal of a specific potion effect to all players satisfying the given predicate.

Link copied to clipboard
fun broadcastClearPotionEffects(playerPredicate: Predicate<SpigotPlayer> = Predicate { true })

Removes all active potion effects from players that satisfy the specified predicate.

Link copied to clipboard
open override fun broadcastFormattedActionBar(message: String, predicate: Predicate<SpigotPlayer> = Predicate { true })

Broadcasts a formatted action bar message to all players satisfying the given predicate.

Link copied to clipboard
open override fun broadcastFormattedMessage(message: String, predicate: Predicate<SpigotPlayer> = Predicate { true })

Broadcasts a formatted message to all players satisfying the given predicate.

Link copied to clipboard
open override fun broadcastFormattedPersistentTitle(title: String = "", subtitle: String = "", fadeIn: @Range(from = 0, to = 72000) Int, predicate: Predicate<SpigotPlayer> = Predicate { true })

Sends a persistent formatted title and subtitle to all players that satisfy the specified predicate. The title remains displayed with the specified fade-in duration.

Link copied to clipboard
open fun broadcastFormattedTitle(title: String = "", subtitle: String = "", fadeIn: @Range(from = 0, to = 72000) Int, stay: @Range(from = 0, to = 72000) Int, fadeOut: @Range(from = 0, to = 72000) Int, predicate: Predicate<SpigotPlayer> = Predicate { true })

Broadcasts a formatted title to all eligible recipients.

open override fun broadcastFormattedTitle(title: String = "", subtitle: String = "", predicate: Predicate<SpigotPlayer>)

Broadcasts a formatted title and subtitle to all players satisfying the given predicate.

Link copied to clipboard
fun broadcastPotionEffect(potionEffectType: PotionEffectType, duration: Int, amplifier: Int, playerPredicate: Predicate<SpigotPlayer> = Predicate { true })

Broadcasts a potion effect to all players who meet the specified condition.

Link copied to clipboard
fun broadcastSound(sound: Sound, predicate: Predicate<SpigotPlayer> = Predicate { true })
fun broadcastSound(sound: Sound, volume: Float, pitch: Float, predicate: Predicate<SpigotPlayer> = Predicate { true })

Broadcasts a sound to all players satisfying the given predicate.

Link copied to clipboard
fun calculateEdges(pos1: Location, pos2: Location): Int

Calculates the total number of edges for a cuboid defined by two 3D locations.

Link copied to clipboard
fun calculateSurfaceArea(pos1: Location, pos2: Location): Int

Calculates the surface area of a cuboid region defined by two locations.

Link copied to clipboard
fun calculateVolume(pos1: Location, pos2: Location): Int

Calculates the volume of a rectangular cuboid defined by two locations.

Link copied to clipboard

Determines if the current material can be placed in mid-air without support.

Link copied to clipboard
fun World.cleanGameRules()

Configures the game rules and environment settings for a World to align with a controlled or static gameplay setup.

fun cleanGameRules(worldName: String)

Cleans and configures game rules for a specified world to ensure a controlled gameplay setup.

Link copied to clipboard
fun Location.getCenterBlockLocation(): Location

Returns a Location object that represents the center of the block of the current location. The method adjusts the current location's coordinates to align it to the exact center of the block it belongs to.

fun Location.getCenterBlockLocation(xOffset: Double, yOffset: Double, zOffset: Double): Location

Calculates the center of the block for the given location, with optional offsets.

Link copied to clipboard
fun Location.getCenterBlockSideLocation(): Location

Retrieves the center block side location of a Location with specific offsets.

Link copied to clipboard
fun Location.getCenterBlockTopLocation(): Location

Calculates the top center location of the block the current location belongs to.

Link copied to clipboard
fun Entity.getCustomNametagTeam(scoreboard: Scoreboard, sort: String, prefix: String? = null, suffix: String? = null): Team
fun Entity.getCustomNametagTeam(scoreboard: Scoreboard, sort: String, prefix: Component? = null, suffix: Component? = null): Team

Retrieves or creates a custom nametag team for the player in the specified scoreboard.

Link copied to clipboard
fun getEdgeLocations(pos1: Location, pos2: Location): Sequence<Location>

Calculates and returns the edge locations of a cuboid defined by two diagonal corners.

Link copied to clipboard
fun Location.getHighestSafeLocationFromBottom(startFrom: Int = 50): Location

Finds the highest safe location starting from a specified point and moving upward. A location is considered safe if the block at the level and the block above it are both air.

Link copied to clipboard
fun Location.getHighestSafeLocationFromTop(startFrom: Int = 256): Location

Determines the highest non-air block location from the specified start height and returns a safe location above it.

Link copied to clipboard
fun World.getRandomLocation(): @NotNull Location

Generates a random location within the valid world boundary and returns it.

Link copied to clipboard
fun getRandomLocationInLocationArea(location1: Location, location2: Location): Location

Generates a random location within a rectangular area defined by two corner locations.

Link copied to clipboard
fun getSurfaceAreaLocations(pos1: Location, pos2: Location): Sequence<Location>

Calculates the locations on the surface of the cuboid defined by two positions.

Link copied to clipboard
fun getVolumeLocations(pos1: Location, pos2: Location): Sequence<Location>

Generates a sequence of all block locations within the cuboid defined by two corner locations. The locations must belong to the same world, and the sequence is generated from the minimum coordinates to the maximum coordinates of the defined cuboid.

Link copied to clipboard
fun Location.isInsideLocationArea(location1: Location, location2: Location): Boolean

Determines if the current location is inside a defined 3D rectangular area.

Link copied to clipboard
fun Material.isRedstoneMachine(): Boolean

Determines if the current Material instance represents a redstone-related machine or component.

Link copied to clipboard
fun Material.isVegetation(): Boolean

Checks if the material is related to vegetation.

Link copied to clipboard
fun SpigotPlayer.openInventory(menuType: MenuType.Typed<*, *>)

Opens a custom inventory menu for the player based on the provided menu type.

Link copied to clipboard
fun SpigotPlayer.playLoopedSound(sound: String, length: Long, volume: Float, pitch: Float)

Plays and the given sound on this player and loops after the specified lengthms has expired.

Link copied to clipboard
open override fun SpigotPlayer.sendFormattedActionBar(message: String)

Sends a formatted action bar message to the current player.

Link copied to clipboard
open override fun SpigotCommandSender.sendFormattedMessage(message: String)

Sends a formatted message to the current player or client system (CS).

Link copied to clipboard
open override fun SpigotPlayer.sendFormattedPersistentTitle(title: String = "", subtitle: String = "", fadeIn: @Range(from = 0, to = 72000) Int)

Sends a formatted, persistent title and subtitle to the current player or client system (P).

Link copied to clipboard
open override fun SpigotPlayer.sendFormattedTitle(title: String = "", subtitle: String = "")

Sends a formatted title and subtitle to the current player. The title and subtitle are displayed in the player's title bar.

open override fun SpigotPlayer.sendFormattedTitle(title: String = "", subtitle: String = "", fadeIn: @Range(from = 0, to = 72000) Int, stay: @Range(from = 0, to = 72000) Int, fadeOut: @Range(from = 0, to = 72000) Int)

Sends a formatted title and subtitle to the current player or client system (P).

Link copied to clipboard
fun SpigotPlayer.setCustomNametag(sort: String, prefix: String? = null, suffix: String? = null)

Sets a custom nametag for a SpigotPlayer instance, along with managing the scoreboard teams required to properly display the nametag information.

fun Entity.setCustomNametag(scoreboard: Scoreboard, sort: String, prefix: String? = null, suffix: String? = null)

Sets a custom nametag for an Entity instance, along with managing the scoreboard teams required to properly display the nametag information.

Link copied to clipboard

Stops all possibly active looped sounds for the current player.

Link copied to clipboard

Stops a possibly active sound loop for the current player and the given sound. If the current player does not have the sound active, this function does nothing.

Link copied to clipboard

Teleports the player to the specified entity's location while applying a visual effect.

fun SpigotPlayer.teleportWithEffect(location: Location, potionEffectType: PotionEffectType = PotionEffectType.SLOWNESS)

Teleports a player to a specified location with a temporary visual potion effect.