CLEANUP
This commit is contained in:
parent
e0789c4a9d
commit
a26006c548
1 changed files with 3 additions and 9 deletions
|
|
@ -15,16 +15,10 @@ import org.bukkit.event.inventory.ClickType
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.event.inventory.InventoryType
|
import org.bukkit.event.inventory.InventoryType
|
||||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.inventory.Inventory
|
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.Repairable
|
import org.bukkit.inventory.meta.Repairable
|
||||||
|
|
||||||
class AnvilUseListener(private val plugin: Core) : Listener {
|
class AnvilUseListener(private val plugin: Core) : Listener {
|
||||||
|
|
||||||
private val config get() = plugin.config
|
|
||||||
private val banSymbols get() = config.getStringList("ban-symbols")
|
|
||||||
private val streamerWords get() = config.getStringList("streamer-words")
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val SECOND_SLOT = 1
|
private const val SECOND_SLOT = 1
|
||||||
private val colorMap = mapOf(
|
private val colorMap = mapOf(
|
||||||
|
|
@ -48,6 +42,9 @@ class AnvilUseListener(private val plugin: Core) : Listener {
|
||||||
private val plain = PlainTextComponentSerializer.plainText()
|
private val plain = PlainTextComponentSerializer.plainText()
|
||||||
private fun ItemStack?.isAir(): Boolean = this == null || type == Material.AIR
|
private fun ItemStack?.isAir(): Boolean = this == null || type == Material.AIR
|
||||||
}
|
}
|
||||||
|
private val config get() = plugin.config
|
||||||
|
private val banSymbols get() = config.getStringList("ban-symbols")
|
||||||
|
private val streamerWords get() = config.getStringList("streamer-words")
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
fun onPrepareAnvil(e: PrepareAnvilEvent) {
|
fun onPrepareAnvil(e: PrepareAnvilEvent) {
|
||||||
|
|
@ -120,14 +117,12 @@ class AnvilUseListener(private val plugin: Core) : Listener {
|
||||||
inv.repairCost = 1
|
inv.repairCost = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.itemMeta = meta
|
result.itemMeta = meta
|
||||||
|
|
||||||
if (result.isSimilar(firstItem)) {
|
if (result.isSimilar(firstItem)) {
|
||||||
e.result = null
|
e.result = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.result = result
|
e.result = result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +131,6 @@ class AnvilUseListener(private val plugin: Core) : Listener {
|
||||||
val inv = e.inventory
|
val inv = e.inventory
|
||||||
if (inv.type != InventoryType.ANVIL) return
|
if (inv.type != InventoryType.ANVIL) return
|
||||||
val p = e.whoClicked as? Player ?: return
|
val p = e.whoClicked as? Player ?: return
|
||||||
|
|
||||||
val firstItem = inv.first()
|
val firstItem = inv.first()
|
||||||
if (firstItem.isAir()) return
|
if (firstItem.isAir()) return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue