Skip to content

Commit

Permalink
fix: trash bug
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Jun 11, 2024
1 parent 1649e14 commit a1a553b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 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.10.1"
version = "6.10.2"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/github/mori01231/lifecore/TrashInventory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ package com.github.mori01231.lifecore

import com.github.mori01231.lifecore.util.ItemUtil
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.Material
import org.bukkit.inventory.Inventory
import org.bukkit.inventory.InventoryHolder
import org.bukkit.inventory.ItemStack

class TrashInventory : InventoryHolder {
private val inventory = Bukkit.createInventory(this, 54, "ゴミ箱")

init {
val item = ItemUtil.createItemStack(Material.BARRIER, 1) {
companion object {
val trashItem = ItemUtil.createItemStack(Material.BARRIER, 1) {
it.itemMeta = it.itemMeta.apply {
setDisplayName("ゴミを捨てる")
setDisplayName("${ChatColor.RED}ゴミを捨てる")
}
}
inventory.setItem(53, item)
}

private val inventory = Bukkit.createInventory(this, 54, "ゴミ箱")

init {
inventory.setItem(53, trashItem)
}

override fun getInventory(): Inventory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import com.github.mori01231.lifecore.util.ItemUtil
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.Material
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.event.inventory.InventoryCloseEvent
Expand Down Expand Up @@ -68,9 +66,9 @@ class TrashListener(private val plugin: LifeCore) : Listener {
if (e.inventory.holder is TrashInventory) {
val inv = e.inventory
for (item in inv.contents) {
if (item.type != Material.AIR) {
e.player.inventory.addItem(item)
}
@Suppress("SENSELESS_COMPARISON")
if (item == null || item.type.isAir) continue
e.player.inventory.addItem(item)
}
}
}
Expand Down

0 comments on commit a1a553b

Please sign in to comment.