Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
51 changes: 31 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
kotlin("jvm") version "1.8.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
java
alias(libs.plugins.kotlin)
alias(libs.plugins.shadow)
}

allprojects {
group = "app.simplecloud.plugin"
version = "1.0-SNAPSHOT"

apply {
plugin("java")
plugin("org.jetbrains.kotlin.jvm")
plugin("com.github.johnrengelman.shadow")
}
version = "1.1-SNAPSHOT"

repositories {
mavenCentral()
Expand All @@ -23,30 +17,47 @@ allprojects {
maven("https://oss.sonatype.org/content/repositories/central")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
maven("https://repo.dmulloy2.net/repository/public/")
}
}

kotlin {
jvmToolchain(17)
subprojects {

apply {
plugin("org.jetbrains.kotlin.jvm")
plugin("com.gradleup.shadow")
}

dependencies {
compileOnly(rootProject.libs.kotlin.jvm)
compileOnly(rootProject.libs.kotlin.test)

compileOnly("net.luckperms:api:5.4")
compileOnly("space.chunks.custom-names:custom-names-api:1.0.6")
implementation("net.kyori:adventure-api:4.14.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation("net.kyori:adventure-text-minimessage:4.14.0")
}
}

subprojects {
dependencies {
implementation(kotlin("stdlib"))
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

tasks.test {
useJUnitPlatform()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlin {
jvmToolchain(21)
compilerOptions {
jvmTarget = JvmTarget.JVM_21
languageVersion = KotlinVersion.KOTLIN_2_0
apiVersion = KotlinVersion.KOTLIN_2_0
}
}

tasks.named("shadowJar", ShadowJar::class) {
tasks.shadowJar {
mergeServiceFiles()
archiveFileName.set("${project.name}.jar")
}
}
15 changes: 15 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[versions]
kotlin = "2.0.20"
shadow = "8.3.3"
paper-api = "1.21.4-R0.1-SNAPSHOT"
paperweight = "2.0.0-beta.12"

[libraries]
kotlin-jvm = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paper-api" }

[plugins]
paperweight-userdev = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package app.simplecloud.plugin.prefixes.api

import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.TextColor
import java.util.*

interface PrefixesActor {
fun applyGroup(target: UUID, group: PrefixesGroup)

fun setPrefix(target: UUID, prefix: Component)

fun setSuffix(target: UUID, suffix: Component)

fun setColor(target: UUID, color: String)

fun formatMessage(target: UUID, format: String, message: Component): Component

fun registerViewer(target: UUID, api: PrefixesApi)
fun hasViewer(target: UUID): Boolean
fun removeViewer(target: UUID)
fun applyGroup(target: UUID, group: PrefixesGroup, vararg viewers: UUID)
fun setPrefix(target: UUID, prefix: Component, vararg viewers: UUID)
fun setSuffix(target: UUID, suffix: Component, vararg viewers: UUID)
fun setColor(target: UUID, color: TextColor, vararg viewers: UUID)
fun apply(target: UUID, prefix: Component, color: TextColor, suffix: Component, priority: Int, vararg viewers: UUID)
fun formatMessage(target: UUID, viewer: UUID?, format: String, message: Component): Component
fun remove(target: UUID)
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,72 @@
package app.simplecloud.plugin.prefixes.api

import net.kyori.adventure.audience.Audience
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.TextColor
import java.util.*

interface PrefixesApi {

/**
* 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)

/**
* 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)
fun setWholeName(uniqueId: UUID, group: PrefixesGroup, vararg viewers: UUID)

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

/**
* 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 priority the users Tablist priority
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
*/
fun setWholeName(uniqueId: UUID, groupName: String)
fun setWholeName(uniqueId: UUID, prefix: Component, color: TextColor, suffix: Component, priority: Int, vararg viewers: UUID)

/**
* 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)
fun setPrefix(uniqueId: UUID, prefix: Component, vararg viewers: UUID)

/**
* 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 A list of all viewers of this change (if empty, everyone is affected)
*/
fun setSuffix(uniqueId: UUID, suffix: Component)
fun setSuffix(uniqueId: UUID, suffix: Component, vararg viewers: UUID)

/**
* Returns all registered [PrefixesGroup] ordered by priority
Expand Down Expand Up @@ -59,14 +94,81 @@ interface PrefixesApi {
/**
* 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 Color string (ChatColor on spigot, hex colors on other server implementations)
* @param color the [TextColor] of the target players team
* @param viewers A list of all viewers of this change (if empty, everyone is affected)
*/
fun setColor(uniqueId: UUID, color: String)
fun setColor(uniqueId: UUID, color: TextColor, vararg viewers: UUID)

/**
* 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 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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.simplecloud.plugin.prefixes.api

import app.simplecloud.plugin.prefixes.api.impl.PrefixesApiImpl

interface PrefixesChatLoader {

/**
* Instantiates the chat provider of PrefixesApi (useful for sharding)
* @param api the [PrefixesApiImpl] object the ChatLoader belongs to
*/
fun load(api: PrefixesApiImpl)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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>
}
Loading