Skip to content

Commit

Permalink
feat(plugin): 1.20+ support
Browse files Browse the repository at this point in the history
1. shade the entire `net.kyori` package, not just `net.kyori.adventure`
2. lib updates:
  - de.tr7zw:item-nbt-api-plugin `2.12.1 -> 2.13.1`
  - net.kyori:adventure-api `4.14.0 -> 4.17.0`
  - net.kyori:adventure-text-minimessage `4.14.0 -> 4.17.0`
  - net.kyori:adventure-platform-bukkit `4.3.1 -> 4.3.3`
  - dev.triumphteam:triumph-gui `3.1.7 -> 3.1.10`
  • Loading branch information
iGabyTM committed Jul 28, 2024
1 parent c8a03c4 commit 6f6c443
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ dependencies {
compileOnly('com.github.MilkBowl:VaultAPI:1.7') { transitive false }

// NBT
compileOnly 'de.tr7zw:item-nbt-api-plugin:2.12.1'
compileOnly 'de.tr7zw:item-nbt-api-plugin:2.13.1'

// Adventure
def adventureVersion = '4.14.0'
def adventurePlatformVersion = '4.3.1'
def adventureVersion = '4.17.0'
def adventurePlatformVersion = '4.3.3'
implementation "net.kyori:adventure-api:$adventureVersion"
implementation "net.kyori:adventure-platform-bukkit:$adventurePlatformVersion"
implementation "net.kyori:adventure-text-minimessage:$adventureVersion"

// GUis and commands
implementation 'dev.triumphteam:triumph-gui:3.1.7'
implementation 'dev.triumphteam:triumph-gui:3.1.10'
implementation 'me.mattstudios.utils:matt-framework:1.4.6'

// Heads
compileOnly('com.arcaniax:HeadDatabase-API:1.3.1') { transitive false }

// WorldGuard compatibility
['base', 'v6', 'v7'].forEach {implementation project(':plugin:compatibility:worldguard:' + it) }
['base', 'v6', 'v7'].forEach { implementation project(':plugin:compatibility:worldguard:' + it) }

// bStats
implementation 'org.bstats:bstats-bukkit:3.0.0'
Expand Down Expand Up @@ -92,7 +92,7 @@ shadowJar {
[
'me.gabytm.util.actions': 'actions',
'dev.triumphteam.gui' : 'gui',
'net.kyori.adventure' : 'adventure',
'net.kyori' : 'kyori',
'me.mattstudios.mf' : 'commands',
'sh.okx.timeapi' : 'timeapi',
'org.bstats' : 'bstats',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.gabytm.minecraft.arcanevouchers

import me.gabytm.minecraft.arcanevouchers.functions.info
import org.bukkit.Bukkit
import org.bukkit.Server
import java.util.regex.Pattern
Expand Down Expand Up @@ -72,17 +73,19 @@ object ServerVersion {
}

private fun getCurrentVersionAsString(): String {
val matcher = Pattern.compile("\\d+\\.\\d+(?:\\.\\d+)?").matcher(getMinecraftVersion())
return if (matcher.find()) matcher.group() else "unknown"
val minecraftVersion = getMinecraftVersion()
val matcher = Pattern.compile("\\d+\\.\\d+(?:\\.\\d+)?").matcher(minecraftVersion)
return if (matcher.find()) matcher.group() else minecraftVersion
}

private fun getMinecraftVersion(): String {
try {
// Paper method
val method = Server::class.java.getDeclaredMethod("getMinecraftVersion")
return method.invoke(Bukkit.getServer()) as String
} catch (ignored: NoSuchMethodError) {
return Bukkit.getServer().javaClass.`package`.name.substringAfterLast('.');
} catch (ignored: NoSuchMethodException) {
// Version is formatted as 'minor.major.patch-R0.1-SNAPSHOT'
return Bukkit.getServer().bukkitVersion.split('-')[0]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ItemCreator(plugin: ArcaneVouchers) {
val item = this
.name(config.getString("name")?.mini(true) ?: Component.empty())
.lore(config.getStringList("lore").map { it.mini(true) })
.flags(*flags)
.enchant(enchants, true)
.unbreakable(config.getBoolean("unbreakable"))
.apply {
Expand All @@ -84,7 +83,9 @@ class ItemCreator(plugin: ArcaneVouchers) {
}

config.getString("color")?.toColor()?.let { color(it) }
}.build()
}
.flags(*flags)
.build()

if (isVoucher) {
// Get the JSON of this voucher
Expand Down

0 comments on commit 6f6c443

Please sign in to comment.