Skip to content

Commit bd6e0d2

Browse files
Merge pull request #12 from SLNE-Development/feat/2-implement-dimension-function
Feat/2 implement dimension function
2 parents 8277df3 + 3e0da28 commit bd6e0d2

File tree

8 files changed

+471
-1
lines changed

8 files changed

+471
-1
lines changed

TODO

Whitespace-only changes.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
kotlin.code.style=official
22
kotlin.stdlib.default.dependency=false
33
org.gradle.parallel=true
4-
version=1.21.10-2.0.2-SNAPSHOT
4+
version=1.21.10-2.0.3-SNAPSHOT

src/main/kotlin/dev/slne/surf/essentials/PaperCommandManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ object PaperCommandManager {
7070
executeCommandAdditions()
7171
timeCommand()
7272
skinChangeCommand()
73+
worldCommand()
7374
}
7475
}

src/main/kotlin/dev/slne/surf/essentials/PaperListenerManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ object PaperListenerManager {
1010
GameModeSwitcherCorrectionListener.register()
1111
TeleportationListener.register()
1212
UnknownCommandListener.register()
13+
WorldListener.register()
1314
SpecialItemListener.register()
1415
CommandExecutionListener.register()
1516
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
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+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package dev.slne.surf.essentials.listener
2+
3+
import dev.slne.surf.essentials.service.worldService
4+
import dev.slne.surf.essentials.util.permission.EssentialsPermissionRegistry
5+
import dev.slne.surf.surfapi.bukkit.api.event.cancel
6+
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
7+
import org.bukkit.World
8+
import org.bukkit.event.EventHandler
9+
import org.bukkit.event.Listener
10+
import org.bukkit.event.player.PlayerPortalEvent
11+
12+
object WorldListener : Listener {
13+
@EventHandler
14+
fun onPortal(event: PlayerPortalEvent) {
15+
val player = event.player
16+
val world = event.to.world
17+
18+
if (worldService.isLocked(world)) {
19+
if (!player.hasPermission(EssentialsPermissionRegistry.WORLD_BYPASS)) {
20+
event.cancel()
21+
player.sendText {
22+
appendPrefix()
23+
24+
when (world.environment) {
25+
World.Environment.NETHER -> error("Der Nether ist zurzeit deaktiviert.")
26+
World.Environment.THE_END -> error("Das End ist zurzeit deaktiviert.")
27+
else -> error("Du kannst dieses Portal nicht benutzen!")
28+
}
29+
}
30+
} else {
31+
player.sendText {
32+
appendPrefix()
33+
success("Du hast die Portal-Sperre umgangen.")
34+
}
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)