Skip to content

Commit

Permalink
Supports Oraxen 2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Nov 3, 2024
1 parent 5d81471 commit 3c7693d
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 61 deletions.
2 changes: 1 addition & 1 deletion BANNER.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ This plugin utilizes a boss bar, but you can still use the first boss bar.
No

### Version
Plugin: 1.17-1.21.3
Plugin: 1.18.2-1.21.3
Fabric mod: server 1.21.3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This project implements a server-side HUD.
- Supports animation.

### Platform
- Bukkit(including Folia) 1.17-1.21.3
- Bukkit(including Folia) 1.18.2-1.21.3
- Velocity 3.3-3.4
- Fabric server 1.21.3

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kr.toxicity.hud.api.bukkit.pack;

import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

public interface BukkitResourcePackHandler {
void handle(@NotNull Plugin plugin);
}
2 changes: 0 additions & 2 deletions bootstrap/bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ repositories {
maven("https://repo.alessiodp.com/releases/") //Parties
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") //PlaceholderAPI
maven("https://mvn.lumine.io/repository/maven/") //MythicMobs
maven("https://repo.oraxen.com/releases") //Oraxen
}

dependencies {
compileOnly("io.th0rgal:oraxen:1.183.0")
compileOnly("io.lumine:Mythic-Dist:5.7.2")
compileOnly("io.lumine:MythicLib-dist:1.7.1-SNAPSHOT")
compileOnly("net.Indyuce:MMOCore-API:1.13.1-SNAPSHOT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
override fun core(): BetterHud = core
override fun version(): String = description.version

@Volatile
var skipInitialReload = false

override fun onEnable() {
val pluginManager = Bukkit.getPluginManager()
nms = when (MinecraftVersion.current) {
Expand All @@ -177,8 +180,8 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
MinecraftVersion.version1_19_2, MinecraftVersion.version1_19_3 -> kr.toxicity.hud.nms.v1_19_R2.NMSImpl()
MinecraftVersion.version1_19, MinecraftVersion.version1_19_1 -> kr.toxicity.hud.nms.v1_19_R1.NMSImpl()
MinecraftVersion.version1_18_2 -> kr.toxicity.hud.nms.v1_18_R2.NMSImpl()
MinecraftVersion.version1_18, MinecraftVersion.version1_18_1 -> kr.toxicity.hud.nms.v1_18_R1.NMSImpl()
MinecraftVersion.version1_17, MinecraftVersion.version1_17_1 -> kr.toxicity.hud.nms.v1_17_R1.NMSImpl()
//MinecraftVersion.version1_18, MinecraftVersion.version1_18_1 -> kr.toxicity.hud.nms.v1_18_R1.NMSImpl()
//MinecraftVersion.version1_17, MinecraftVersion.version1_17_1 -> kr.toxicity.hud.nms.v1_17_R1.NMSImpl()
else -> {
warn("Unsupported minecraft version: ${MinecraftVersion.current}")
pluginManager.disablePlugin(this)
Expand Down Expand Up @@ -268,7 +271,7 @@ class BukkitBootstrapImpl : BukkitBootstrap, JavaPlugin() {
nms.registerCommand(CommandManager.module)
core.start()
scheduler.asyncTask {
core.reload()
if (!skipInitialReload) core.reload()
log.info(
"Minecraft version: ${MinecraftVersion.current}, NMS version: ${nms.version}",
"Plugin enabled."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
package kr.toxicity.hud.bootstrap.bukkit.compatibility.oraxen

import io.th0rgal.oraxen.api.events.OraxenPackGeneratedEvent
import io.th0rgal.oraxen.utils.VirtualFile
import kr.toxicity.hud.api.listener.HudListener
import kr.toxicity.hud.api.placeholder.HudPlaceholder
import kr.toxicity.hud.api.plugin.ReloadState.Failure
import kr.toxicity.hud.api.plugin.ReloadState.OnReload
import kr.toxicity.hud.api.plugin.ReloadState.Success
import kr.toxicity.hud.api.trigger.HudTrigger
import kr.toxicity.hud.api.update.UpdateEvent
import kr.toxicity.hud.api.yaml.YamlObject
import kr.toxicity.hud.bootstrap.bukkit.BukkitBootstrapImpl
import kr.toxicity.hud.bootstrap.bukkit.compatibility.Compatibility
import kr.toxicity.hud.bootstrap.bukkit.util.registerListener
import kr.toxicity.hud.manager.ConfigManagerImpl
import kr.toxicity.hud.util.PLUGIN
import kr.toxicity.hud.util.BOOTSTRAP
import kr.toxicity.hud.util.info
import kr.toxicity.hud.util.warn
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import java.io.ByteArrayInputStream
import org.bukkit.Bukkit
import org.bukkit.plugin.Plugin

class OraxenCompatibility : Compatibility {
override val website: String = "https://www.spigotmc.org/resources/72448/"
Expand All @@ -34,36 +27,24 @@ class OraxenCompatibility : Compatibility {
get() = mapOf()

override fun start() {
registerListener(object : Listener {
@EventHandler
fun generate(event: OraxenPackGeneratedEvent) {
when (val state = PLUGIN.reload()) {
is Success -> {
val output = event.output
state.resourcePack.forEach {
output.add(
VirtualFile(
it.key.substringBeforeLast('/'),
it.key.substringAfterLast('/'),
ByteArrayInputStream(it.value).buffered()
)
)
}
info("Successfully merged with Oraxen: (${state.time} ms)")
}
is Failure -> {
val reason = mutableListOf(
"Fail to merge the resource pack with Oraxen.",
"Reason: ${state.throwable.message ?: state.throwable.javaClass.simpleName}"
)
if (ConfigManagerImpl.debug) {
reason.add(state.throwable.stackTraceToString())
}
warn(*reason.toTypedArray())
}
is OnReload -> warn("This plugin is still on reload!")
}
(BOOTSTRAP as BukkitBootstrapImpl).skipInitialReload = true
val version = (Bukkit.getPluginManager().getPlugin("Oraxen") ?: return)
.description
.version
when (version
.substringBefore('.')
.toInt()
) {
1 -> {
(BOOTSTRAP as BukkitBootstrapImpl).skipInitialReload = true
OraxenR1Handler().handle(BOOTSTRAP as Plugin)
}
})
2 -> {
(BOOTSTRAP as BukkitBootstrapImpl).skipInitialReload = true
OraxenR2Handler().handle(BOOTSTRAP as Plugin)
}
else -> warn("Unknown Oraxen Version.")
}
info("Successfully handle Oraxen $version.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ data class MinecraftVersion(
val version1_19_1 = MinecraftVersion(1, 19, 1)
val version1_19 = MinecraftVersion(1, 19, 0)
val version1_18_2 = MinecraftVersion(1, 18, 2)
val version1_18_1 = MinecraftVersion(1, 18, 1)
val version1_18 = MinecraftVersion(1, 18, 0)
val version1_17_1 = MinecraftVersion(1, 17, 1)
val version1_17 = MinecraftVersion(1, 17, 0)
//val version1_18_1 = MinecraftVersion(1, 18, 1)
//val version1_18 = MinecraftVersion(1, 18, 0)
//val version1_17_1 = MinecraftVersion(1, 17, 1)
//val version1_17 = MinecraftVersion(1, 17, 0)

private val comparator = Comparator.comparing { v: MinecraftVersion ->
v.first
Expand Down
22 changes: 16 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ val betterCommand = "1.0"

val supportedMinecraftVersions = listOf(
//1.17
"1.17",
"1.17.1",
//"1.17",
//"1.17.1",
//1.18
"1.18",
"1.18.1",
//"1.18",
//"1.18.1",
"1.18.2",
//1.19
"1.19",
Expand Down Expand Up @@ -68,8 +68,8 @@ val supportedVelocityVersions = listOf(
)

val legacyNmsVersion = listOf(
"v1_17_R1",
"v1_18_R1",
//"v1_17_R1",
//"v1_18_R1",
"v1_18_R2",
"v1_19_R1",
"v1_19_R2",
Expand Down Expand Up @@ -256,6 +256,7 @@ fun Project.api() = dependency(api)

val dist = project("dist").adventure().library().api()
val scheduler = project("scheduler")
val oraxen = project("oraxen")
val bedrock = project("bedrock")

allNmsVersion.forEach {
Expand All @@ -266,6 +267,9 @@ allNmsVersion.forEach {
scheduler.project("standard").adventure().bukkit().api()
scheduler.project("folia").folia().api()

oraxen.project("1.0").bukkit().api()
oraxen.project("2.0").bukkit().api()

dist.dependency(allNmsVersion)

val bukkitBootstrap = project("bootstrap:bukkit")
Expand All @@ -275,6 +279,7 @@ val bukkitBootstrap = project("bootstrap:bukkit")
.dependency(dist)
.bukkitAudience()
.dependency(scheduler.subprojects)
.dependency(oraxen.subprojects)
.dependency(bedrock.subprojects)
.dependency(allNmsVersion)

Expand Down Expand Up @@ -351,6 +356,11 @@ val pluginJar by tasks.creating(Jar::class.java) {
t.archiveFile
}))
}
oraxen.subprojects.forEach {
from(zipTree(it.tasks.jar.map { t ->
t.archiveFile
}))
}
allNmsVersion.forEach {
from(zipTree(it.tasks.named("reobfJar").map { t ->
(t as RemapJar).outputJar
Expand Down
15 changes: 15 additions & 0 deletions changelog/1.9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# BetterHud 1.9

## Notice
- Drop support about 1.17, 1.17.1, 1.18.1

## Updates

- If your server has Polymer, BetterHud's resource pack will automatically be merged. (Fabric)
- If your server has Oraxen, BetterHud's resource pack will automatically be merged. (Bukkit)

**Caution**:
- Please set 'pack-type' in config.yml to 'none' if you want to use Polymer or Oraxen.
- If your server uses Polymer, you have to use '/polymer generate-pack' instead of '/hud reload'.
- If your server uses Oraxen, you have to use '/oraxen reload all' instead of '/hud reload'.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx16384M -Dfile.encoding=UTF-8
org.gradle.caching=true
org.gradle.parallel=true

paperVersion=1.17-1.21.3
paperVersion=1.18.2-1.21.3
velocityVersion=3.4

minecraft_version=1.21.3
Expand Down
7 changes: 7 additions & 0 deletions oraxen/1.0/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repositories {
maven("https://repo.oraxen.com/releases") //Oraxen
}

dependencies {
compileOnly("io.th0rgal:oraxen:1.183.0")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package kr.toxicity.hud.bootstrap.bukkit.compatibility.oraxen

import io.th0rgal.oraxen.api.events.OraxenPackGeneratedEvent
import io.th0rgal.oraxen.utils.VirtualFile
import kr.toxicity.hud.api.BetterHudAPI
import kr.toxicity.hud.api.bukkit.pack.BukkitResourcePackHandler
import kr.toxicity.hud.api.plugin.ReloadState.*
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.plugin.Plugin
import java.io.ByteArrayInputStream

class OraxenR1Handler : BukkitResourcePackHandler {
override fun handle(plugin: Plugin) {
val api = BetterHudAPI.inst()
val logger = BetterHudAPI.inst().bootstrap().logger()
Bukkit.getPluginManager().registerEvents(object : Listener {
@EventHandler
fun generate(event: OraxenPackGeneratedEvent) {
when (val state = api.reload()) {
is Success -> {
val output = event.output
state.resourcePack.forEach {
output.add(
VirtualFile(
it.key.substringBeforeLast('/'),
it.key.substringAfterLast('/'),
ByteArrayInputStream(it.value).buffered()
)
)
}
logger.info("Successfully merged with Oraxen: (${state.time} ms)")
}
is Failure -> {
logger.warn(
"Fail to merge the resource pack with Oraxen.",
"Reason: ${state.throwable.message ?: state.throwable.javaClass.simpleName}"
)
}
is OnReload -> logger.warn("This plugin is still on reload!")
}
}
}, plugin)
}
}
8 changes: 8 additions & 0 deletions oraxen/2.0/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repositories {
maven("https://repo.oraxen.com/snapshots") //Oraxen
}

dependencies {
compileOnly("io.th0rgal:oraxen:2.0-SNAPSHOT")
compileOnly("team.unnamed:creative-api:1.7.3")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package kr.toxicity.hud.bootstrap.bukkit.compatibility.oraxen

import io.th0rgal.oraxen.api.events.resourcepack.OraxenPrePackGenerateEvent
import kr.toxicity.hud.api.BetterHudAPI
import kr.toxicity.hud.api.bukkit.pack.BukkitResourcePackHandler
import kr.toxicity.hud.api.plugin.ReloadState.*
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.plugin.Plugin
import team.unnamed.creative.ResourcePack

class OraxenR2Handler : BukkitResourcePackHandler {
override fun handle(plugin: Plugin) {
val api = BetterHudAPI.inst()
val logger = BetterHudAPI.inst().bootstrap().logger()
Bukkit.getPluginManager().registerEvents(object : Listener {
@EventHandler
fun generate(event: OraxenPrePackGenerateEvent) {
when (val state = api.reload()) {
is Success -> {
val pack = ResourcePack.resourcePack()
state.resourcePack.forEach {
pack.unknownFile(it.key) { stream ->
stream.write(it.value)
}
}
event.addResourcePack(pack)
logger.info("Successfully merged with Oraxen: (${state.time} ms)")
}
is Failure -> {
logger.warn(
"Fail to merge the resource pack with Oraxen.",
"Reason: ${state.throwable.message ?: state.throwable.javaClass.simpleName}"
)
}
is OnReload -> logger.warn("This plugin is still on reload!")
}
}
}, plugin)
}
}
7 changes: 5 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ include(
"api:fabric-api",

"dist",
"nms:v1_17_R1",
"nms:v1_18_R1",
//"nms:v1_17_R1",
//"nms:v1_18_R1",
"nms:v1_18_R2",
"nms:v1_19_R1",
"nms:v1_19_R2",
Expand All @@ -37,6 +37,9 @@ include(
"scheduler:standard",
"scheduler:folia",

"oraxen:1.0",
"oraxen:2.0",

"bedrock:geyser",
"bedrock:floodgate",

Expand Down

0 comments on commit 3c7693d

Please sign in to comment.