diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml deleted file mode 100644 index cd843ae..0000000 --- a/.github/workflows/alpha.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Release & Publish Packages (Alpha Branch) - -on: - push: - branches: - - alpha - -jobs: - publish: - # Only run this workflow for pushes to the default repository - if: github.repository_owner == 'Lyttle-Development' - runs-on: ubuntu-22.04 - env: - GPR_USER: ${{ secrets.GPR_USER }} # GitHub Packages username - GPR_API_KEY: ${{ secrets.GPR_API_KEY }} # GitHub Packages token - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - # Checks out your code so the workflow can access it - - - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@v3 - # Ensures the checked-in Gradle wrapper is valid and secure - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: 21 - check-latest: true - # Sets up Java 21 for building and publishing - - - name: Publish to GitHub Packages (Maven) - env: - USERNAME: ${{ secrets.GPR_USER }} # GitHub Packages username - TOKEN: ${{ secrets.GPR_API_KEY }} # GitHub Packages token - CHANNEL: 'Alpha' # Github Release channel - run: | - # Publishes artifacts to GitHub Packages (Maven) - ./gradlew publish --stacktrace - - - name: Publish to Hangar (Upload) - env: - HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} # Hangar API token (secret) - CHANNEL: 'Alpha' # Hangar release channel - run: | - # Uploads the plugin to Hangar platform - ./gradlew publishPluginPublicationToHangar --stacktrace - - - name: Publish to Modrinth (Upload) - env: - MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_API_TOKEN }} # Modrinth API token (secret) - CHANNEL: 'Alpha' # Modrinth release channel - run: | - # Publishes to Modrinth (ensure your build.gradle is configured for this) - ./gradlew modrinth --stacktrace - # If your Modrinth Gradle task is named differently, update this accordingly \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 5510631..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Release & Publish Packages (Main Branch) - -on: - push: - branches: - - main - -jobs: - publish: - # Only run this workflow for pushes to the default repository - if: github.repository_owner == 'Lyttle-Development' - runs-on: ubuntu-22.04 - env: - GPR_USER: ${{ secrets.GPR_USER }} # GitHub Packages username - GPR_API_KEY: ${{ secrets.GPR_API_KEY }} # GitHub Packages token - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - # Checks out your code so the workflow can access it - - - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@v3 - # Ensures the checked-in Gradle wrapper is valid and secure - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: 21 - check-latest: true - # Sets up Java 21 for building and publishing - - - name: Publish to GitHub Packages (Maven) - env: - USERNAME: ${{ secrets.GPR_USER }} # GitHub Packages username - TOKEN: ${{ secrets.GPR_API_KEY }} # GitHub Packages token - CHANNEL: 'Release' # Github Release channel - run: | - # Publishes artifacts to GitHub Packages (Maven) - ./gradlew publish --stacktrace - - - name: Publish to Hangar (Upload) - env: - HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} # Hangar API token (secret) - CHANNEL: 'Release' # Hangar release channel - run: | - # Uploads the plugin to Hangar platform - ./gradlew publishPluginPublicationToHangar --stacktrace - - - name: Publish to Modrinth (Upload) - env: - MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_API_TOKEN }} # Modrinth API token (secret) - CHANNEL: 'Release' # Modrinth release channel - run: | - # Publishes to Modrinth (ensure your build.gradle is configured for this) - ./gradlew modrinth --stacktrace - # If your Modrinth Gradle task is named differently, update this accordingly diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml new file mode 100644 index 0000000..f593b5f --- /dev/null +++ b/.github/workflows/release-and-publish.yml @@ -0,0 +1,144 @@ +name: Release & Publish Packages (Release & Alpha Branches) + +on: + push: + branches: + - main + - alpha + +jobs: + publish-github: + if: github.repository_owner == 'Lyttle-Development' + runs-on: ubuntu-22.04 + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_API_KEY: ${{ secrets.GPR_API_KEY }} + CHANNEL: ${{ github.ref_name == 'main' && 'Release' || 'Alpha' }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Checks out your code so the workflow can access it + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v3 + # Ensures the checked-in Gradle wrapper is valid and secure + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 21 + check-latest: true + # Sets up Java 21 for building and publishing + + - name: Build project + run: | + ./gradlew build shadowJar --stacktrace + + - name: Upload JAR artifact + uses: actions/upload-artifact@v4 + with: + name: plugin-jar + path: build/libs/*.jar + + - name: Extract plugin version from gradle.properties + id: get_version + run: | + VERSION=$(grep '^pluginVersion=' gradle.properties | cut -d'=' -f2) + if [ "${{ env.CHANNEL }}" = "Release" ]; then + TAG="v$VERSION" + else + TAG="v${VERSION}-ALPHA.${GITHUB_RUN_NUMBER}" + fi + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Create git tag for release + id: tag_release + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a ${{ steps.get_version.outputs.tag }} -m "Release ${{ steps.get_version.outputs.tag }}" + git push origin ${{ steps.get_version.outputs.tag }} + + - name: Create GitHub Release and Upload JAR + id: create_release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.get_version.outputs.tag }} + files: build/libs/*.jar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-hangar: + if: github.repository_owner == 'Lyttle-Development' + runs-on: ubuntu-22.04 + env: + HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} + CHANNEL: ${{ github.ref_name == 'main' && 'Release' || 'Alpha' }} + GPR_USER: ${{ secrets.GPR_USER }} + GPR_API_KEY: ${{ secrets.GPR_API_KEY }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Checks out your code so the workflow can access it + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v3 + # Ensures the checked-in Gradle wrapper is valid and secure + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 21 + check-latest: true + # Sets up Java 21 for building and publishing + + - name: Build project + run: | + ./gradlew build shadowJar --stacktrace + + - name: Publish to Hangar + env: + HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} + CHANNEL: ${{ github.ref_name == 'main' && 'Release' || 'Alpha' }} + run: | + # Uploads the plugin to Hangar platform + ./gradlew publishPluginPublicationToHangar --stacktrace + + publish-modrinth: + if: github.repository_owner == 'Lyttle-Development' + runs-on: ubuntu-22.04 + env: + MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_API_TOKEN }} + CHANNEL: ${{ github.ref_name == 'main' && 'Release' || 'Alpha' }} + GPR_USER: ${{ secrets.GPR_USER }} + GPR_API_KEY: ${{ secrets.GPR_API_KEY }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Checks out your code so the workflow can access it + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v3 + # Ensures the checked-in Gradle wrapper is valid and secure + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 21 + check-latest: true + # Sets up Java 21 for building and publishing + + - name: Build project + run: | + ./gradlew build shadowJar --stacktrace + + - name: Publish to Modrinth + env: + MODRINTH_API_TOKEN: ${{ secrets.MODRINTH_API_TOKEN }} + CHANNEL: ${{ github.ref_name == 'main' && 'Release' || 'Alpha' }} + run: | + # Publishes to Modrinth (ensure your build.gradle is configured for this) + ./gradlew modrinth --stacktrace diff --git a/build.gradle.kts b/build.gradle.kts index c3da72d..c94f23e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,10 +31,11 @@ dependencies { compileOnly("io.papermc.paper:paper-api:" + (property("paperVersion") as String) + "-R0.1-SNAPSHOT") compileOnly("net.luckperms:api:5.4") compileOnly("org.xerial:sqlite-jdbc:3.46.0.0") - implementation("com.lyttledev:lyttleutils:1.1.7") + implementation("com.lyttledev:lyttleutils:1.2.0") } group = "com.lyttledev" +version = (property("pluginVersion") as String) description = "LyttleAdmin" java.sourceCompatibility = JavaVersion.VERSION_21 diff --git a/gradle.properties b/gradle.properties index def8e31..14ad705 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # The current version of the plugin. -pluginVersion=1.2.6 +pluginVersion=1.2.7 # Specify the platform versions for Paper, Velocity, and Waterfall. # Hangar also allows version ranges (such as 1.19-1.20.2) and wildcards (such as 1.20.x). diff --git a/src/main/java/com/lyttldev/lyttleadmin/commands/StaffCommand.java b/src/main/java/com/lyttldev/lyttleadmin/commands/StaffCommand.java index e4a6b3c..20a279b 100644 --- a/src/main/java/com/lyttldev/lyttleadmin/commands/StaffCommand.java +++ b/src/main/java/com/lyttldev/lyttleadmin/commands/StaffCommand.java @@ -8,6 +8,7 @@ import com.lyttldev.lyttleadmin.utils.LocationUtil; import com.lyttldev.lyttleadmin.utils.RolesConfigLoader; import com.lyttledev.lyttleutils.types.Message.Replacements; +import com.lyttledev.lyttleutils.utils.gameplay.ActionBar; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.minimessage.MiniMessage; @@ -345,10 +346,10 @@ private void runActions(Player player, Replacements replacements, boolean enable if (actionBar != null && !actionBar.isEmpty()) { // Set action bar message Component message = plugin.message.getMessageRaw(actionBar); - setActionBar(true, player, message); + ActionBar.setActionBar(true, player, message); } else { // If no action bar message is set, clear the action bar - setActionBar(false, player, Component.empty()); + ActionBar.setActionBar(false, player, Component.empty()); } RoleChange remove = action.getRemove(); @@ -392,23 +393,6 @@ private void runActions(Player player, Replacements replacements, boolean enable } } - HashMap activeActionBars = new HashMap<>(); - private void setActionBar(boolean active, Player player, Component message) { - BukkitTask oldActionBarTask = activeActionBars.get(player); - // If there is an old action bar task, cancel it before overwriting it - if (oldActionBarTask != null) { - oldActionBarTask.cancel(); - activeActionBars.remove(player); - } - - if (active) { - BukkitTask newActionBarTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> { - player.sendActionBar(message); - }, 0, 40); - activeActionBars.put(player, newActionBarTask); - } - } - private void setGameMode(Player player, GameMode gameMode) { if (player != null && gameMode != null) { player.setGameMode(gameMode); diff --git a/src/main/java/com/lyttldev/lyttleadmin/types/Configs.java b/src/main/java/com/lyttldev/lyttleadmin/types/Configs.java index 6526bde..2e30024 100644 --- a/src/main/java/com/lyttldev/lyttleadmin/types/Configs.java +++ b/src/main/java/com/lyttldev/lyttleadmin/types/Configs.java @@ -1,30 +1,30 @@ package com.lyttldev.lyttleadmin.types; import com.lyttldev.lyttleadmin.LyttleAdmin; -import com.lyttledev.lyttleutils.types.Config; +import com.lyttledev.lyttleutils.types.YamlConfig; public class Configs { private final LyttleAdmin plugin; // Configs - public Config general; - public Config messages; + public YamlConfig general; + public YamlConfig messages; // Default configs - public Config defaultGeneral; - public Config defaultMessages; + public YamlConfig defaultGeneral; + public YamlConfig defaultMessages; public Configs(LyttleAdmin plugin) { this.plugin = plugin; // Configs - general = new Config(plugin, "config.yml"); - messages = new Config(plugin, "messages.yml"); + general = new YamlConfig(plugin, "config.yml"); + messages = new YamlConfig(plugin, "messages.yml"); // Default configs - defaultGeneral = new Config(plugin, "#defaults/config.yml"); - defaultMessages = new Config(plugin, "#defaults/messages.yml"); + defaultGeneral = new YamlConfig(plugin, "#defaults/config.yml"); + defaultMessages = new YamlConfig(plugin, "#defaults/messages.yml"); } public void reload() {