diff --git a/src/main/kotlin/com/skillw/asahi/internal/namespacing/prefix/lang/Lang.kt b/src/main/kotlin/com/skillw/asahi/internal/namespacing/prefix/lang/Lang.kt index eb55af27..92008e7e 100644 --- a/src/main/kotlin/com/skillw/asahi/internal/namespacing/prefix/lang/Lang.kt +++ b/src/main/kotlin/com/skillw/asahi/internal/namespacing/prefix/lang/Lang.kt @@ -20,6 +20,11 @@ private fun `null`() = prefixParser { result { null } } +@AsahiPrefix(["null-str"], "lang") +private fun nullStr() = prefixParser { + result { "null" } +} + @AsahiPrefix(["pass"], "lang") private fun pass() = prefixParser { result { "" } diff --git a/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/HologramBuilder.kt b/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/HologramBuilder.kt index afc8f5f1..47213068 100644 --- a/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/HologramBuilder.kt +++ b/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/HologramBuilder.kt @@ -107,7 +107,7 @@ class HologramBuilder(private val location: Location) { * @return 构建好的Hologram */ fun build(): IHologram { - val hologram = hologramManager.createHologram(location.clone(), content) + val hologram = hologramManager.createHologram(location.clone(), content, viewers) if (stay != -1L) { each?.also { vector -> var count = 0 diff --git a/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/IHologram.kt b/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/IHologram.kt index 947e9afe..e422f88c 100644 --- a/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/IHologram.kt +++ b/src/main/kotlin/com/skillw/pouvoir/api/feature/hologram/IHologram.kt @@ -2,20 +2,10 @@ package com.skillw.pouvoir.api.feature.hologram import com.skillw.pouvoir.api.plugin.map.component.Keyable import org.bukkit.Location -import org.bukkit.entity.Player /** 全息接口 */ interface IHologram : Keyable { - /** 坐标 */ - var location: Location - - /** 内容 */ - val content: List - - /** 可看到的玩家 */ - val viewers: MutableSet - /** * 传送 * diff --git a/src/main/kotlin/com/skillw/pouvoir/api/manager/sub/HologramManager.kt b/src/main/kotlin/com/skillw/pouvoir/api/manager/sub/HologramManager.kt index a143d254..8fd42667 100644 --- a/src/main/kotlin/com/skillw/pouvoir/api/manager/sub/HologramManager.kt +++ b/src/main/kotlin/com/skillw/pouvoir/api/manager/sub/HologramManager.kt @@ -3,6 +3,7 @@ package com.skillw.pouvoir.api.manager.sub import com.skillw.pouvoir.api.feature.hologram.IHologram import com.skillw.pouvoir.api.manager.Manager import org.bukkit.Location +import org.bukkit.entity.Player /** * HologramManager @@ -17,5 +18,5 @@ abstract class HologramManager : Manager { * @param content * @return */ - abstract fun createHologram(location: Location, content: List): IHologram + abstract fun createHologram(location: Location, content: List, players: Set): IHologram } \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/pouvoir/internal/feature/hologram/Hologram.kt b/src/main/kotlin/com/skillw/pouvoir/internal/feature/hologram/Hologram.kt index f4f15318..8bade5c5 100644 --- a/src/main/kotlin/com/skillw/pouvoir/internal/feature/hologram/Hologram.kt +++ b/src/main/kotlin/com/skillw/pouvoir/internal/feature/hologram/Hologram.kt @@ -5,28 +5,28 @@ import org.bukkit.Location import org.bukkit.entity.Player import java.util.concurrent.ConcurrentHashMap -class Hologram(override var location: Location, override val content: List) : IHologram { +class Hologram private constructor(var location: Location, val content: List) : IHologram { override val key = (location.toString().hashCode() + content.hashCode()).toString() - override val viewers = ConcurrentHashSet() + val viewers = ConcurrentHashSet() - constructor(location: Location, content: List, vararg viewers: Player) : this(location, content) { - this.viewers.addAll(viewers) + + private val lines = ConcurrentHashMap() + + init { content.forEachIndexed { index, line -> lines[index] = HologramLine(location.clone().add(0.0, (((content.size - 1) - index) * 0.3), 0.0), line, this.viewers) } } - constructor(location: Location, content: List, viewers: Set) : this(location, content) { + constructor(location: Location, content: List, vararg viewers: Player) : this(location, content) { this.viewers.addAll(viewers) - content.forEachIndexed { index, line -> - lines[index] = - HologramLine(location.clone().add(0.0, (((content.size - 1) - index) * 0.3), 0.0), line, this.viewers) - } } - private val lines = ConcurrentHashMap() + constructor(location: Location, content: List, viewers: Set) : this(location, content) { + this.viewers.addAll(viewers) + } override fun teleport(location: Location) { this.location = location diff --git a/src/main/kotlin/com/skillw/pouvoir/internal/manager/HologramManagerImpl.kt b/src/main/kotlin/com/skillw/pouvoir/internal/manager/HologramManagerImpl.kt index 2eaa2ead..71f76f5d 100644 --- a/src/main/kotlin/com/skillw/pouvoir/internal/manager/HologramManagerImpl.kt +++ b/src/main/kotlin/com/skillw/pouvoir/internal/manager/HologramManagerImpl.kt @@ -5,13 +5,14 @@ import com.skillw.pouvoir.api.feature.hologram.IHologram import com.skillw.pouvoir.api.manager.sub.HologramManager import com.skillw.pouvoir.internal.feature.hologram.Hologram import org.bukkit.Location +import org.bukkit.entity.Player internal object HologramManagerImpl : HologramManager() { override val key = "HologramManagerImpl" override val priority = 3 override val subPouvoir = Pouvoir - override fun createHologram(location: Location, content: List): IHologram { - return Hologram(location, content) + override fun createHologram(location: Location, content: List, players: Set): IHologram { + return Hologram(location, content, players) } } \ No newline at end of file