diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4f0cde9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,102 @@ +name: Publish to Maven & Create GitHub Release + +on: + push: + branches: + - 'version/*' + workflow_dispatch: + +env: + SLNE_SNAPSHOTS_REPO_USERNAME: ${{ secrets.SLNE_SNAPSHOTS_REPO_USERNAME }} + SLNE_SNAPSHOTS_REPO_PASSWORD: ${{ secrets.SLNE_SNAPSHOTS_REPO_PASSWORD }} + SLNE_RELEASES_REPO_USERNAME: ${{ secrets.SLNE_RELEASES_REPO_USERNAME }} + SLNE_RELEASES_REPO_PASSWORD: ${{ secrets.SLNE_RELEASES_REPO_PASSWORD }} + MODULE_REGEX: "surf-tab-api.*-all\\.jar$|surf-tab-velocity.*-all\\.jar$" + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + +jobs: + build: + runs-on: ubuntu-latest + environment: production + steps: + - name: Collect Workflow Telemetry + uses: catchpoint/workflow-telemetry-action@v2 + + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: gradle-${{ runner.os }}- + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: 'graalvm' + java-version: '24' + + - name: Build all modules with Gradle + run: ./gradlew build shadowJar --parallel --no-scan + + - name: Publish all modules to Maven + run: ./gradlew publish --parallel --no-scan + + - name: Extract Project Version and Snapshot Flag from Gradle + id: get_version + run: | + VERSION=$(./gradlew properties --no-daemon \ + | grep '^version:' \ + | awk '{print $2}') + SNAPSHOT_FLAG=$(./gradlew properties --no-daemon \ + | grep '^snapshot:' \ + | awk '{print $2}') + if [ "$SNAPSHOT_FLAG" = "true" ]; then + VERSION="${VERSION}-SNAPSHOT" + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "SNAPSHOT_FLAG=$SNAPSHOT_FLAG" >> $GITHUB_ENV + + - name: Determine release flags + run: | + CURRENT_BRANCH=${GITHUB_REF#refs/heads/} + # prerelease only for snapshots + if [ "${SNAPSHOT_FLAG}" = "true" ]; then + echo "PRERELEASE=true" >> $GITHUB_ENV + else + echo "PRERELEASE=false" >> $GITHUB_ENV + fi + # make_latest false for snapshots or non-default branches + if [ "${SNAPSHOT_FLAG}" = "true" ] || [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then + echo "MAKE_LATEST=false" >> $GITHUB_ENV + else + echo "MAKE_LATEST=true" >> $GITHUB_ENV + fi + + - name: Find and filter JAR files + id: find_jars + run: | + echo "JAR_FILES<> $GITHUB_ENV + find . -path "**/build/libs/*.jar" \ + | grep -E "${{ env.MODULE_REGEX }}" \ + >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ env.VERSION }} + name: Release ${{ env.VERSION }} + draft: false + prerelease: ${{ env.PRERELEASE }} + make_latest: ${{ env.MAKE_LATEST }} + files: ${{ env.JAR_FILES }} + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 7bbfa4d..fd4fc47 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,28 @@ +import dev.slne.surf.surfapi.gradle.util.slneReleases + buildscript { repositories { gradlePluginPortal() maven("https://repo.slne.dev/repository/maven-public/") { name = "maven-public" } } dependencies { - classpath("dev.slne.surf:surf-api-gradle-plugin:1.21.11-1.7.0") + classpath("dev.slne.surf:surf-api-gradle-plugin:1.21.11+") } } allprojects { group = "dev.slne.surf.tab" version = findProperty("version") as String +} + +subprojects { + afterEvaluate { + plugins.withType { + configure { + repositories { + slneReleases() + } + } + } + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 57f03c0..2920250 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ kotlin.code.style=official kotlin.stdlib.default.dependency=false org.gradle.parallel=true -version=1.21.11-1.0.0-SNAPSHOT \ No newline at end of file +version=1.21.11-1.0.2-SNAPSHOT \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/surf-tab-api/build.gradle.kts b/surf-tab-api/build.gradle.kts index 34ec0c2..6e6fa0f 100644 --- a/surf-tab-api/build.gradle.kts +++ b/surf-tab-api/build.gradle.kts @@ -1,3 +1,8 @@ plugins { - id("dev.slne.surf.surfapi.gradle.velocity") + id("dev.slne.surf.surfapi.gradle.core") +} + + +surfCoreApi { + withSurfRedis() } \ No newline at end of file diff --git a/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabEntryUpdateRedisEvent.kt b/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabEntryUpdateRedisEvent.kt new file mode 100644 index 0000000..73d5565 --- /dev/null +++ b/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabEntryUpdateRedisEvent.kt @@ -0,0 +1,11 @@ +package dev.slne.surf.tab.api.redis + +import dev.slne.surf.redis.event.RedisEvent +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +data class TabEntryUpdateRedisEvent( + val toUpdateUuid: @Contextual UUID +) : RedisEvent() \ No newline at end of file diff --git a/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabHideRedisEvent.kt b/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabHideRedisEvent.kt new file mode 100644 index 0000000..1b477a0 --- /dev/null +++ b/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabHideRedisEvent.kt @@ -0,0 +1,12 @@ +package dev.slne.surf.tab.api.redis + +import dev.slne.surf.redis.event.RedisEvent +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +data class TabHideRedisEvent( + val player: @Contextual UUID, + val toHide: @Contextual UUID +) : RedisEvent() diff --git a/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabShowRedisEvent.kt b/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabShowRedisEvent.kt new file mode 100644 index 0000000..4061208 --- /dev/null +++ b/surf-tab-api/src/main/kotlin/dev/slne/surf/tab/api/redis/TabShowRedisEvent.kt @@ -0,0 +1,12 @@ +package dev.slne.surf.tab.api.redis + +import dev.slne.surf.redis.event.RedisEvent +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +data class TabShowRedisEvent( + val player: @Contextual UUID, + val toShow: @Contextual UUID +) : RedisEvent() diff --git a/surf-tab-velocity/build.gradle.kts b/surf-tab-velocity/build.gradle.kts index b847294..ebce9fd 100644 --- a/surf-tab-velocity/build.gradle.kts +++ b/surf-tab-velocity/build.gradle.kts @@ -6,6 +6,10 @@ repositories { maven("https://repo.william278.net/releases/") } +surfVelocityApi { + withSurfRedis() +} + velocityPluginFile { main = "dev.slne.surf.tab.velocity.VelocityMain" authors = listOf("red") @@ -13,6 +17,9 @@ velocityPluginFile { pluginDependencies { register("miniplaceholders") register("luckperms") + register("surf-clan-velocity") { + optional = true + } } } @@ -20,8 +27,6 @@ dependencies { compileOnly(libs.mini.placeholders) compileOnly(libs.mini.placeholders.kotlin) compileOnly(libs.luckperms.api) - - implementation("dev.slne:surf-redis:1.0.0-20251223.105653-21") - api(project(":surf-tab-api")) + compileOnly("dev.slne.surf.clan:surf-clan-api:1.21.11-1.3.0-SNAPSHOT") } \ No newline at end of file diff --git a/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/VelocityMain.kt b/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/VelocityMain.kt index d3d41ac..324145f 100644 --- a/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/VelocityMain.kt +++ b/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/VelocityMain.kt @@ -8,7 +8,10 @@ import com.velocitypowered.api.event.proxy.ProxyShutdownEvent import com.velocitypowered.api.plugin.PluginContainer import com.velocitypowered.api.plugin.annotation.DataDirectory import com.velocitypowered.api.proxy.ProxyServer -import dev.slne.redis.RedisApi +import dev.slne.clan.api.ClanModificationListener +import dev.slne.clan.api.surfClanApi +import dev.slne.surf.redis.RedisApi +import dev.slne.surf.tab.api.redis.TabEntryUpdateRedisEvent import dev.slne.surf.tab.velocity.command.surfTabCommand import dev.slne.surf.tab.velocity.config.TablistConfigProvider import dev.slne.surf.tab.velocity.hook.LuckPermsHook @@ -33,7 +36,7 @@ class VelocityMain @Inject constructor( @Subscribe fun onInitialization(event: ProxyInitializeEvent) { instance = this - redisApi = RedisApi.create(dataPath) + redisApi = RedisApi.create() surfTabCommand() LuckPermsHook.load() @@ -43,6 +46,12 @@ class VelocityMain @Inject constructor( plugin.proxy.eventManager.register(plugin, ConnectionListener()) redisApi.freezeAndConnect() + + surfClanApi.addClanModificationListener(ClanModificationListener { + it.members.map { member -> member.uuid }.forEach { memberUuid -> + redisApi.publishEvent(TabEntryUpdateRedisEvent(memberUuid)) + } + }) } @Subscribe diff --git a/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/command/SurfTabCommand.kt b/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/command/SurfTabCommand.kt index c1fe035..68ad146 100644 --- a/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/command/SurfTabCommand.kt +++ b/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/command/SurfTabCommand.kt @@ -4,8 +4,6 @@ import dev.jorel.commandapi.kotlindsl.anyExecutor import dev.jorel.commandapi.kotlindsl.commandTree import dev.jorel.commandapi.kotlindsl.literalArgument import dev.slne.surf.surfapi.core.api.messages.adventure.sendText -import dev.slne.surf.tab.velocity.plugin -import dev.slne.surf.tab.velocity.service.tablistService import dev.slne.surf.tab.velocity.tablistConfiguration fun surfTabCommand() = commandTree("surftab") { @@ -15,10 +13,6 @@ fun surfTabCommand() = commandTree("surftab") { anyExecutor { executor, _ -> tablistConfiguration.reload() - plugin.proxy.allPlayers.forEach { - tablistService.updatePlayerInTablist(it) - } - executor.sendText { appendPrefix() success("Die Tablist wurde neu geladen.") diff --git a/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/config/TablistConfig.kt b/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/config/TablistConfig.kt index 8f6d3c2..d45a02d 100644 --- a/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/config/TablistConfig.kt +++ b/surf-tab-velocity/src/main/kotlin/dev/slne/surf/tab/velocity/config/TablistConfig.kt @@ -5,12 +5,5 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable @ConfigSerializable data class TablistConfig( val header: String = "
<#6EA6D9> CASTCRAFTER
<#6EA6D9>COMMUNITY SERVER

<#59CCF2> - <#59CCF2>