1.3.0
Изменения: - Переход к JSON-конфигу - Теперь при ламинировании карты отображается, кто её заламинировал и его uuid - Теперь у переименованных предметов нет курсивного шрифта
This commit is contained in:
parent
a26006c548
commit
f5c466cf70
6 changed files with 59 additions and 494 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package dev.marrow.zsign
|
||||
|
||||
import com.github.shynixn.mccoroutine.bukkit.SuspendingJavaPlugin
|
||||
import dev.marrow.zsign.config.ConfigIO
|
||||
import dev.marrow.zsign.listeners.AnvilUseListener
|
||||
import dev.marrow.zsign.listeners.MapLaminationListener
|
||||
import dev.marrow.zsign.utils.CommonUtils.gson
|
||||
|
|
@ -23,6 +24,8 @@ class Core : SuspendingJavaPlugin() {
|
|||
instance = this
|
||||
console = logger
|
||||
|
||||
ConfigIO.readConfig()
|
||||
|
||||
// Только наш cartography-слушатель
|
||||
server.pluginManager.registerEvents(MapLaminationListener(this), this)
|
||||
server.pluginManager.registerEvents(AnvilUseListener(this), this)
|
||||
|
|
|
|||
41
src/main/kotlin/dev/marrow/zsign/config/ConfigIO.kt
Normal file
41
src/main/kotlin/dev/marrow/zsign/config/ConfigIO.kt
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,7 @@
|
|||
package dev.marrow.zsign.listeners
|
||||
|
||||
import dev.marrow.zsign.Core
|
||||
import dev.marrow.zsign.config.ConfigIO
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.NamedTextColor
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
|
|
@ -42,9 +43,8 @@ class AnvilUseListener(private val plugin: Core) : Listener {
|
|||
private val plain = PlainTextComponentSerializer.plainText()
|
||||
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")
|
||||
val banSymbols = ConfigIO.instance.filters.banSymbols
|
||||
val streamerWords = ConfigIO.instance.filters.streamerWords
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
fun onPrepareAnvil(e: PrepareAnvilEvent) {
|
||||
|
|
@ -84,7 +84,7 @@ class AnvilUseListener(private val plugin: Core) : Listener {
|
|||
}
|
||||
|
||||
if (newName != null) {
|
||||
meta.displayName(Component.text(newName))
|
||||
meta.displayName(Component.text(newName).decoration(TextDecoration.ITALIC, false))
|
||||
}
|
||||
|
||||
if (secondItem != null) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import dev.marrow.zsign.Core
|
|||
import io.papermc.paper.event.player.CartographyItemEvent
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.NamedTextColor
|
||||
import net.kyori.adventure.text.format.TextDecoration
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.entity.Player
|
||||
|
|
@ -36,10 +38,13 @@ class MapLaminationListener(private val plugin: Core) : Listener {
|
|||
return mm.persistentDataContainer.has(laminatedKey, PersistentDataType.BYTE)
|
||||
}
|
||||
|
||||
private fun markLaminated(copy: ItemStack): ItemStack = copy.apply {
|
||||
private fun markLaminated(copy: ItemStack, player: Player): ItemStack = copy.apply {
|
||||
val mm = itemMeta as MapMeta
|
||||
mm.persistentDataContainer.set(laminatedKey, PersistentDataType.BYTE, 1.toByte())
|
||||
mm.lore(listOf(Component.text("Заламинирована")))
|
||||
mm.lore(listOf(
|
||||
Component.text("Заламинировано игроком ${player.name}").color(NamedTextColor.YELLOW).decoration(TextDecoration.ITALIC, false),
|
||||
Component.text("(${player.uniqueId})").color(NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, false),
|
||||
))
|
||||
itemMeta = mm
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +105,8 @@ class MapLaminationListener(private val plugin: Core) : Listener {
|
|||
val top = inv.getItem(TOP_SLOT)
|
||||
val cursor = inv.viewers.firstOrNull()?.itemOnCursor
|
||||
if (top.isRedPane() || (top.isAir() && cursor.isRedPane())) {
|
||||
val out = markLaminated(base.clone())
|
||||
val player = inv.viewers.firstOrNull() as? Player ?: return
|
||||
val out = markLaminated(base.clone(), player)
|
||||
out.amount = 1
|
||||
e.result = out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue