Skip to content

Commit a5fd22e

Browse files
Merge pull request #14 from SLNE-Development/feat/new-lobby-selector
refactor: reorganize inventory logic and enhance navigation options
2 parents 14ccc57 + a227b74 commit a5fd22e

File tree

2 files changed

+69
-43
lines changed

2 files changed

+69
-43
lines changed

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.11-3.0.1-SNAPSHOT
4+
version=1.21.11-3.0.2-SNAPSHOT

src/main/kotlin/dev/slne/surf/lobby/inventory/impl/NavigatorInventory.kt

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,35 @@ package dev.slne.surf.lobby.inventory.impl
33
import com.github.stefvanschie.inventoryframework.pane.util.Slot
44
import dev.slne.surf.event.base.api.common.state.EventServerState
55
import dev.slne.surf.lobby.event.eventServerBridge
6+
import dev.slne.surf.lobby.lobbyConfig
67
import dev.slne.surf.lobby.plugin
78
import dev.slne.surf.lobby.utils.Locations
89
import dev.slne.surf.surfapi.bukkit.api.builder.buildLore
910
import dev.slne.surf.surfapi.bukkit.api.builder.displayName
1011
import dev.slne.surf.surfapi.bukkit.api.event.cancel
1112
import dev.slne.surf.surfapi.bukkit.api.inventory.dsl.menu
1213
import dev.slne.surf.surfapi.bukkit.api.inventory.dsl.staticPane
13-
import dev.slne.surf.surfapi.bukkit.api.surfBukkitApi
1414
import dev.slne.surf.surfapi.core.api.font.toSmallCaps
15-
import dev.slne.surf.surfapi.core.api.messages.adventure.playSound
16-
import dev.slne.surf.surfapi.core.api.messages.adventure.text
15+
import dev.slne.surf.surfapi.core.api.messages.adventure.*
1716
import org.bukkit.Sound
1817
import org.bukkit.entity.Player
1918

