-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
722 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Publish commons | ||
|
||
on: | ||
release: | ||
branches: [ master ] | ||
types: [ published ] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
environment: deployment | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
cache: 'gradle' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Publish with Gradle | ||
run: ./gradlew publish -PmavenUsername=${{ secrets.REPO_USERNAME }} -PmavenPassword=${{ secrets.REPO_SECRET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import org.gradle.api.tasks.compile.JavaCompile | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
plugins { | ||
`java-library` | ||
} | ||
|
||
tasks { | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import org.gradle.api.artifacts.repositories.PasswordCredentials | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.authentication.http.BasicAuthentication | ||
import org.gradle.kotlin.dsl.create | ||
import org.gradle.kotlin.dsl.credentials | ||
import org.gradle.kotlin.dsl.get | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
group = project.group | ||
version = project.version | ||
|
||
java { | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
url = uri("https://repo.bx-team.space/releases/") | ||
|
||
if (project.version.toString().endsWith("-SNAPSHOT")) { | ||
url = uri("https://repo.bx-team.space/snapshots/") | ||
} | ||
credentials(PasswordCredentials::class) | ||
authentication { | ||
create<BasicAuthentication>("basic") | ||
} | ||
} | ||
} | ||
publications { | ||
create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
`java-library` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://repo.papermc.io/repository/maven-public/") | ||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,11 @@ | ||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
group = project.group | ||
version = project.version | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://repo.papermc.io/repository/maven-public/") | ||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") | ||
`commons-java` | ||
`commons-publish` | ||
`commons-repositories` | ||
} | ||
|
||
dependencies { | ||
api(project(":commons-shared")) | ||
api("net.kyori:adventure-text-minimessage:4.17.0") | ||
api("net.kyori:adventure-text-serializer-legacy:4.17.0") | ||
} | ||
|
||
tasks { | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
} | ||
withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
url = uri("https://repo.bx-team.space/releases/") | ||
|
||
if (project.version.toString().endsWith("-SNAPSHOT")) { | ||
url = uri("https://repo.bx-team.space/snapshots/") | ||
} | ||
credentials(PasswordCredentials::class) | ||
authentication { | ||
create<BasicAuthentication>("basic") | ||
} | ||
} | ||
} | ||
publications { | ||
create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,13 @@ | ||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
group = project.group | ||
version = project.version | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://repo.papermc.io/repository/maven-public/") | ||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") | ||
`commons-java` | ||
`commons-publish` | ||
`commons-repositories` | ||
} | ||
|
||
dependencies { | ||
api(project(":commons-shared")) | ||
api("org.jetbrains:annotations:26.0.1") | ||
|
||
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT") | ||
testImplementation("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT") | ||
} | ||
|
||
tasks { | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
withSourcesJar() | ||
} | ||
withType<JavaCompile> { | ||
options.encoding = "UTF-8" | ||
} | ||
withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
url = uri("https://repo.bx-team.space/releases/") | ||
|
||
if (project.version.toString().endsWith("-SNAPSHOT")) { | ||
url = uri("https://repo.bx-team.space/snapshots/") | ||
} | ||
credentials(PasswordCredentials::class) | ||
authentication { | ||
create<BasicAuthentication>("basic") | ||
} | ||
} | ||
} | ||
publications { | ||
create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
commons-bukkit/src/main/java/space/bxteam/commons/bukkit/scheduler/BukkitScheduledTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package space.bxteam.commons.bukkit.scheduler; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.scheduler.BukkitTask; | ||
import space.bxteam.commons.scheduler.Task; | ||
|
||
public class BukkitScheduledTask implements Task { | ||
BukkitTask task; | ||
boolean isRepeating; | ||
|
||
public BukkitScheduledTask(final BukkitTask task) { | ||
this.task = task; | ||
this.isRepeating = false; | ||
} | ||
|
||
public BukkitScheduledTask(final BukkitTask task, boolean isRepeating) { | ||
this.task = task; | ||
this.isRepeating = isRepeating; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
task.cancel(); | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return task.isCancelled(); | ||
} | ||
|
||
@Override | ||
public boolean isCurrentlyRunning() { | ||
// Fuck Bukkit, you don't have any other way | ||
return Bukkit.getServer().getScheduler().isCurrentlyRunning(this.task.getTaskId()); | ||
} | ||
|
||
@Override | ||
public boolean isRepeatingTask() { | ||
return isRepeating; | ||
} | ||
|
||
@Override | ||
public Plugin getPlugin() { | ||
return task.getOwner(); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
commons-bukkit/src/main/java/space/bxteam/commons/bukkit/scheduler/BukkitScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package space.bxteam.commons.bukkit.scheduler; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.plugin.Plugin; | ||
import space.bxteam.commons.scheduler.Scheduler; | ||
import space.bxteam.commons.scheduler.Task; | ||
|
||
public class BukkitScheduler implements Scheduler { | ||
final Plugin plugin; | ||
|
||
public BukkitScheduler(Plugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean isGlobalThread() { | ||
return Bukkit.getServer().isPrimaryThread(); | ||
} | ||
|
||
@Override | ||
public boolean isEntityThread(Entity entity) { | ||
return Bukkit.getServer().isPrimaryThread(); | ||
} | ||
|
||
@Override | ||
public boolean isRegionThread(Location location) { | ||
return Bukkit.getServer().isPrimaryThread(); | ||
} | ||
|
||
@Override | ||
public Task runTask(Runnable runnable) { | ||
return new BukkitScheduledTask(Bukkit.getScheduler().runTask(plugin, runnable)); | ||
} | ||
|
||
@Override | ||
public Task runTaskLater(Runnable runnable, long delay) { | ||
return new BukkitScheduledTask(Bukkit.getScheduler().runTaskLater(plugin, runnable, delay)); | ||
} | ||
|
||
@Override | ||
public Task runTaskTimer(Runnable runnable, long delay, long period) { | ||
return new BukkitScheduledTask(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period)); | ||
} | ||
|
||
@Override | ||
public Task runTaskAsynchronously(Runnable runnable) { | ||
return new BukkitScheduledTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable)); | ||
} | ||
|
||
@Override | ||
public Task runTaskLaterAsynchronously(Runnable runnable, long delay) { | ||
return new BukkitScheduledTask(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, runnable, delay)); | ||
} | ||
|
||
@Override | ||
public Task runTaskTimerAsynchronously(Runnable runnable, long delay, long period) { | ||
return new BukkitScheduledTask(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, runnable, delay, period)); | ||
} | ||
|
||
@Override | ||
public void execute(Runnable runnable) { | ||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable); | ||
} | ||
|
||
@Override | ||
public void cancelTasks() { | ||
Bukkit.getScheduler().cancelTasks(plugin); | ||
} | ||
|
||
@Override | ||
public void cancelTasks(Plugin plugin) { | ||
Bukkit.getScheduler().cancelTasks(plugin); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
`commons-java` | ||
`commons-publish` | ||
`commons-repositories` | ||
} | ||
|
||
dependencies { | ||
api(project(":commons-shared")) | ||
api("org.jetbrains:annotations:26.0.1") | ||
|
||
compileOnlyApi("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT") | ||
} |
Oops, something went wrong.