@@ -6,7 +6,11 @@ import dev.slne.surf.essentials.command.argument.world.worldsArgument
66import dev.slne.surf.essentials.service.worldService
77import dev.slne.surf.essentials.util.permission.EssentialsPermissionRegistry
88import dev.slne.surf.essentials.util.util.isFolia
9+ import dev.slne.surf.surfapi.core.api.font.toSmallCaps
10+ import dev.slne.surf.surfapi.core.api.messages.adventure.buildText
911import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
12+ import dev.slne.surf.surfapi.core.api.messages.pagination.Pagination
13+ import net.kyori.adventure.text.format.TextDecoration
1014import org.bukkit.Bukkit
1115import org.bukkit.World
1216
@@ -180,4 +184,59 @@ fun worldCommand() = commandTree("world") {
180184 }
181185 }
182186 }
183- }
187+
188+ literalArgument(" list" ) {
189+ anyExecutor { executor, _ ->
190+ val worlds = Bukkit .getWorlds()
191+
192+ if (worlds.isEmpty()) {
193+ executor.sendText {
194+ appendPrefix()
195+ error(" Es sind keine Welten geladen." )
196+ }
197+ return @anyExecutor
198+ }
199+
200+ val worldData = worlds.map {
201+ WorldData (it.name, worldService.isLocked(it))
202+ }
203+
204+ val pagination = Pagination <WorldData > {
205+ title {
206+ primary(" Geladene Welten" .toSmallCaps(), TextDecoration .BOLD )
207+ }
208+
209+ rowRenderer { row, index ->
210+ listOf (
211+ buildText {
212+ darkSpacer(" >" )
213+ appendSpace()
214+ variableValue(row.worldName)
215+ appendSpace()
216+ spacer(" (" )
217+ if (row.isLocked) {
218+ error(" Gesperrt" .toSmallCaps())
219+ } else {
220+ success(" Entsperrt" .toSmallCaps())
221+ }
222+ spacer(" )" )
223+ }
224+ )
225+ }
226+ }
227+
228+ executor.sendText {
229+ appendPrefix()
230+ info(" Es sind insgesamt " )
231+ variableValue(worlds.size.toString())
232+ info(" Welt(en) geladen:" )
233+ append(pagination.renderComponent(worldData))
234+ }
235+ }
236+ }
237+ }
238+
239+ private data class WorldData (
240+ val worldName : String ,
241+ val isLocked : Boolean
242+ )
0 commit comments