Skip to content

Commit

Permalink
feat: parseArmor/parseWeapon on number key
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Sep 11, 2023
1 parent d3d88f4 commit 8a1ba3b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "net.azisaba"
version = "6.6.11"
version = "6.6.12"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
Expand Down Expand Up @@ -61,6 +61,7 @@ dependencies {
implementation("com.zaxxer:HikariCP:4.0.3")
implementation("org.mariadb.jdbc:mariadb-java-client:3.0.6")
implementation("org.yaml:snakeyaml:2.0")
implementation("xyz.acrylicstyle.java-util:expression:2.0.0-SNAPSHOT")
compileOnly("net.azisaba.ballotbox:receiver:1.0.1")
compileOnly("net.azisaba.azipluginmessaging:api:4.0.3")
compileOnly("net.azisaba:RyuZUPluginChat:4.2.0")
Expand Down Expand Up @@ -135,5 +136,6 @@ tasks {
relocate("org.yaml", "com.github.mori01231.lifecore.lib.org.yaml")
relocate("org.snakeyaml", "com.github.mori01231.lifecore.lib.org.snakeyaml")
relocate("org.intellij", "com.github.mori01231.lifecore.lib.org.intellij")
relocate("xyz.acrylicstyle.util", "com.github.mori01231.lifecore.lib.xyz.acrylicstyle.util")
}
}
1 change: 1 addition & 0 deletions src/main/java/com/github/mori01231/lifecore/LifeCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class LifeCore : JavaPlugin() {
pm.registerEvents(PreventOpenMerchantMenuListener(), this)
pm.registerEvents(CancelMythicItemPlaceListener(), this)
pm.registerEvents(GameModeChangeLoggerListener(this), this)
pm.registerEvents(FixMythicItemListener, this)

// Items
pm.registerEvents(OreOnlyItemListener(), this)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.github.mori01231.lifecore.listener

import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.inventory.ClickType
import org.bukkit.event.inventory.InventoryClickEvent
import xyz.acrylicstyle.util.expression.RuntimeData
import xyz.acrylicstyle.util.expression.instruction.InstInvokeVirtual
import xyz.acrylicstyle.util.expression.instruction.InstLoadVariable
import xyz.acrylicstyle.util.expression.instruction.InstStoreString
import xyz.acrylicstyle.util.expression.instruction.InstructionSet

object FixMythicItemListener : Listener {
private val getPlayerProfileInst = InstructionSet().apply {
add(InstStoreString("plugin"))
add(InstLoadVariable())
add(InstInvokeVirtual("io.lumine.mythiccrucible.MythicCrucible", "getProfileManager", "()Lio/lumine/mythiccrucible/profiles/ProfileManager;"))
add(InstStoreString("player"))
add(InstLoadVariable())
add(InstInvokeVirtual("io.lumine.mythiccrucible.profiles.ProfileManager", "getPlayerProfile", "(Lorg/bukkit/entity/Player;)Lio/lumine/mythiccrucible/profiles/Profile;"))
}
private val parseWeapon = InstructionSet().apply {
addAll(getPlayerProfileInst)
add(InstInvokeVirtual("io.lumine.mythiccrucible.profiles.Profile", "parseWeapons", "()V"))
}
private val parseArmor = InstructionSet().apply {
addAll(getPlayerProfileInst)
add(InstInvokeVirtual("io.lumine.mythiccrucible.profiles.Profile", "parseArmor", "()V"))
}

@EventHandler
fun onClick(e: InventoryClickEvent) {
if (e.click != ClickType.NUMBER_KEY) {
return
}
val plugin = Bukkit.getPluginManager().getPlugin("MythicCrucible") ?: return
Bukkit.getScheduler().runTask(plugin, Runnable {
val runtimeData = RuntimeData.builder()
.allowPrivate(false)
.addVariable("player", e.whoClicked)
.addVariable("plugin", plugin)
.build()
parseWeapon.execute(runtimeData)
parseArmor.execute(runtimeData)
(e.whoClicked as Player).updateInventory()
})
}
}

0 comments on commit 8a1ba3b

Please sign in to comment.