Skip to content

Commit

Permalink
feat: add paper support
Browse files Browse the repository at this point in the history
  • Loading branch information
StillLutto committed Jan 12, 2025
1 parent 4b9612c commit 4ad7ab7
Show file tree
Hide file tree
Showing 207 changed files with 1,606 additions and 466 deletions.
72 changes: 0 additions & 72 deletions api/build.gradle.kts

This file was deleted.

27 changes: 12 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ plugins {
kotlin("jvm") version "1.9.22"
`maven-publish`
id("com.gradleup.shadow") version "8.3.5"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" apply false
}

apply(plugin = "maven-publish")
val projectGroupId = "com.undefined"
val projectVersion = "0.0.39"
val projectVersion = "0.0.43"
val projectArtifactId = "stellar"

group = projectGroupId
Expand All @@ -21,14 +20,6 @@ val minecraftVersion = "1.20.6"
repositories {
mavenCentral()
mavenLocal()
maven {
name = "spigotmc-repo"
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
maven {
name = "minecraft-repo"
url = uri("https://libraries.minecraft.net/")
}
maven("https://repo.codemc.io/repository/maven-snapshots/")
}

Expand All @@ -43,7 +34,6 @@ publishing {
}
}
}

publications {
register<MavenPublication>("maven") {
groupId = projectGroupId
Expand All @@ -64,7 +54,11 @@ allprojects {

repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
mavenLocal()
maven {
name = "minecraft-repo"
url = uri("https://libraries.minecraft.net/")
}
}

dependencies {
Expand All @@ -77,14 +71,17 @@ allprojects {
}

dependencies {
implementation(project(":api"))
implementation(project(":spigot:api"))
implementation(project(":common"))
}

tasks {
publish {
finalizedBy(project(":paper:common").tasks["publish"])
}
withType<ShadowJar> {
archiveFileName.set("${project.name}-${project.version}.jar")
archiveClassifier.set("mapped")
archiveFileName = "${project.name}-${project.version}.jar"
archiveClassifier = "spigot"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
Expand Down
18 changes: 3 additions & 15 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,8 @@ val versionVar = version
val groupIdVar = "com.undefined"
val artifactIdVar = "stellar"

publishing {
publications {
register<MavenPublication>("maven") {
groupId = groupIdVar
artifactId = artifactIdVar
version = versionVar.toString()

from(components["java"])
}
}
}

dependencies {
compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.21.4-R0.1-SNAPSHOT")
api("com.mojang:authlib:1.5.21")
}

Expand All @@ -28,10 +16,10 @@ tasks {
kotlinOptions.jvmTarget = "1.8"
}
compileJava {
options.release.set(8)
options.release = 8
}
}

kotlin {
jvmToolchain(21)
}
}
61 changes: 61 additions & 0 deletions paper/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
plugins {
`java-library`
kotlin("jvm") version "1.9.22"
id("com.gradleup.shadow") version "8.3.5"
}

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

val versionVar = version
val groupIdVar = "com.undefined"
val artifactIdVar = "stellar"

group = groupIdVar
version = versionVar

publishing {
repositories {
maven {
name = "UndefinedCreations"
url = uri("https://repo.undefinedcreations.com/releases")
credentials(PasswordCredentials::class) {
username = System.getenv("MAVEN_NAME")
password = System.getenv("MAVEN_SECRET")
}
}
}
publications {
register<MavenPublication>("maven") {
groupId = groupIdVar
artifactId = artifactIdVar
version = versionVar.toString()

from(components["java"])
}
}
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT")
implementation(project(":paper:common"))
implementation(project(":paper:v1_17_1"))
implementation(kotlin("reflect"))
}

tasks {
shadowJar {
archiveClassifier = "paper"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileJava {
options.release = 8
}
}

kotlin {
jvmToolchain(21)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ abstract class BaseStellarCommand(val name: String, val description: String = ""
hasBeenRegistered = true
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.undefined.stellar.manager

import com.undefined.stellar.listener.StellarListener
import com.undefined.stellar.registrar.AbstractCommandRegistrar
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
import org.jetbrains.annotations.ApiStatus
import kotlin.reflect.KClass

@ApiStatus.Internal
object CommandManager {
val registrars: Map<String, KClass<out AbstractCommandRegistrar>> = mapOf(
"1.17.1" to com.undefined.stellar.v1_17_1.CommandRegistrar::class,
)

private val initializedPlugins: MutableList<JavaPlugin> = mutableListOf()
fun initialize(plugin: JavaPlugin) {
if (initializedPlugins.contains(plugin)) return
initializedPlugins.add(plugin)
Bukkit.getPluginManager().registerEvents(StellarListener, plugin)
}
}
12 changes: 12 additions & 0 deletions paper/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
java
kotlin("jvm") version "1.9.22"
id("com.gradleup.shadow") version "8.3.5"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.13" apply false
}

allprojects {
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
}
30 changes: 30 additions & 0 deletions paper/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
kotlin("jvm") version "1.9.22"
}

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

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT")
api("com.mojang:authlib:1.5.21")
api(project(":common"))
}

tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileJava {
options.release = 8
}
}

java {
disableAutoTargetJvm()
}

kotlin {
jvmToolchain(21)
}
9 changes: 3 additions & 6 deletions v1_21_3/build.gradle.kts → paper/v1_17_1/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ plugins {
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION

dependencies {
paperweight.paperDevBundle("1.21.3-R0.1-SNAPSHOT")
implementation("com.mojang:brigadier:1.2.9")
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT")
compileOnly(project(":common"))
}

Expand All @@ -16,12 +15,10 @@ tasks {
kotlinOptions.jvmTarget = "1.8"
}
compileJava {
options.release.set(8)
options.release = 8
}
paperweight {
javaLauncher.set(
project.javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(21)) }
)
javaLauncher = project.javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(17)) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.undefined.stellar.argument.LiteralStellarArgument
import com.undefined.stellar.argument.types.primitive.PhraseArgument
import com.undefined.stellar.data.suggestion.Suggestion
import net.minecraft.commands.CommandSourceStack
import org.bukkit.Bukkit
import org.bukkit.scheduler.BukkitRunnable
import java.util.concurrent.CompletableFuture

object CommandAdapter {
Expand All @@ -27,9 +29,9 @@ object CommandAdapter {
fun handleCommandFunctions(command: AbstractStellarCommand<*>, brigadierCommand: ArgumentBuilder<CommandSourceStack, *>) {
if (command.executions.isNotEmpty() || command.executions.isNotEmpty())
brigadierCommand.executes { context ->
sync {
BrigadierCommandHelper.handleExecutions(command, context)
}
object : BukkitRunnable() {
override fun run() = BrigadierCommandHelper.handleExecutions(command, context)
}.runTask(CommandRegistrar.plugin)
1
}
brigadierCommand.requires { source ->
Expand Down Expand Up @@ -79,7 +81,7 @@ object CommandAdapter {

private fun handleGreedyStringWordFunctions(argument: PhraseArgument, argumentBuilder: RequiredArgumentBuilder<CommandSourceStack, *>) {
argumentBuilder.executes { context ->
sync {
Bukkit.getScheduler().runTask(CommandRegistrar.plugin, Runnable {
val greedyContext = CommandContextAdapter.getGreedyCommandContext(context)

for (i in greedyContext.arguments.indices) {
Expand All @@ -88,7 +90,7 @@ object CommandAdapter {
if (i == greedyContext.arguments.lastIndex)
for (execution in word.executions) execution(greedyContext)
}
}
})
Command.SINGLE_SUCCESS
}

Expand Down
3 changes: 1 addition & 2 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ val artifactIdVar = "stellar"

dependencies {
compileOnly("org.spigotmc:spigot-api:1.21.4-R0.1-SNAPSHOT")

implementation(project(":api"))
implementation(project(":spigot:api"))
}

tasks {
Expand Down
Loading

0 comments on commit 4ad7ab7

Please sign in to comment.