Skip to content

Commit

Permalink
1.19.2 support with fixed commands
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Nov 2, 2022
1 parent 645947e commit 1648aaa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ dependencies {
implementation("de.tr7zw:item-nbt-api-plugin:2.10.0")
implementation("io.papermc:paperlib:1.0.7")

//compile "org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT"
//compileOnly("io.papermc.paper:paper-api:1.17-R0.1-SNAPSHOT")
compileOnly("com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.8.2")
compileOnly("com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0")

Expand All @@ -63,6 +61,7 @@ dependencies {

compileOnly("org.apache.httpcomponents:fluent-hc:4.5.13")
compileOnly("org.apache.commons:commons-math3:3.6.1")
compileOnly("commons-lang:commons-lang:2.6")
}

tasks {
Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/com/perkelle/dev/envoys/Envoys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import com.perkelle.dev.envoys.utils.async
import com.perkelle.dev.envoys.utils.gui.GUIListener
import com.perkelle.dev.envoys.utils.sync
import org.bstats.bukkit.Metrics

import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.plugin.Plugin
import org.bukkit.plugin.java.JavaPlugin
import java.lang.reflect.Method
import java.util.*
import javax.script.ScriptEngineManager

Expand All @@ -35,6 +35,8 @@ fun verboseLog(str: String) {

class Envoys(val pl: Plugin) {

private var syncCommandsMethod: Method? = null

companion object {
lateinit var instance: Envoys

Expand Down Expand Up @@ -148,6 +150,13 @@ class Envoys(val pl: Plugin) {

// Register commands
EnvoysCommand().register()
try {
syncCommandsMethod = Bukkit.getServer().javaClass.getDeclaredMethod("syncCommands")
syncCommandsMethod?.isAccessible = true
syncCommandsMethod?.invoke(Bukkit.getServer())
} catch (e: Exception) {
verboseLog("Completely failed to register commands")
}
verboseLog("Registered commands")

val refillManager = RefillManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ enum class ServerVersion {
V1_15,
V1_16,
V1_17,
V1_18,
V1_19,
;

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class InventorySnapshotV_1_12 : IInventorySnapshot {
val inv = Bukkit.createInventory(null, chest.inventory.size)

val contents = chest.inventory.contents
.filterNotNull()
?.filterNotNull()!!
.filterNot { it.type == Material.AIR }

for ((i, item) in contents.withIndex()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class OpenListener: Listener {
val chestInv = IInventorySnapshot.instance.getInventorySnapshot(chest)

chest.inventory.clear()
p.inventory.addItem(*chestInv.contents.filterNotNull().filterNot { it.type == Material.AIR }.toTypedArray())
p.inventory.addItem(*chestInv.contents?.filterNotNull()!!.filterNot { it.type == Material.AIR }.toTypedArray())
.values.forEach { item -> p.world.dropItem(p.location, item) }
}

Expand Down

0 comments on commit 1648aaa

Please sign in to comment.