1+ package dev.slne.surf.essentials.command
2+
3+ import dev.jorel.commandapi.kotlindsl.*
4+ import dev.slne.surf.essentials.service.worldService
5+ import dev.slne.surf.essentials.util.permission.EssentialsPermissionRegistry
6+ import dev.slne.surf.essentials.util.util.isFolia
7+ import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
8+ import org.bukkit.Bukkit
9+ import org.bukkit.World
10+
11+ fun worldCommand () = commandTree(" world" ) {
12+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND )
13+
14+ literalArgument(" lock" ) {
15+ worldArgument(" world" ) {
16+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_LOCK )
17+ anyExecutor { executor, args ->
18+ val world: World by args
19+
20+ if (Bukkit .getServer().isFolia()) {
21+ executor.sendText {
22+ appendPrefix()
23+ error(" Dieser Befehl wird auf Folia-Servern nicht unterstützt." )
24+ }
25+ return @anyExecutor
26+ }
27+
28+ if (worldService.isLocked(world)) {
29+ executor.sendText {
30+ appendPrefix()
31+ error(" Die Welt ist bereits gesperrt." )
32+ }
33+ return @anyExecutor
34+ }
35+
36+ worldService.lock(world)
37+ executor.sendText {
38+ appendPrefix()
39+ success(" Die Welt " )
40+ variableValue(world.name)
41+ success(" wurde gesperrt." )
42+ }
43+ }
44+ }
45+ }
46+
47+ literalArgument(" unlock" ) {
48+ worldArgument(" world" ) {
49+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_UNLOCK )
50+ anyExecutor { executor, args ->
51+ val world: World by args
52+
53+ if (Bukkit .getServer().isFolia()) {
54+ executor.sendText {
55+ appendPrefix()
56+ error(" Dieser Befehl wird auf Folia-Servern nicht unterstützt." )
57+ }
58+ return @anyExecutor
59+ }
60+
61+ if (! worldService.isLocked(world)) {
62+ executor.sendText {
63+ appendPrefix()
64+ error(" Die Welt ist nicht gesperrt." )
65+ }
66+ return @anyExecutor
67+ }
68+
69+ worldService.unlock(world)
70+ executor.sendText {
71+ appendPrefix()
72+ success(" Die Welt " )
73+ variableValue(world.name)
74+ success(" wurde entsperrt." )
75+ }
76+ }
77+ }
78+ }
79+
80+ literalArgument(" join" ) {
81+ worldArgument(" world" ) {
82+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_JOIN )
83+ playerExecutor { player, args ->
84+ val world: World by args
85+
86+ player.sendText {
87+ appendPrefix()
88+ info(" Du wirst in die Welt " )
89+ variableValue(world.name)
90+ info(" teleportiert..." )
91+ }
92+
93+ player.teleportAsync(world.spawnLocation).thenRun {
94+ player.sendText {
95+ appendPrefix()
96+ success(" Du wurdest in die Welt " )
97+ variableValue(world.name)
98+ success(" teleportiert." )
99+ }
100+ }
101+ }
102+ }
103+ }
104+
105+ literalArgument(" create" ) {
106+ stringArgument(" name" ) {
107+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_CREATE )
108+ anyExecutor { executor, args ->
109+ val name: String by args
110+
111+ executor.sendText {
112+ appendPrefix()
113+ info(" Dieser Befehl ist zurzeit deaktiviert." )
114+ }
115+ return @anyExecutor
116+
117+ if (Bukkit .getServer().isFolia()) {
118+ executor.sendText {
119+ appendPrefix()
120+ error(" Dieser Befehl wird auf Folia-Servern nicht unterstützt." )
121+ }
122+ return @anyExecutor
123+ }
124+
125+ worldService.create(executor, name, null , null , null , null , null )
126+ }
127+ }
128+ }
129+
130+ literalArgument(" delete" ) {
131+ worldArgument(" world" ) {
132+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_DELETE )
133+ anyExecutor { executor, args ->
134+ val world: World by args
135+
136+ executor.sendText {
137+ appendPrefix()
138+ info(" Dieser Befehl ist zurzeit deaktiviert." )
139+ }
140+ return @anyExecutor
141+
142+ if (Bukkit .getServer().isFolia()) {
143+ executor.sendText {
144+ appendPrefix()
145+ error(" Dieser Befehl wird auf Folia-Servern nicht unterstützt." )
146+ }
147+ return @anyExecutor
148+ }
149+
150+ worldService.delete(executor, world)
151+ }
152+ }
153+ }
154+
155+ literalArgument(" load" ) {
156+ stringArgument(" name" ) {
157+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_LOAD )
158+ anyExecutor { executor, args ->
159+ val name: String by args
160+
161+ executor.sendText {
162+ appendPrefix()
163+ info(" Dieser Befehl ist zurzeit deaktiviert." )
164+ }
165+ return @anyExecutor
166+
167+ if (Bukkit .getServer().isFolia()) {
168+ executor.sendText {
169+ appendPrefix()
170+ error(" Dieser Befehl wird auf Folia-Servern nicht unterstützt." )
171+ }
172+ return @anyExecutor
173+ }
174+
175+
176+ worldService.load(executor, name)
177+ }
178+ }
179+ }
180+
181+ literalArgument(" unload" ) {
182+ worldArgument(" world" ) {
183+ withPermission(EssentialsPermissionRegistry .WORLD_COMMAND_UNLOAD )
184+ anyExecutor { executor, args ->
185+ val world: World by args
186+
187+ executor.sendText {
188+ appendPrefix()
189+ info(" Dieser Befehl ist zurzeit deaktiviert." )
190+ }
191+ return @anyExecutor
192+
193+ if (Bukkit .getServer().isFolia()) {
194+ executor.sendText {
195+ appendPrefix()
196+ error(" Dieser Befehl wird auf Folia-Servern nicht unterstützt." )
197+ }
198+ return @anyExecutor
199+ }
200+
201+ worldService.unload(executor, world)
202+ }
203+ }
204+ }
205+ }
0 commit comments