Skip to content

Commit

Permalink
feat(version-support): add 1.18.1 and 1.18.2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
StillLutto committed Dec 21, 2024
1 parent 06720a9 commit 05dc7b7
Show file tree
Hide file tree
Showing 43 changed files with 1,738 additions and 40 deletions.
2 changes: 2 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ version = versionVar
dependencies {
compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT")
implementation(project(":common"))
implementation(project(":v1_18_1"))
implementation(project(":v1_18_2"))
implementation(project(":v1_19_2"))
implementation(project(":v1_19_3"))
implementation(project(":v1_19_4"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StellarCommand(name: String, permissions: List<String> = listOf()) : Abstr
StellarCommands.commands.add(this)
CommandManager.initialize(plugin)
val registrar = CommandManager.registrars[NMSVersion.version] ?: throw UnsupportedVersionException()
registrar.register(this)
registrar.register(this, plugin)
for (execution in this.registerExecutions) execution()
Bukkit.getPluginManager().callEvent(StellarCommandRegisterEvent(this))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
object CommandManager {
val registrars: Map<String, AbstractCommandRegistrar> = mapOf(
"1.18" to com.undefined.stellar.v1_18_1.CommandRegistrar,
"1.18.1" to com.undefined.stellar.v1_18_1.CommandRegistrar,
"1.18.2" to com.undefined.stellar.v1_18_2.CommandRegistrar,
"1.19" to com.undefined.stellar.v1_19_2.CommandRegistrar,
"1.19.1" to com.undefined.stellar.v1_19_2.CommandRegistrar,
"1.19.2" to com.undefined.stellar.v1_19_2.CommandRegistrar,
"1.19.3" to com.undefined.stellar.v1_19_3.CommandRegistrar,
"1.19.4" to com.undefined.stellar.v1_19_4.CommandRegistrar,
Expand Down
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ allprojects {
apply(plugin = "java-library")
apply(plugin = "maven-publish")

version = projectVersion

repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
Expand Down Expand Up @@ -77,6 +79,9 @@ allprojects {
dependencies {
implementation(project(":api"))
implementation(project(":common"))
implementation(project(":v1_18_1:", "reobf"))
implementation(project(":v1_18_2:", "reobf"))
implementation(project(":v1_19_2:", "reobf"))
implementation(project(":v1_19_3:", "reobf"))
implementation(project(":v1_19_4:", "reobf"))
implementation(project(":v1_20", "reobf"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package com.undefined.stellar.registrar

import com.undefined.stellar.AbstractStellarCommand
import org.bukkit.command.CommandSender
import org.bukkit.plugin.java.JavaPlugin

interface AbstractCommandRegistrar {
fun register(command: AbstractStellarCommand<*>)
fun register(command: AbstractStellarCommand<*>, plugin: JavaPlugin)
fun handleCommandFailure(sender: CommandSender, input: String): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import org.jetbrains.annotations.ApiStatus
@ApiStatus.Internal
object NMSVersion {
val version by lazy { Bukkit.getBukkitVersion().split("-")[0] }
}
}
8 changes: 5 additions & 3 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ val groupIdVar = "com.undefined"
val artifactIdVar = "stellar"

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

implementation(project(":api"))
implementation(project(":common"))
implementation(project(":v1_18_1:", "reobf"))
implementation(project(":v1_18_2:", "reobf"))
implementation(project(":v1_19_2:", "reobf"))
implementation(project(":v1_19_3:", "reobf"))
implementation(project(":v1_19_4:", "reobf"))
Expand All @@ -25,7 +27,7 @@ dependencies {
implementation(project(":v1_21_1:", "reobf"))
implementation(project(":v1_21_3:", "reobf"))
implementation(project(":v1_21_4:", "reobf"))
implementation(project(":v1_20"))
implementation(project(":v1_18_1"))
}

tasks {
Expand All @@ -42,7 +44,7 @@ tasks {
}

runServer {
minecraftVersion("1.20")
minecraftVersion("1.18.1")
jvmArgs("-Xmx2G")
}
}
Expand Down
9 changes: 5 additions & 4 deletions server/src/main/kotlin/com/undefined/stellar/Main.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.undefined.stellar

import net.kyori.adventure.text.format.Style
import org.bukkit.Color
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
Expand All @@ -9,11 +11,10 @@ import java.util.function.Predicate
class Main : JavaPlugin() {

override fun onEnable() {
StellarCommand("isItem")
.addItemArgument(name = "item")
StellarCommand("test")
.addColorArgument(name = "item")
.addExecution<Player> {
val predicate = getArgument<Predicate<ItemStack>>("item")
sender.inventory.setItem()
sender.sendMessage(getArgument<Style>("item").toString())
}
.register(this)
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Stellar
version: '${version}'
main: com.undefined.stellar.Main
api-version: '1.20'
api-version: '1.18'
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = "stellar"
include("server", "api", "common", "v1_19_2", "v1_19_3", "v1_19_4", "v1_20", "v1_20_1", "v1_20_2", "v1_20_4", "v1_20_6", "v1_21", "v1_21_1", "v1_21_3", "v1_21_4")
include("server", "api", "common", "v1_18_1", "v1_18_2", "v1_19_2", "v1_19_3", "v1_19_4", "v1_20", "v1_20_1", "v1_20_2", "v1_20_4", "v1_20_6", "v1_21", "v1_21_1", "v1_21_3", "v1_21_4")
26 changes: 26 additions & 0 deletions v1_18_1/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
kotlin("jvm") version "1.9.22"
id("io.papermc.paperweight.userdev") version "1.7.1"
}

paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION

dependencies {
paperweight.paperDevBundle("1.18.1-R0.1-SNAPSHOT")
// pluginRemapper("net.fabricmc:tiny-remapper:0.10.3:fat")
compileOnly(project(":common"))
}

tasks {
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
}

java {
disableAutoTargetJvm()
}

kotlin {
jvmToolchain(17)
}
Loading

0 comments on commit 05dc7b7

Please sign in to comment.