Skip to content

Commit

Permalink
Add publishing and clean up gradle builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Redned235 committed Jun 30, 2024
1 parent 38ae967 commit 035f222
Show file tree
Hide file tree
Showing 9 changed files with 827 additions and 20 deletions.
14 changes: 14 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: battleplugins
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build

on:
push:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Build with Gradle
run: ./gradlew build
- name: Publish to Maven Repository
if: ${{ success() && github.repository == 'BattlePlugins/BattleArena' && github.ref_name == 'rewrite' }}
run: ./gradlew publish
env:
BUILD_NUMBER: ${{ github.run_number }}
ORG_GRADLE_PROJECT_battlepluginsUsername: ${{ vars.DEPLOY_USER }}
ORG_GRADLE_PROJECT_battlepluginsPassword: ${{ secrets.DEPLOY_SECRET }}
- name: Publish to Modrinth
if: ${{ success() && github.repository == 'BattlePlugins/BattleArena' && github.ref_name == 'rewrite' }}
env:
CHANGELOG: ${{ github.event.head_commit.message }}
BUILD_NUMBER: ${{ github.run_number }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew modrinth
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = "org.battleplugins"
version = "4.0.0-SNAPSHOT"
allprojects {
apply {
plugin("java")
plugin("java-library")
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
group = "org.battleplugins"
version = "4.0.0-SNAPSHOT"

allprojects {
repositories {
maven("https://repo.papermc.io/repository/maven-public")
}

apply {
plugin("java")
plugin("java-library")
plugin("com.github.johnrengelman.shadow")
java {
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
paper-api = "1.20.4-R0.1-SNAPSHOT"
paper-api = "1.19.4-R0.1-SNAPSHOT"
worldedit = "7.2.9"

[libraries]
Expand Down
83 changes: 78 additions & 5 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import xyz.jpenilla.runpaper.task.RunServer

plugins {
id("maven-publish")
id("xyz.jpenilla.run-paper") version "2.3.0"
id("com.modrinth.minotaur") version "2.+"
}

val supportedVersions = listOf("1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6", "1.21")

repositories {
maven("https://maven.enginehub.org/repo/")
}
Expand All @@ -14,9 +20,14 @@ dependencies {
tasks {
runServer {
minecraftVersion("1.20.6")

// Set Java 21 (1.20.6 requires Java 21)
javaLauncher = project.javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
}
}

shadowJar {
jar {
from("src/main/java/resources") {
include("*")
}
Expand All @@ -25,11 +36,73 @@ tasks {
archiveClassifier.set("")
}

jar {
archiveClassifier.set("unshaded")
javadoc {
(options as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
}

named("build") {
dependsOn(shadowJar)
processResources {
filesMatching("plugin.yml") {
expand("version" to rootProject.version)
}
}
}

publishing {
val isSnapshot = "SNAPSHOT" in version.toString()

repositories {
maven {
name = "battleplugins"
url = uri("https://repo.battleplugins.org/${if (isSnapshot) "snapshots" else "releases"}")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}

publications {
create<MavenPublication>("mavenJava") {
artifactId = "arena"

from(components["java"])
pom {
packaging = "jar"
url.set("https://github.com/BattlePlugins/BattleArena")

scm {
connection.set("scm:git:git://github.com/BattlePlugins/BattleArena.git")
developerConnection.set("scm:git:ssh://github.com/BattlePlugins/BattleArena.git")
url.set("https://github.com/BattlePlugins/BattleArena");
}

licenses {
license {
name.set("GNU General Public License v3.0")
url.set("https://www.gnu.org/licenses/gpl-3.0.html")
}
}

developers {
developer {
name.set("BattlePlugins Team")
organization.set("BattlePlugins")
organizationUrl.set("https://github.com/BattlePlugins")
}
}
}
}
}
}
}

modrinth {
val snapshot = "SNAPSHOT" in rootProject.version.toString()

token.set(System.getenv("MODRINTH_TOKEN") ?: "")
projectId.set("battlearena")
versionNumber.set(rootProject.version as String + if (snapshot) "-" + System.getenv("BUILD_NUMBER") else "")
versionType.set(if (snapshot) "beta" else "release")
changelog.set(System.getenv("CHANGELOG") ?: "")
uploadFile.set(tasks.jar)
gameVersions.set(supportedVersions)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.event.ClickEvent;
import org.apache.commons.lang3.StringUtils;
import org.battleplugins.arena.Arena;
import org.battleplugins.arena.BattleArena;
import org.battleplugins.arena.competition.CompetitionType;
Expand All @@ -13,6 +14,7 @@
import org.battleplugins.arena.util.OptionSelector;
import org.battleplugins.arena.util.UnitUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.time.Duration;
Expand Down Expand Up @@ -181,4 +183,8 @@ public void reload(Player player) {
long end = System.currentTimeMillis();
Messages.RELOAD_COMPLETE.send(player, UnitUtil.toUnitString(player, end - start, TimeUnit.MILLISECONDS));
}

public void sendHeader(CommandSender sender) {
Messages.HEADER.sendCentered(sender, "BattleArena");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.battleplugins.arena.ArenaPlayer;
import org.battleplugins.arena.event.action.EventAction;
import org.bukkit.potion.PotionEffect;

import java.util.List;
import java.util.Map;

public class ClearEffectsAction extends EventAction {
Expand All @@ -13,6 +15,8 @@ public ClearEffectsAction(Map<String, String> params) {

@Override
public void call(ArenaPlayer arenaPlayer) {
arenaPlayer.getPlayer().clearActivePotionEffects();
for (PotionEffect effect : List.copyOf(arenaPlayer.getPlayer().getActivePotionEffects())) {
arenaPlayer.getPlayer().removePotionEffect(effect.getType());
}
}
}
5 changes: 3 additions & 2 deletions plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: BattleArena
version: 4.0.0
main: org.battleplugins.arena.BattleArena
version: ${version}
description: A complete match and event framework for Minecraft. Supports creating modes through config files, or fully custom modes through plugins.
author: BattlePlugins
website: https://battleplugins.org
api-version: 1.20
api-version: 1.19
softdepend: [WorldEdit]
commands:
battlearena:
Expand Down

0 comments on commit 035f222

Please sign in to comment.