-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vanish placeholders
- Loading branch information
Showing
8 changed files
with
99 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version=3.4.0 | ||
version=3.5.0 | ||
plugin-name=VelocityVanish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 72 additions & 2 deletions
74
src/main/java/ir/syrent/velocityvanish/spigot/hook/PlaceholderAPIHook.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,81 @@ | ||
package ir.syrent.velocityvanish.spigot.hook | ||
|
||
class PlaceholderAPIHook constructor(name: String) : Dependency(name) { | ||
import ir.syrent.velocityvanish.spigot.VelocityVanishSpigot | ||
import ir.syrent.velocityvanish.spigot.ruom.Ruom | ||
import ir.syrent.velocityvanish.spigot.storage.Settings | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion | ||
import org.bukkit.OfflinePlayer | ||
|
||
class PlaceholderAPIHook constructor(plugin: VelocityVanishSpigot, name: String) : Dependency(name) { | ||
|
||
init { | ||
if (exists) { | ||
VanishExpansion(plugin).register() | ||
} | ||
} | ||
|
||
override fun features(): List<String> { | ||
return mutableListOf( | ||
"Access to all placeholders in all plugin messages." | ||
"Access to all placeholders in all plugin messages.", | ||
"Add plugin placeholders like %velocityvanish_online_total% to PlaceholderAPI." | ||
) | ||
} | ||
|
||
class VanishExpansion( | ||
private val plugin: VelocityVanishSpigot | ||
) : PlaceholderExpansion() { | ||
override fun getIdentifier(): String { | ||
return Ruom.getPlugin().description.name.lowercase() | ||
} | ||
|
||
override fun getAuthor(): String { | ||
return Ruom.getPlugin().description.authors.joinToString(", ") | ||
} | ||
|
||
override fun getVersion(): String { | ||
return Ruom.getPlugin().description.version | ||
} | ||
|
||
override fun persist(): Boolean { | ||
return true | ||
} | ||
|
||
override fun canRegister(): Boolean { | ||
return true | ||
} | ||
|
||
override fun onRequest(player: OfflinePlayer, params: String): String? { | ||
if (params.equals("vanished", true)) { | ||
return if (plugin.vanishedNames.contains(player.name)) "true" else "false" | ||
} | ||
|
||
if (params.equals("count", true)) { | ||
return plugin.vanishedNames.size.toString() | ||
} | ||
|
||
if (params.startsWith("online_")) { | ||
val type = params.substring(7) | ||
|
||
return if (type.equals("here", true)) { | ||
Ruom.getOnlinePlayers().filter { !plugin.vanishedNames.contains(it.name) }.size.toString() | ||
} else if (type.equals("total", true)) { | ||
val players = mutableListOf<String>() | ||
for (serverPlayers in plugin.proxyPlayers.values.filter { it.isNotEmpty() }) { | ||
players.addAll(serverPlayers) | ||
} | ||
players.filter { !plugin.vanishedNames.contains(it) }.size.toString() | ||
} else { | ||
if (!Settings.velocitySupport) { | ||
warning("Plugin trying to get online players from other servers but Velocity support is disabled.") | ||
Ruom.getOnlinePlayers().filter { !plugin.vanishedNames.contains(it.name) }.size.toString() | ||
} else { | ||
(plugin.proxyPlayers[type.lowercase()]?.filter { !plugin.vanishedNames.contains(it) }?.size ?: 0).toString() | ||
} | ||
} | ||
} | ||
|
||
return null | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"id":"velocityvanish","name":"VelocityVanish","version":"3.4.0","description":"Vanish plugin for velocity servers","url":"syrent.ir","authors":["Syrent"],"dependencies":[],"main":"ir.syrent.velocityvanish.velocity.VelocityVanish"} | ||
{"id":"velocityvanish","name":"VelocityVanish","version":"3.5.0","description":"Vanish plugin for velocity servers","url":"syrent.ir","authors":["Syrent"],"dependencies":[],"main":"ir.syrent.velocityvanish.velocity.VelocityVanish"} |