2019
fun navigatorInventory() = menu(text("<shift:-46><glyph:server_selector>"), 6) {
2120
setOnGlobalDrag { it.cancel() }
2221
setOnGlobalClick { it.cancel() }
2322

24-
staticPane(Slot.fromXY(5, 0), 3, 3) {
25-
fillWith(eventServerItem)
23+
staticPane(Slot.fromXY(1, 0), 3, 3) {
24+
fillWith(survivalServerItem)
2625

2726
setOnClick {
2827
val player = it.whoClicked as? Player ?: return@setOnClick
2928

3029
// if(player.isPremium()) { TODO: Premium Rang
31-
// surfBukkitApi.sendPlayerToServer(player, "event")
30+
// surfBukkitApi.sendPlayerToServer(player, "survival")
3231
// return@setOnClick
3332
// }
3433

35-
player.teleportAsync(Locations.EVENT_TELEPORT.getLocation()).thenRun {
34+
player.teleportAsync(Locations.SURVIVAL_TELEPORT.getLocation()).thenRun {
3635
player.playSound(true) {
3736
type(Sound.ENTITY_ENDERMAN_TELEPORT)
3837
pitch(2.0f)
@@ -42,18 +41,18 @@ fun navigatorInventory() = menu(text("<shift:-46><glyph:server_selector>"), 6) {
4241
}
4342
}
4443

45-
staticPane(Slot.fromXY(1, 0), 3, 3) {
46-
fillWith(survivalServerItem)
44+
staticPane(Slot.fromXY(5, 0), 3, 3) {
45+
fillWith(eventServerItem)
4746

4847
setOnClick {
4948
val player = it.whoClicked as? Player ?: return@setOnClick
5049

5150
// if(player.isPremium()) { TODO: Premium Rang
52-
// surfBukkitApi.sendPlayerToServer(player, "survival")
51+
// surfBukkitApi.sendPlayerToServer(player, "event")
5352
// return@setOnClick
5453
// }
5554

56-
player.teleportAsync(Locations.SURVIVAL_TELEPORT.getLocation()).thenRun {
55+
player.teleportAsync(Locations.EVENT_TELEPORT.getLocation()).thenRun {
5756
player.playSound(true) {
5857
type(Sound.ENTITY_ENDERMAN_TELEPORT)
5958
pitch(2.0f)
@@ -63,31 +62,76 @@ fun navigatorInventory() = menu(text("<shift:-46><glyph:server_selector>"), 6) {
6362
}
6463
}
6564

66-
staticPane(Slot.fromXY(0, 4), 2, 3) {
67-
fillWith(lobbyOneServerItem)
65+
staticPane(Slot.fromXY(0, 4), 2, 2) {
66+
fillWith(lobbySelectorItem)
6867

6968
setOnClick {
70-
val player = it.whoClicked as? Player ?: return@setOnClick
71-
surfBukkitApi.sendPlayerToServer(player, "lobby01")
69+
lobbySelectorInventory().show(it.whoClicked)
7270
}
7371
}
7472

75-
staticPane(Slot.fromXY(3, 4), 2, 3) {
76-
fillWith(lobbyTwoServerItem)
73+
staticPane(Slot.fromXY(2, 4), 2, 2) {
74+
fillWith(spawnItem)
7775

7876
setOnClick {
79-
val player = it.whoClicked as? Player ?: return@setOnClick
80-
surfBukkitApi.sendPlayerToServer(player, "lobby02")
77+
it.whoClicked.closeInventory()
78+
it.whoClicked.teleportAsync(lobbyConfig.spawnPoint.toLocation()).thenRun {
79+
it.whoClicked.sendText {
80+
appendInfoPrefix()
81+
info("Du wurdest zum Spawn teleportiert.")
82+
}
83+
}
8184
}
8285
}
83-
staticPane(Slot.fromXY(6, 4), 2, 3) {
84-
fillWith(lobbyThreeServerItem)
86+
87+
staticPane(Slot.fromXY(5, 4), 2, 2) {
88+
fillWith(rulesItem)
8589

8690
setOnClick {
87-
val player = it.whoClicked as? Player ?: return@setOnClick
88-
surfBukkitApi.sendPlayerToServer(player, "lobby03")
91+
it.whoClicked.closeInventory()
92+
it.whoClicked.sendText {
93+
appendInfoPrefix()
94+
info("Das Regelwerk findest du hier: ")
95+
append {
96+
variableValue("server.castcrafter.de/rules")
97+
clickOpensUrl("https://server.castcrafter.de/rules")
98+
}
99+
}
89100
}
90101
}
102+
103+
staticPane(Slot.fromXY(7, 4), 2, 2) {
104+
fillWith(cosmeticsItem)
105+
}
106+
}
107+
108+
fun lobbySelectorInventory() = menu(buildText { spacer("Lobby Auswahl") }, 4) {
109+
setOnGlobalDrag { it.cancel() }
110+
setOnGlobalClick { it.cancel() }
111+
}
112+
113+
private val lobbySelectorItem = plugin.getInvisibleItem().apply {
114+
displayName {
115+
primary("Lobby Auswahl")
116+
}
117+
}
118+
119+
private val spawnItem = plugin.getInvisibleItem().apply {
120+
displayName {
121+
primary("Spawn")
122+
}
123+
}
124+
125+
private val rulesItem = plugin.getInvisibleItem().apply {
126+
displayName {
127+
primary("Regelwerk")
128+
}
129+
}
130+
131+
private val cosmeticsItem = plugin.getInvisibleItem().apply {
132+
displayName {
133+
primary("???")
134+
}
91135
}
92136

93137
private val survivalServerItem = plugin.getInvisibleItem().apply {
@@ -136,22 +180,4 @@ private val eventServerItem
136180
}
137181

138182
}
139-
}
140-
141-
private val lobbyOneServerItem = plugin.getInvisibleItem().apply {
142-
displayName {
143-
primary("Lobby 1")
144-
}
145-
}
146-
147-
private val lobbyTwoServerItem = plugin.getInvisibleItem().apply {
148-
displayName {
149-
primary("Lobby 2")
150-
}
151-
}
152-
153-
private val lobbyThreeServerItem = plugin.getInvisibleItem().apply {
154-
displayName {
155-
primary("Lobby 3")
156-
}
157-
}
183+
}

0 commit comments

Comments
 (0)