Skip to content

Commit 67d1d6d

Browse files
committed
✨ feat(protection): add world retrieval to RegionInfo and display in view-util
- implement world retrieval in RegionInfo using Bukkit - display world name in view-util with fallback to "Unknown"
1 parent 89cadda commit 67d1d6d

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/main/kotlin/dev/slne/surf/protect/paper/menu/util/view-util.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ fun createRegionItem(protection: RegionInfo, showMoreInfo: Boolean = true) =
120120
white("Id: ".toSmallCaps())
121121
variableValue(protection.region.id.toSmallCaps())
122122
}
123+
line {
124+
appendBlob()
125+
appendSpace()
126+
white("Welt: ".toSmallCaps())
127+
variableValue(protection.world?.key()?.asMinimalString()?.toSmallCaps() ?: "Unbekannt".toSmallCaps())
128+
}
123129
line {
124130
appendBlob()
125131
appendSpace()

src/main/kotlin/dev/slne/surf/protect/paper/region/info/RegionInfo.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import dev.slne.surf.protect.paper.region.flags.ProtectionFlagsRegistry
88
import dev.slne.surf.protect.paper.util.fixedVolume
99
import dev.slne.surf.protect.paper.util.getRegionManagerOrNull
1010
import dev.slne.surf.protect.paper.util.toLocalPlayer
11+
import org.bukkit.Bukkit
12+
import org.bukkit.World
1113

1214

1315
data class RegionInfo(val region: ProtectedRegion) {
@@ -21,6 +23,7 @@ data class RegionInfo(val region: ProtectedRegion) {
2123
val regionManager get() = region.getRegionManagerOrNull()
2224
val owners get() = region.owners.uniqueIds.mapTo(mutableObjectListOf()) { it.toLocalPlayer() }
2325
val members get() = region.members.uniqueIds.mapTo(mutableObjectListOf()) { it.toLocalPlayer() }
26+
val world: World? get() = regionManager?.name?.let { Bukkit.getWorld(it) }
2427

2528
init {
2629
val flagInfo = region.getFlag(ProtectionFlagsRegistry.SURF_PROTECT_FLAG)

0 commit comments

Comments
 (0)