API
Before utilizing the API, make sure that the AdvancedVanish
plugin is enabled by addingdepend: [AdvancedVanish]
or softdepend: [AdvancedVanish]
to your plugin's plugin.yml
.
Even though AdvancedVanish was made in Kotlin, the API can still be accessed from Java.
Adding the Dependency
Add this repository to your pom.xml
:
<repository>
<id>repsy</id>
<name>quantiom</name>
<url>https://repo.repsy.io/mvn/quantiom/minecraft</url>
</repository>
Add the dependency and replace <version>...</version>
with the current version:
<dependency>
<groupId>me.quantiom</groupId>
<artifactId>advancedvanish</artifactId>
<version>1.2.2</version>
</dependency>
Methods
AdvancedVanishAPI.vanishPlayer(player: Player): Unit
AdvancedVanishAPI.unVanishPlayer(player: Player): Unit
AdvancedVanishAPI.isPlayerVanished(player: Player): Boolean
AdvancedVanishAPI.canSee(player: Player, target: Player): Boolean
Extensions (Kotlin Only)
Player.isVanished(): Boolean
Events
PrePlayerVanishEvent
- Gets called before vanishing a player, implementsCancellable
PlayerVanishEvent
- Gets called after a player vanishes.PrePlayerUnVanishEvent
- Gets called before a player unvanishes, implementsCancellable
.PlayerUnVanishEvent
- Gets called after a player unvanishes.
Example Usage
class ExamplePlugin : JavaPlugin(), Listener {
override fun onEnable() {
this.server.pluginManager.registerEvents(this, this)
}
@EventHandler
private fun onVanish(event: PlayerVanishEvent) {
val vanishedPlayers = AdvancedVanishAPI.vanishedPlayers
.map(Bukkit::getPlayer)
.joinToString(", ", transform = Player::getName)
this.logger.log(Level.INFO, "${event.player.name} has entered vanish.")
this.logger.log(Level.INFO, "Current vanished players: ${vanishedPlayers}.")
}
@EventHandler
private fun onUnVanish(event: PrePlayerUnVanishEvent) {
event.isCancelled = true // Don't let players unvanish
}
}
Last updated