diff --git a/README.md b/README.md index f2378fe..de6de26 100644 --- a/README.md +++ b/README.md @@ -1,110 +1,67 @@ # AdvancedVanish -![license](https://img.shields.io/github/license/quantiom/EventHandler?color=%23b59e28&style=for-the-badge) ![made-with-kotlin](https://img.shields.io/badge/MADE%20WITH-KOTLIN-%23b59e28?style=for-the-badge&logo=java) ![last-commit](https://img.shields.io/github/last-commit/quantiom/AdvancedVanish?color=%23b59e28&style=for-the-badge) -AdvancedVanish is a fully customizable and advanced vanish plugin made with Kotlin. +A fully customizable and advanced vanish plugin for Spigot-based Minecraft servers. -Spigot Resource: https://www.spigotmc.org/resources/advancedvanish.86036/ +## Features -GitBook: https://quantioms.gitbook.io/advancedvanish/ +- Toggle vanish for yourself and other players. +- Control whether you can interact with blocks while vanished. +- View a list of vanished players. +- Check the vanish status of any player. +- Vanish priority system. +- Support for various popular plugins like LuckPerms, PlaceholderAPI, and Essentials. -## Features -- Fully customizable through the [config](src/main/resources/config.yml). (70+ options) - - Messages - - Permissions - - Actions - - Hooks - - Placeholders - - Much more... -- Vanished players are **completely** invisible, as if they are not even online. -- Vanish priorities/levels ([more info](https://quantioms.gitbook.io/advancedvanish/features#vanish-priorities)) - - Supports many different permissions plugins. (LuckPerms, PermissionsEx, bPermissions, GroupManager) -- Many configurable hooks which provide support to other plugins. - - Essentials - - PlaceholderAPI - - DiscordSRV - - Dynmap - - Much more... -- Togglable Actions when vanished (15+) -- Commands: - - `/vanish` *- Toggle vanish.* - - `/vanish reload` *- Reloads the config and hooks* - - `/vanish priority` *- Displays your vanish priority.* - - `/vanish list` *- Dispalys a list of vanished players.* - - `/vanish status ` *- Check if a player is in vanish.* - - `/vanish set ` *- Set another player's vanish.* - - `/vanish toggle ` *- Toggle another player's vanish.* - - `/vanish interact` *- Toggles interacting while in vanish* -- Cross Server Vanish Synchronization -- For the rest of the features, check out the [GitBook page](https://quantioms.gitbook.io/advancedvanish/). +## Commands + +| Command | Description | Aliases | +|---------------------------------|----------------------------------------------|-------------------------| +| `/vanish` | Toggle your vanish status. | `/v`, `/advancedvanish` | +| `/vanish version` | Shows the plugin version. | | +| `/vanish reload` | Reloads the configuration and hooks. | | +| `/vanish interact` | Toggle block interaction while vanished. | | +| `/vanish priority` | Displays your vanish priority. | | +| `/vanish list` | Lists all vanished players. | | +| `/vanish status ` | Check if a player is vanished. | | +| `/vanish set ` | Set another player's vanish status. | | +| `/vanish toggle ` | Toggle another player's vanish status. | | +| `/vanish help` | Displays the help message. | | -## Hooks -In AdvancedVanish, there are many hooks which provide support to other plugins. -A full list of hooks with their descriptions can be found on the [GitBook page](https://quantioms.gitbook.io/advancedvanish/features#hooks). +## Permissions -## Vanish Priority -An explanation and guide of how to use vanish priorities can be found on the [GitBook page](https://quantioms.gitbook.io/advancedvanish/features#vanish-priorities). -*Note: Requires a supported permissions plugin to function* +| Permission | Description | Default | +|----------------------------------------|----------------------------------------------------| ---------- | +| `advancedvanish.vanish` | Allows toggling your own vanish status. | `true` | +| `advancedvanish.version-command` | Allows using the `/vanish version` command. | `true` | +| `advancedvanish.reload-config-command` | Allows using the `/vanish reload` command. | `op` | +| `advancedvanish.interact-command` | Allows using the `/vanish interact` command. | `op` | +| `advancedvanish.priority-command` | Allows using the `/vanish priority` command. | `true` | +| `advancedvanish.list-command` | Allows using the `/vanish list` command. | `op` | +| `advancedvanish.status-command` | Allows using the `/vanish status` command. | `op` | +| `advancedvanish.set-other-command` | Allows using the `/vanish set` command. | `op` | +| `advancedvanish.toggle-other-command` | Allows using the `/vanish toggle` command. | `op` | +| `advancedvanish.help-command` | Allows using the `/vanish help` command. | `true` | +| `advancedvanish.see-vanished` | Allows seeing vanished players. | `op` | -## API -Before utilizing the API, make sure that the `AdvancedVanish` plugin is -enabled, or add `depend: [AdvancedVanish]` or `softdepend: [AdvancedVanish]` to -your plugin's `plugin.yml`. +*Note: The actual permission nodes are configurable in `config.yml`.* -### Maven -Add this repository to your `pom.xml`: -```xml - - repsy - quantiom - https://repo.repsy.io/mvn/quantiom/minecraft - -``` +## Dependencies -Add the dependency and replace `...` with the current version: -```xml - - me.quantiom - advancedvanish - 1.2.7 - -``` +AdvancedVanish has soft dependencies on the following plugins, which means it can integrate with them if they are installed, but they are not required for the plugin to run: -### Methods -```kotlin -AdvancedVanishAPI.vanishPlayer(player: Player): Unit -AdvancedVanishAPI.unVanishPlayer(player: Player): Unit -AdvancedVanishAPI.isPlayerVanished(player: Player): Boolean -AdvancedVanishAPI.canSee(player: Player, target: Player): Boolean -``` -### Extensions -```kotlin -Player.isVanished(): Boolean -``` -### Events -- `PrePlayerVanishEvent` - Gets called before vanishing a player, implements `Cancellable`. -- `PlayerVanishEvent` - Gets called after a player vanishes. -- `PrePlayerUnVanishEvent` - Gets called before a player unvanishes, implements `Cancellable`. -- `PlayerUnVanishEvent` - Gets called after a player unvanishes. -### Example Usage -```kotlin -class ExamplePlugin : JavaPlugin(), Listener { - override fun onEnable() { - this.server.pluginManager.registerEvents(this, this) - } +- LuckPerms +- PlaceholderAPI +- GroupManager +- PermissionsEx +- bPermissions +- DiscordSRV +- Dynmap +- squaremap +- LibsDisguises +- PlayerParticles +- Essentials +- ProtocolLib - @EventHandler - private fun onVanish(event: PlayerVanishEvent) { - val vanishedPlayers = AdvancedVanishAPI.vanishedPlayers - .map(Bukkit::getPlayer) - .joinToString(", ", transform = Player::getName) +## Configuration - this.logger.log(Level.INFO, "${event.player.name} has entered vanish.") - this.logger.log(Level.INFO, "Current vanished players: ${vanishedPlayers}.") - } +The plugin is highly configurable. You can customize messages, permission nodes, and various other settings in the `config.yml` file. - @EventHandler - private fun onUnVanish(event: PrePlayerUnVanishEvent) { - event.isCancelled = true // Don't let players unvanish - } -} -``` diff --git a/pom.xml b/pom.xml index fa824f0..8e244d9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ me.quantiom advancedvanish - 1.2.7 + 2026.5.0 jar AdvancedVanish @@ -22,13 +22,13 @@ UTF-8 - 2.1.0 + 2.2.0 official 4.13.2 10 - 17 - 17 + 21 + 21 true @@ -41,17 +41,13 @@ aikar https://repo.aikar.co/content/groups/aikar/ - - dmulloy2-repo - https://repo.dmulloy2.net/nexus/repository/public/ - ess-repo https://repo.essentialsx.net/releases/ paper-repo - https://papermc.io/repo/repository/maven-public/ + https://repo.papermc.io/repository/maven-public/ jitpack.io @@ -85,15 +81,13 @@ md_5-public https://repo.md-5.net/content/groups/public/ + + purpur-repo + https://repo.purpurmc.org/snapshots + - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - provided - io.papermc.paper paper-api @@ -106,7 +100,6 @@ 0.5.1-SNAPSHOT compile - net.luckperms api @@ -114,15 +107,15 @@ provided - com.comphenix.protocol + net.dmulloy2 ProtocolLib - 5.3.0 + 5.4.0 provided net.essentialsx EssentialsX - 2.20.1 + 2.21.2 provided @@ -134,7 +127,7 @@ com.discordsrv discordsrv - 1.28.0 + 1.30.5 provided @@ -156,7 +149,7 @@ provided - LibsDisguises + LibsDisguises LibsDisguises 10.0.44 provided @@ -171,31 +164,31 @@ redis.clients jedis - 5.1.1 + 7.5.0 provided org.jetbrains.exposed exposed-core - 0.47.0 + 0.50.0 provided org.jetbrains.exposed exposed-dao - 0.47.0 + 0.50.0 provided org.jetbrains.exposed exposed-jdbc - 0.47.0 + 0.50.0 provided net.byteflux libby-bukkit - 1.3.0 + 1.3.1 org.jetbrains.kotlin @@ -208,11 +201,6 @@ kotlin-stdlib-jdk8 ${kotlin.version} - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - @@ -320,6 +308,46 @@ + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + + package + + shade + + + false + + + co.aikar.commands + me.quantiom.advancedvanish.shaded.acf.commands + + + co.aikar.locales + me.quantiom.advancedvanish.shaded.acf.locales + + + kotlin + me.quantiom.advancedvanish.shaded.kotlin + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + - + \ No newline at end of file diff --git a/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanish.kt b/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanish.kt index 8a7078b..4a03588 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanish.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanish.kt @@ -51,8 +51,8 @@ object AdvancedVanish { fun onDisable() { ServerSyncManager.close() VanishStateManager.onDisable() - AdvancedVanishAPI.vanishedPlayers.map(Bukkit::getPlayer).forEach { AdvancedVanishAPI.unVanishPlayer(it!!) } + AdvancedVanishAPI.vanishedPlayers.mapNotNull(Bukkit::getPlayer).forEach { AdvancedVanishAPI.unVanishPlayer(it) } HooksManager.disableHooks() commandManager?.unregisterCommand(VanishCommand) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanishPlugin.java b/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanishPlugin.java index d7c132c..00a1f55 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanishPlugin.java +++ b/src/main/kotlin/me/quantiom/advancedvanish/AdvancedVanishPlugin.java @@ -2,14 +2,6 @@ import org.bukkit.plugin.java.JavaPlugin; -/** - * This class is written in Java only because of the - * dependency management system. After Kotlin is loaded, the - * AdvancedVanish Kotlin class will take over. - * - * Basically, this class just acts as a "loader". - */ - public class AdvancedVanishPlugin extends JavaPlugin { @Override public void onEnable() { diff --git a/src/main/kotlin/me/quantiom/advancedvanish/command/VanishCommand.kt b/src/main/kotlin/me/quantiom/advancedvanish/command/VanishCommand.kt index 470a217..b427543 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/command/VanishCommand.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/command/VanishCommand.kt @@ -97,7 +97,7 @@ object VanishCommand : BaseCommand() { private fun onListCommand(player: Player) { if (!permissionCheck(player, "permissions.list-command", "advancedvanish.list-command")) return - val players = AdvancedVanishAPI.vanishedPlayers.map(Bukkit::getPlayer).map { it!! }.joinToString(", ", transform = Player::getName) + val players = AdvancedVanishAPI.vanishedPlayers.mapNotNull(Bukkit::getPlayer).joinToString(", ", transform = Player::getName) player.sendConfigMessage("vanished-list", "%vanished-players%" to players.ifEmpty { "None" }) } @@ -187,4 +187,4 @@ object VanishCommand : BaseCommand() { return true } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/config/Config.kt b/src/main/kotlin/me/quantiom/advancedvanish/config/Config.kt index 1430597..a0b0d62 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/config/Config.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/config/Config.kt @@ -3,8 +3,7 @@ package me.quantiom.advancedvanish.config import co.aikar.commands.Locales import co.aikar.commands.MessageKeys import co.aikar.locales.MessageKeyProvider -import com.google.common.collect.Maps -import com.google.common.io.Closeables +import java.util.concurrent.ConcurrentHashMap import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.sync.ServerSyncManager import me.quantiom.advancedvanish.state.VanishStateManager @@ -29,7 +28,6 @@ object Config { private var CONFIG_VERSION: Int? = null - // get config version from maven variable init { val resource = this.javaClass.classLoader.getResourceAsStream("app.properties") val p = Properties() @@ -42,12 +40,14 @@ object Config { e.printStackTrace() AdvancedVanish.instance!!.logger.log(Level.SEVERE, "Unable to read app.properties! Shutting down...") } finally { - Closeables.closeQuietly(inputStream) + try { + inputStream?.close() + } catch (ignored: IOException) {} CONFIG_VERSION = p.getProperty("application.config.version").toInt() } } - private var messages: MutableMap> = Maps.newHashMap() + private var messages: MutableMap> = ConcurrentHashMap() fun reload() { if (!File(AdvancedVanish.instance!!.dataFolder.toString() + File.separator, "config.yml").exists()) { @@ -59,7 +59,6 @@ object Config { this.savedConfig = it.config } - // config-version check val currentConfigVersion = this.getValueOrDefault("config-version", CONFIG_VERSION)!! if (currentConfigVersion != CONFIG_VERSION) { File(AdvancedVanish.instance!!.dataFolder.toString() + File.separator, "config.yml").also { @@ -110,7 +109,6 @@ object Config { } } else { if (newYamlConfig.contains(currKey) && oldYamlConfig.contains(currKey) && newYamlConfig.get(currKey)!!::class == oldYamlConfig.get(currKey)!!::class) { - // update formatting to use MiniMessage if (newYamlConfig.get(currKey)!! is String && oldVersion < 8) { newYamlConfig.set(currKey, MiniMessage.miniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(oldYamlConfig.get(currKey) as String))) } else { @@ -127,7 +125,6 @@ object Config { return value } - // some default values return when (T::class) { Boolean::class -> false as T String::class -> "" as T @@ -189,7 +186,7 @@ object Config { } private fun reloadCommandHandlerMessages() { - val commandHandlerMessages: MutableMap = Maps.newHashMap() + val commandHandlerMessages: MutableMap = mutableMapOf() this.savedConfig?.getConfigurationSection("command-handler-messages")?.let { it.getKeys(false).forEach { key -> @@ -209,7 +206,7 @@ object Config { prefix + if (commandHandlerMessages.containsKey(key)) commandHandlerMessages[key]!! else default } - val messages: MutableMap = Maps.newHashMap() + val messages: MutableMap = mutableMapOf() messages[MessageKeys.UNKNOWN_COMMAND] = getOrDefault("unknown-command", "Invalid arguments.") .color().colorLegacy() @@ -234,4 +231,4 @@ object Config { AdvancedVanish.commandManager!!.locales.addMessages(Locales.ENGLISH, messages) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerUnVanishEvent.kt b/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerUnVanishEvent.kt index 66b8f23..89b04ae 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerUnVanishEvent.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerUnVanishEvent.kt @@ -13,4 +13,4 @@ class PlayerUnVanishEvent(val player: Player, val onLeave: Boolean) : Event() { } override fun getHandlers(): HandlerList = HANDLERS -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerVanishEvent.kt b/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerVanishEvent.kt index 426e396..8434a1a 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerVanishEvent.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/event/PlayerVanishEvent.kt @@ -14,4 +14,4 @@ class PlayerVanishEvent(val player: Player, val onJoin: Boolean) : Event() { } override fun getHandlers(): HandlerList = HANDLERS -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerUnVanishEvent.kt b/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerUnVanishEvent.kt index 2aeffe0..a60823a 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerUnVanishEvent.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerUnVanishEvent.kt @@ -20,4 +20,4 @@ class PrePlayerUnVanishEvent(val player: Player, val fromLeave: Boolean) : Event override fun setCancelled(set: Boolean) { this.isCancelled = set } override fun isCancelled(): Boolean = isCancelled -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerVanishEvent.kt b/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerVanishEvent.kt index 4f32af6..6bba8fd 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerVanishEvent.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/event/PrePlayerVanishEvent.kt @@ -20,4 +20,4 @@ class PrePlayerVanishEvent(val player: Player, val onJoin: Boolean) : Event(), C override fun setCancelled(set: Boolean) { this.isCancelled = set } override fun isCancelled(): Boolean = isCancelled -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/HooksManager.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/HooksManager.kt index 605e817..e5b13f5 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/HooksManager.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/HooksManager.kt @@ -58,4 +58,4 @@ object HooksManager { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/IHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/IHook.kt index c12eb9b..c13c83e 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/IHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/IHook.kt @@ -7,4 +7,4 @@ interface IHook : Listener { fun onEnable() {} fun onDisable() {} -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ActionBarHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ActionBarHook.kt index 55e8346..965dd95 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ActionBarHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ActionBarHook.kt @@ -1,5 +1,6 @@ package me.quantiom.advancedvanish.hook.impl +import io.papermc.paper.threadedregions.scheduler.ScheduledTask import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.config.Config import me.quantiom.advancedvanish.event.PlayerUnVanishEvent @@ -10,24 +11,27 @@ import me.quantiom.advancedvanish.util.color import org.bukkit.Bukkit import org.bukkit.entity.Player import org.bukkit.event.EventHandler -import org.bukkit.scheduler.BukkitRunnable class ActionBarHook : IHook { - private val updateTask: BukkitRunnable = - object : BukkitRunnable() { - override fun run() { - AdvancedVanishAPI.vanishedPlayers.map(Bukkit::getPlayer).map { it!! }.forEach(::sendActionBar) - } - } + private var updateTask: ScheduledTask? = null override fun getID() = "ActionBar" override fun onEnable() { - this.updateTask.runTaskTimer(AdvancedVanish.instance!!, 0L, 30L) + this.updateTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(AdvancedVanish.instance!!, { _ -> + AdvancedVanishAPI.vanishedPlayers.forEach { uuid -> + Bukkit.getPlayer(uuid)?.let { player -> + player.getScheduler().run(AdvancedVanish.instance!!, { _ -> + sendActionBar(player) + }, null) + } + } + }, 1L, 30L) } override fun onDisable() { - this.updateTask.cancel() + this.updateTask?.cancel() + this.updateTask = null } private fun sendActionBar(player: Player) { diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DiscordSrvHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DiscordSrvHook.kt index db2d2c9..8b8a003 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DiscordSrvHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DiscordSrvHook.kt @@ -5,9 +5,7 @@ import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.config.Config import me.quantiom.advancedvanish.event.PlayerUnVanishEvent import me.quantiom.advancedvanish.event.PlayerVanishEvent -import me.quantiom.advancedvanish.hook.HooksManager import me.quantiom.advancedvanish.hook.IHook -import me.quantiom.advancedvanish.util.AdvancedVanishAPI import me.quantiom.advancedvanish.util.applyPlaceholders import me.quantiom.advancedvanish.util.color import me.quantiom.advancedvanish.util.colorLegacy @@ -52,4 +50,4 @@ class DiscordSrvHook : IHook { DiscordSRV.getPlugin().sendJoinMessage(event.player, message.colorLegacy()) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DynmapHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DynmapHook.kt index 8afea35..c1ad7ca 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DynmapHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/DynmapHook.kt @@ -21,4 +21,4 @@ class DynmapHook : IHook { private fun onUnVanish(event: PlayerUnVanishEvent) { this.dynmap.setPlayerVisiblity(event.player, true) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/EssentialsHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/EssentialsHook.kt index 3350569..d02abdd 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/EssentialsHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/EssentialsHook.kt @@ -6,8 +6,6 @@ import me.quantiom.advancedvanish.event.PlayerVanishEvent import me.quantiom.advancedvanish.hook.IHook import org.bukkit.Bukkit import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority -import org.bukkit.event.player.PlayerJoinEvent class EssentialsHook : IHook { private var essentials = Bukkit.getPluginManager().getPlugin("Essentials") as Essentials @@ -27,4 +25,4 @@ class EssentialsHook : IHook { this.essentials.getUser(event.player).isHidden = false } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/LibsDisguisesHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/LibsDisguisesHook.kt index d6e3366..c9927f4 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/LibsDisguisesHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/LibsDisguisesHook.kt @@ -32,4 +32,4 @@ class LibsDisguisesHook : IHook { } } catch (ignored: Exception) {} } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt index 7010e5f..85c91af 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlaceHolderApiHook.kt @@ -25,8 +25,7 @@ class PlaceHolderApiHook : IHook { return when (params.lowercase()) { isVanishedPlaceholder -> if (player?.isVanished() == true) "Yes" else "No" vanishedPlayersPlaceholder -> AdvancedVanishAPI.vanishedPlayers - .map(Bukkit::getPlayer) - .map { it!! } + .mapNotNull(Bukkit::getPlayer) .joinToString(", ", transform = Player::getName) .ifEmpty { "None" } playerCountPlaceholder -> (Bukkit.getOnlinePlayers().size - AdvancedVanishAPI.vanishedPlayers.size).toString() @@ -44,4 +43,4 @@ class PlaceHolderApiHook : IHook { override fun onDisable() { this.expansion.unregister() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlayerParticlesHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlayerParticlesHook.kt index 850bfd2..f6b30f8 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlayerParticlesHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/PlayerParticlesHook.kt @@ -1,28 +1,31 @@ package me.quantiom.advancedvanish.hook.impl import dev.esophose.playerparticles.api.PlayerParticlesAPI +import io.papermc.paper.threadedregions.scheduler.ScheduledTask import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.hook.IHook import me.quantiom.advancedvanish.util.AdvancedVanishAPI -import org.bukkit.scheduler.BukkitRunnable +import org.bukkit.Bukkit class PlayerParticlesHook : IHook { override fun getID() = "PlayerParticles" - private val updateTask: BukkitRunnable = - object : BukkitRunnable() { - override fun run() { - AdvancedVanishAPI.vanishedPlayers - .mapNotNull { PlayerParticlesAPI.getInstance().getPPlayer(it) } - .forEach { it.activeParticles.clear() } - } - } + private var updateTask: ScheduledTask? = null override fun onEnable() { - this.updateTask.runTaskTimer(AdvancedVanish.instance!!, 0L, 20L) + this.updateTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(AdvancedVanish.instance!!, { _ -> + AdvancedVanishAPI.vanishedPlayers.forEach { uuid -> + Bukkit.getPlayer(uuid)?.let { player -> + player.getScheduler().run(AdvancedVanish.instance!!, { _ -> + PlayerParticlesAPI.getInstance().getPPlayer(player.uniqueId)?.activeParticles?.clear() + }, null) + } + } + }, 1L, 20L) } override fun onDisable() { - this.updateTask.cancel() + this.updateTask?.cancel() + this.updateTask = null } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ServerListHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ServerListHook.kt index 085e9c3..9ef8321 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ServerListHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/ServerListHook.kt @@ -19,8 +19,18 @@ class ServerListHook : IHook { override fun onPacketSending(event: PacketEvent?) { val ping = event!!.packet.serverPings.read(0) as WrappedServerPing + // Adjust the online player count ping.playersOnline -= AdvancedVanishAPI.vanishedPlayers.size - ping.setPlayers(ping.players.filter { AdvancedVanishAPI.vanishedPlayers.find { vUUID -> vUUID == it.uuid } == null }) + + // Try to filter vanished players from the sample list + // In MC 1.21+, this may fail due to NameAndId vs GameProfile conversion issues in ProtocolLib + try { + ping.setPlayers(ping.players.filter { AdvancedVanishAPI.vanishedPlayers.find { vUUID -> vUUID == it.uuid } == null }) + } catch (_: IllegalArgumentException) { + // If we can't filter the player list due to ProtocolLib compatibility issues, + // at least the player count will be correct (adjusted above) + // This prevents the error spam while maintaining basic functionality + } } } @@ -33,4 +43,4 @@ class ServerListHook : IHook { override fun onDisable() { ProtocolLibrary.getProtocolManager().removePacketListener(this.packetListener) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/SquaremapHook.kt b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/SquaremapHook.kt index 570f26a..768afc8 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/SquaremapHook.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/hook/impl/SquaremapHook.kt @@ -20,4 +20,4 @@ class SquaremapHook : IHook { private fun onUnVanish(event: PlayerUnVanishEvent) { this.squaremap.playerManager().show(event.player.uniqueId) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/listener/VanishListener.kt b/src/main/kotlin/me/quantiom/advancedvanish/listener/VanishListener.kt index 876d3f6..120454c 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/listener/VanishListener.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/listener/VanishListener.kt @@ -228,10 +228,19 @@ object VanishListener : Listener { @EventHandler private fun onDamage(event: EntityDamageByEntityEvent) { - (event.damager as? Player)?.let { damager -> - if (damager.isVanished() && !Config.getValueOrDefault("when-vanished.attack-entities", false) && !VanishStateManager.canInteract(damager)) { - damager.sendConfigMessage("cannot-attack-entities-while-vanished") - event.isCancelled = true + if (event.damager is Player) { + val damager = event.damager as Player + if (damager.isVanished()) { + if (event.entity is Player) { + damager.sendConfigMessage("cannot-attack-entities-while-vanished") + event.isCancelled = true + return + } + + if (!Config.getValueOrDefault("when-vanished.attack-entities", false) && !VanishStateManager.canInteract(damager)) { + damager.sendConfigMessage("cannot-attack-entities-while-vanished") + event.isCancelled = true + } } } diff --git a/src/main/kotlin/me/quantiom/advancedvanish/permission/IPermissionsHandler.kt b/src/main/kotlin/me/quantiom/advancedvanish/permission/IPermissionsHandler.kt index b170636..543dfcb 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/permission/IPermissionsHandler.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/permission/IPermissionsHandler.kt @@ -4,4 +4,4 @@ import org.bukkit.entity.Player interface IPermissionsHandler { fun getVanishPriority(player: Player): Int -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/permission/impl/LuckPermsHandler.kt b/src/main/kotlin/me/quantiom/advancedvanish/permission/impl/LuckPermsHandler.kt index 7d6fd55..3df7309 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/permission/impl/LuckPermsHandler.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/permission/impl/LuckPermsHandler.kt @@ -14,4 +14,4 @@ class LuckPermsHandler : IPermissionsHandler { ))?.toInt() ?: 0 } ?: 0 } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/state/VanishStateManager.kt b/src/main/kotlin/me/quantiom/advancedvanish/state/VanishStateManager.kt index 3129ad8..c8ea8ed 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/state/VanishStateManager.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/state/VanishStateManager.kt @@ -1,12 +1,10 @@ package me.quantiom.advancedvanish.state -import com.google.common.collect.Maps -import com.google.common.collect.Sets import com.google.gson.Gson import com.google.gson.reflect.TypeToken +import java.util.concurrent.ConcurrentHashMap import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.config.Config -import me.quantiom.advancedvanish.util.AdvancedVanishAPI import me.quantiom.advancedvanish.util.isVanished import org.bukkit.Bukkit import org.bukkit.entity.Player @@ -18,8 +16,8 @@ import java.lang.reflect.Type import java.util.* object VanishStateManager { - val savedVanishStates: MutableMap = Maps.newHashMap() - val interactEnabled: MutableSet = Sets.newHashSet() + val savedVanishStates: MutableMap = ConcurrentHashMap() + val interactEnabled: MutableSet = ConcurrentHashMap.newKeySet() fun onConfigReload() { if (!Config.getValueOrDefault("keep-vanish-state", false) @@ -98,4 +96,4 @@ object VanishStateManager { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/sync/IServerSyncStore.kt b/src/main/kotlin/me/quantiom/advancedvanish/sync/IServerSyncStore.kt index 4901e77..ae826c9 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/sync/IServerSyncStore.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/sync/IServerSyncStore.kt @@ -8,4 +8,4 @@ interface IServerSyncStore { fun get(key: UUID): Boolean fun setAsync(key: UUID, value: Boolean) -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/sync/ServerSyncManager.kt b/src/main/kotlin/me/quantiom/advancedvanish/sync/ServerSyncManager.kt index 9f861be..af21e60 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/sync/ServerSyncManager.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/sync/ServerSyncManager.kt @@ -1,6 +1,6 @@ package me.quantiom.advancedvanish.sync -import com.google.common.collect.Maps +import java.util.concurrent.ConcurrentHashMap import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.config.Config import me.quantiom.advancedvanish.event.PlayerUnVanishEvent @@ -17,7 +17,7 @@ object ServerSyncManager : Listener { var crossServerSupportEnabled: Boolean = false var serverSyncStoreImpl: IServerSyncStore? = null - var loginVanishStates: MutableMap = Maps.newHashMap() + var loginVanishStates: MutableMap = ConcurrentHashMap() fun setup() { if (Config.getValueOrDefault("cross-server-support.enabled", false)) { @@ -32,7 +32,6 @@ object ServerSyncManager : Listener { this.crossServerSupportEnabled = serverSyncStoreImpl!!.setup() } else { - // if the cross-server-support option gets disabled when reloading this.serverSyncStoreImpl?.close() this.crossServerSupportEnabled = false } @@ -66,4 +65,4 @@ object ServerSyncManager : Listener { if (!this.crossServerSupportEnabled) return this.serverSyncStoreImpl?.setAsync(key, value) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/RedisServerSyncStore.kt b/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/RedisServerSyncStore.kt index d163b6b..1ebd7de 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/RedisServerSyncStore.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/RedisServerSyncStore.kt @@ -52,7 +52,7 @@ object RedisServerSyncStore : IServerSyncStore { } override fun setAsync(key: UUID, value: Boolean) { - Bukkit.getScheduler().runTaskAsynchronously(AdvancedVanish.instance!!, Runnable { + Bukkit.getAsyncScheduler().runNow(AdvancedVanish.instance!!) { try { this.pool?.resource?.let { resource -> resource.set(this.getPlayerKey(key), value.toString()) @@ -62,8 +62,8 @@ object RedisServerSyncStore : IServerSyncStore { AdvancedVanish.log(Level.SEVERE, "There was an error while attempting to make a connection with Redis: ") e.printStackTrace() } - }) + } } private fun getPlayerKey(uuid: UUID) = "advancedvanish-${uuid}" -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/SqlServerSyncStore.kt b/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/SqlServerSyncStore.kt index 008dbae..244341a 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/SqlServerSyncStore.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/sync/impl/SqlServerSyncStore.kt @@ -30,8 +30,7 @@ object SqlServerSyncStore : IServerSyncStore { val statement = this.connection!!.createStatement() statement.executeUpdate(""" CREATE TABLE IF NOT EXISTS advancedvanish ( - id INT AUTO_INCREMENT PRIMARY KEY, - uuid CHAR(36) NOT NULL, + uuid CHAR(36) NOT NULL PRIMARY KEY, state BOOLEAN NOT NULL ); """.trimIndent()) @@ -69,7 +68,7 @@ object SqlServerSyncStore : IServerSyncStore { } override fun setAsync(key: UUID, value: Boolean) { - Bukkit.getScheduler().runTaskAsynchronously(AdvancedVanish.instance!!, Runnable { + Bukkit.getAsyncScheduler().runNow(AdvancedVanish.instance!!) { try { val updateQuery = "INSERT INTO advancedvanish (uuid, state) VALUES (?, ?) ON DUPLICATE KEY UPDATE state = ?" val preparedStatement = connection!!.prepareStatement(updateQuery) @@ -81,6 +80,6 @@ object SqlServerSyncStore : IServerSyncStore { AdvancedVanish.log(Level.SEVERE, "There was an error while attempting to make a connection with SQL: ") e.printStackTrace() } - }) + } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt b/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt index bfe190a..258c8fb 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/util/AdvancedVanishAPI.kt @@ -1,7 +1,7 @@ package me.quantiom.advancedvanish.util -import com.google.common.collect.Lists -import com.google.common.collect.Maps +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.config.Config import me.quantiom.advancedvanish.event.PlayerUnVanishEvent @@ -21,16 +21,9 @@ import java.util.* fun Player.isVanished() = AdvancedVanishAPI.isPlayerVanished(this) object AdvancedVanishAPI { - val vanishedPlayers: MutableList = Lists.newArrayList() - private val storedPotionEffects: MutableMap> = Maps.newHashMap() - - /** - * Vanishes a player if the PrePlayerVanishEvent - * does not get cancelled. - * - * @param player The player to vanish - * @param onJoin If this is being called from the PlayerJoinEvent, used for hook/fake join and leave message functionality - */ + val vanishedPlayers: MutableList = CopyOnWriteArrayList() + private val storedPotionEffects: MutableMap> = ConcurrentHashMap() + fun vanishPlayer(player: Player, onJoin: Boolean = false) { val prePlayerVanishEvent = PrePlayerVanishEvent(player, onJoin) Bukkit.getPluginManager().callEvent(prePlayerVanishEvent) @@ -38,18 +31,16 @@ object AdvancedVanishAPI { if (prePlayerVanishEvent.isCancelled) return this.vanishedPlayers.add(player.uniqueId) - - // add vanished metadata to player for other plugins to use + player.setMetadata("vanished", FixedMetadataValue(AdvancedVanish.instance!!, true)) - val previousEffects: MutableList = Lists.newArrayList(); - - // add potion effects - Config.getValueOrDefault("when-vanished.give-potion-effects", Lists.newArrayList()) + val previousEffects: MutableList = mutableListOf() + + Config.getValueOrDefault("when-vanished.give-potion-effects", mutableListOf()) .map { it.split(":") } .filter { it.size > 1 } - .forEach { - PotionEffectType.values().find { e -> e?.name == it[0] }?.run { + .forEach { potionInfo -> + PotionEffectType.values().find { e -> e?.name == potionInfo[0] }?.run { val currentPotionEffect = player.activePotionEffects.find { e -> e.type == this } if (currentPotionEffect != null) { @@ -57,18 +48,17 @@ object AdvancedVanishAPI { } else { previousEffects.add(this.createEffect(0, 0)) } - - // Check server ver for impl of infinite duration (1.19.4+) + val duration = if (Bukkit.getVersion().contains("1.19.4") || Bukkit.getVersion().contains(" 1.2")) { -1 } else Integer.MAX_VALUE if (onJoin) { - Bukkit.getScheduler().runTaskLater(AdvancedVanish.instance!!, Runnable { - player.addPotionEffect(this.createEffect(duration, it[1].toInt() - 1)) - }, 10L) + player.getScheduler().runDelayed(AdvancedVanish.instance!!, { + player.addPotionEffect(this.createEffect(duration, potionInfo[1].toInt() - 1)) + }, null, 10L) } else { - player.addPotionEffect(this.createEffect(duration, it[1].toInt() - 1)) + player.addPotionEffect(this.createEffect(duration, potionInfo[1].toInt() - 1)) } } } @@ -82,19 +72,21 @@ object AdvancedVanishAPI { Bukkit.getOnlinePlayers() .filter { it.uniqueId != player.uniqueId } - .forEach { - if (usePriority && it.hasPermission(Config.getValueOrDefault( - "permissions.vanish", - "advancedvanish.vanish" - ))) { - val pPriority = PermissionsManager.handler!!.getVanishPriority(it) - - if (pPriority < playerPriority!!) { - it.hidePlayer(player) + .forEach { observer -> + observer.getScheduler().run(AdvancedVanish.instance!!, { + if (usePriority && observer.hasPermission(Config.getValueOrDefault( + "permissions.vanish", + "advancedvanish.vanish" + ))) { + val pPriority = PermissionsManager.handler!!.getVanishPriority(observer) + + if (pPriority < playerPriority!!) { + observer.hidePlayer(AdvancedVanish.instance!!, player) + } + } else { + observer.hidePlayer(AdvancedVanish.instance!!, player) } - } else { - it.hidePlayer(player) - } + }, null) } if (!onJoin && Config.getValueOrDefault("join-leave-messages.fake-leave-message-on-vanish.enable", false)) { @@ -115,13 +107,6 @@ object AdvancedVanishAPI { Bukkit.getPluginManager().callEvent(PlayerVanishEvent(player, onJoin)) } - /** - * Vanishes a player if the PrePlayerUnVanishEvent - * does not get cancelled. - * - * @param player The player to unvanish - * @param onLeave If this is being called from the PlayerQuitEvent, used for hook/fake join and leave message functionality - */ fun unVanishPlayer(player: Player, onLeave: Boolean = false) { val prePlayerUnVanishEvent = PrePlayerUnVanishEvent(player, onLeave) Bukkit.getPluginManager().callEvent(prePlayerUnVanishEvent) @@ -130,7 +115,6 @@ object AdvancedVanishAPI { this.vanishedPlayers.remove(player.uniqueId) - // remove vanished metadata from player player.removeMetadata("vanished", AdvancedVanish.instance!!) VanishStateManager.interactEnabled.remove(player.uniqueId) @@ -148,11 +132,12 @@ object AdvancedVanishAPI { } Bukkit.getOnlinePlayers() - .forEach { - it.showPlayer(player) + .forEach { observer -> + observer.getScheduler().run(AdvancedVanish.instance!!, { + observer.showPlayer(AdvancedVanish.instance!!, player) + }, null) } - // ignore if they are in spectator mode (allowed to fly by default) if (player.gameMode != GameMode.SPECTATOR && !player.hasPermission(Config.getValueOrDefault("permissions.keep-fly-on-unvanish", "advancedvanish.keep-fly")) && !Config.getValueOrDefault("advancedvanish.fly.keep-on-unvanish", false)) { player.isFlying = false @@ -177,25 +162,14 @@ object AdvancedVanishAPI { this.vanishedPlayers.forEach { uuid -> Bukkit.getPlayer(uuid)?.let { if (!this.canSee(player, it)) { - player.hidePlayer(it) + player.hidePlayer(AdvancedVanish.instance!!, it) } } } } - /** - * Checks if a player is vanished - * - * @param player The player to check if vanished - */ fun isPlayerVanished(player: Player): Boolean = this.vanishedPlayers.contains(player.uniqueId) - /** - * Returns true if `player` can see `target` - * - * @param player - * @param target - */ fun canSee(player: Player, target: Player): Boolean { if (!target.isVanished()) return false @@ -204,8 +178,8 @@ object AdvancedVanishAPI { "advancedvanish.vanish" ))) return false - if (!Config.usingPriorities) return true + if (!Config.usingPriorities || PermissionsManager.handler == null) return true return PermissionsManager.handler!!.getVanishPriority(player) >= PermissionsManager.handler!!.getVanishPriority(target) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/quantiom/advancedvanish/util/Extensions.kt b/src/main/kotlin/me/quantiom/advancedvanish/util/Extensions.kt index fd7bdc3..eb7d8c0 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/util/Extensions.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/util/Extensions.kt @@ -1,12 +1,10 @@ package me.quantiom.advancedvanish.util -import me.quantiom.advancedvanish.AdvancedVanish import me.quantiom.advancedvanish.config.Config import net.kyori.adventure.text.Component import net.kyori.adventure.text.minimessage.MiniMessage import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer import org.bukkit.command.CommandSender -import org.bukkit.entity.Player fun String.applyPlaceholders(vararg pairs: Pair): String { var intermediate = this diff --git a/src/main/kotlin/me/quantiom/advancedvanish/util/UpdateChecker.kt b/src/main/kotlin/me/quantiom/advancedvanish/util/UpdateChecker.kt index f687b2e..2a3b251 100644 --- a/src/main/kotlin/me/quantiom/advancedvanish/util/UpdateChecker.kt +++ b/src/main/kotlin/me/quantiom/advancedvanish/util/UpdateChecker.kt @@ -13,7 +13,7 @@ object UpdateChecker { private const val RESOURCE_ID = 86036 fun getVersion(consumer: Consumer) { - Bukkit.getScheduler().runTaskAsynchronously(AdvancedVanish.instance!!, Runnable { + Bukkit.getAsyncScheduler().runNow(AdvancedVanish.instance!!) { try { URL("https://api.spigotmc.org/legacy/update.php?resource=${RESOURCE_ID}").openStream() .use { inputStream -> @@ -26,6 +26,6 @@ object UpdateChecker { } catch (exception: IOException) { AdvancedVanish.instance!!.logger.info("Unable to check for updates: " + exception.message) } - }) + } } -} \ No newline at end of file +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9a6018d..b7316e3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,16 +2,15 @@ name: ${project.name} description: ${project.description} author: quantiom version: ${project.version} -main: ${project.groupId}.${project.artifactId}.${project.name}Plugin +main: me.quantiom.advancedvanish.AdvancedVanishPlugin softdepend: [LuckPerms, PlaceholderAPI, GroupManager, PermissionsEx, bPermissions, DiscordSRV, Dynmap, squaremap, LibsDisguises, PlayerParticles, Essentials, PlaceholderAPI, ProtocolLib] -api-version: 1.20 +api-version: '1.21' +folia-supported: true +libraries: + - 'redis.clients:jedis:5.1.0' + commands: vanish: description: The main vanish command. aliases: [v, advancedvanish] usage: /vanish - -libraries: -- 'co.aikar:acf-paper:0.5.1-SNAPSHOT' -- 'redis.clients:jedis:jar:5.1.0' -- 'org.jetbrains.kotlin:kotlin-stdlib:jar:1.9.22'