Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class LuckPermsGroup(private var group: Group, private var luckPerms: LuckPerms)
}

override fun containsPlayer(uniqueId: UUID): Boolean {
return containsPlayerFuture(uniqueId).join()
return containsPlayerAsync(uniqueId).join()
}

override fun containsPlayerFuture(uniqueId: UUID): CompletableFuture<Boolean> {
override fun containsPlayerAsync(uniqueId: UUID): CompletableFuture<Boolean> {
return luckPerms.userManager.loadUser(uniqueId).thenApplyAsync { user ->
return@thenApplyAsync user.primaryGroup == getName()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,65 @@ import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.TextColor
import java.util.*

interface PrefixesApi {
interface PrefixesApi<Player> {

/**
* Registers a player to be able to see prefixes
* @param uniqueId UUID of the target player
*/
fun registerViewer(uniqueId: UUID)

/**
* Returns if a viewer exists
* @param uniqueId UUID of the target player
*/
fun hasViewer(uniqueId: UUID): Boolean

/**
* Removes a viewer
* @param uniqueId UUID of the target player
*/
fun removeViewer(uniqueId: UUID)
fun registerAudience(audience: Audience)
fun hasAudience(audience: Audience): Boolean
fun removeAudience(audience: Audience)

/**
* Sets the prefix and suffix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param player Target player
* @param group
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
* @param audience An audience to this change (if null, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, group: PrefixesGroup, vararg viewers: UUID)
fun setWholeName(player: Player, group: PrefixesGroup, audience: Audience? = null)

/**
* Sets the prefix and suffix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param player Target player
* @param groupName
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
* @param audience An audience to this change (if null, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, groupName: String, vararg viewers: UUID)
fun setWholeName(player: Player, groupName: String, audience: Audience? = null)

/**
* Sets the prefix and suffix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param prefix the targets prefix
* @param color the targets team color
* @param suffix the targets suffix
* @param player Target player
* @param prefix the target prefix
* @param color the target team color
* @param suffix the target suffix
* @param priority the users Tablist priority
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
* @param audience An audience to this change (if null, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, prefix: Component, color: TextColor, suffix: Component, priority: Int, vararg viewers: UUID)
fun setWholeName(
player: Player,
prefix: Component,
color: TextColor,
suffix: Component,
priority: Int,
audience: Audience? = null
)

fun setWholeName(player: Player, data: PrefixesPlayerData, audience: Audience? = null)

fun editWholeName(player: Player, audience: Audience? = null, action: (PrefixesPlayerData) -> Unit)

/**
* Sets the prefix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param player Target player
* @param prefix prefix to set
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
* @param audience An audience to this change (if null, everyone is affected)
*/
fun setPrefix(uniqueId: UUID, prefix: Component, vararg viewers: UUID)
fun setPrefix(player: Player, prefix: Component, audience: Audience? = null)

/**
* Sets the prefix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param player Target player
* @param suffix suffix to set
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
* @param audience An audience to this change (if null, everyone is affected)
*/
fun setSuffix(uniqueId: UUID, suffix: Component, vararg viewers: UUID)
fun setSuffix(player: Player, suffix: Component, audience: Audience? = null)

/**
* Returns all registered [PrefixesGroup] ordered by priority
Expand All @@ -75,100 +72,38 @@ interface PrefixesApi {

/**
* Returns the highest [PrefixesGroup] of a player
* @param uniqueId UUID of the target player
* @param player Target player
*/
fun getHighestGroup(uniqueId: UUID): PrefixesGroup
fun getHighestGroup(player: Player): PrefixesGroup

/**
* Adds a [PrefixesGroup]
* @param group
*/
fun addGroup(group: PrefixesGroup)

/**
* Changes the [PrefixesActor] of the server instance (e.g. to a bukkit actor)
* @param actor
*/
fun setActor(actor: PrefixesActor)

/**
* Changes the Scoreboard Team color of the target player (Used in 1.12+ to make player names colorful)
* @param uniqueId UUID of the target player
* @param player Target player
* @param color the [TextColor] of the target players team
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
* @param audience An audience to this change (if null, everyone is affected)
*/
fun setColor(uniqueId: UUID, color: TextColor, vararg viewers: UUID)
fun setColor(player: Player, color: TextColor, audience: Audience? = null)

/**
* Sets the used PrefixesConfig
* @param config Specifies the new [PrefixesConfig]
*/
fun setConfig(config: PrefixesConfig)

/**
* Returns a formatted chat message of the target player that will be sent to the viewer
* @param target UUID of the target player
* @param viewer UUID of the viewing player (if null, only default prefix and suffix of the players group will be shown)
* @param format the chat format the message should follow
* @param message Message sent by the [target]
*/
fun formatChatMessage(target: UUID, viewer: UUID?, format: String, message: Component): Component
/**
* Sets the prefix and suffix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param group
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, group: PrefixesGroup, viewers: Audience)

/**
* Sets the prefix and suffix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param groupName
* @param viewers An [Audience] of all viewers of this change (if empty, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, groupName: String, viewers: Audience)

/**
* Sets the prefix and suffix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param prefix the targets prefix
* @param color the targets team color
* @param suffix the targets suffix
* @param viewers An [Audience] of all viewers of this change (if empty, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, prefix: Component, color: TextColor, suffix: Component, priority: Int, viewers: Audience)
/**
* Sets the prefix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param prefix prefix to set
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
*/
fun setPrefix(uniqueId: UUID, prefix: Component, viewers: Audience)

/**
* Sets the prefix of a player in both Tab and Chat
* @param uniqueId UUID of the target player
* @param suffix suffix to set
* @param viewers An [Audience] of all viewers of this change (if empty, everyone is affected)
*/
fun setSuffix(uniqueId: UUID, suffix: Component, viewers: Audience)

/**
* Changes the Scoreboard Team color of the target player (Used in 1.12+ to make player names colorful)
* @param uniqueId UUID of the target player
* @param color [TextColor] the color of the target players team
* @param viewers An [Audience] of all viewers of this change (if empty, everyone is affected)
*/
fun setColor(uniqueId: UUID, color: TextColor, viewers: Audience)

/**
* Returns a formatted chat message of the target player that will be sent to the viewer
* @param target UUID of the target player
* @param viewer An [Audience] of the viewing player (if empty, only default prefix and suffix of the targets group will be shown)
* @param target Target player
* @param audience An audience to this change (if null, everyone is affected)
* @param format the chat format the message should follow
* @param message Message sent by the [target]
*/
fun formatChatMessage(target: UUID, viewer: Audience, format: String, message: Component): Component
fun formatChatMessage(target: Player, format: String, message: Component, audience: Audience? = null): Component

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package app.simplecloud.plugin.prefixes.api

interface PrefixesConfig {
fun getChatFormat(): String
class PrefixesConfig {
private var chatFormat: String = "<prefix><name_colored><suffix><gray>:</gray> <white><message></white>"

fun getChatFormat(): String {
return chatFormat
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.google.gson.stream.JsonReader
import java.io.File
import java.io.FileReader

class PrefixesConfigParser<C : PrefixesConfig>(private val configFile: File) {
fun parse(type: Class<C>, default: C): C {
class PrefixesConfigParser(private val configFile: File) {
fun parse(type: Class<PrefixesConfig>, default: PrefixesConfig): PrefixesConfig {
if (!configFile.exists()) return default
val gson = Gson()
val reader = JsonReader(FileReader(configFile))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
package app.simplecloud.plugin.prefixes.api

import net.kyori.adventure.text.format.TextColor

interface PrefixesDisplay<C, P, T> {
fun createTeam(id: String, priority: Int = 0): T?
fun getTeam(id: String): T?
fun updatePrefix(id: String, prefix: C)
fun getPriority(team: T): Int?
fun updateSuffix(id: String, suffix: C)

fun updatePriority(id: String, priority: Int): T?
fun updateColor(id: String, color: TextColor)
fun update(id: String, prefix: C, suffix: C, priority: Int)

fun toPriorityString(priority: Int): String {
if (priority < 0) return "000"
if (priority > 999) return "999"
var result = priority.toString()
for (i in 0 until 3 - result.length) {
result = "0${result}"
}
return result
}

fun setPlayer(id: String, player: P)
fun removePlayer(player: P)
fun setViewer(player: P): Boolean
fun addViewer(player: P): Boolean
fun removeViewer(player: P): Boolean
fun getViewers(): Set<P>
interface PrefixesDisplay<P> {
/**
* This is called whenever we transition from another display (global display)
*/
fun transition(player: P, content: PrefixesPlayerData)

fun apply(player: P, content: PrefixesPlayerData)
fun getCurrent(player: P): PrefixesPlayerData?
fun remove(player: P)
fun getAll(): Map<P, PrefixesPlayerData>
}
Loading