1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package cat.freya.khs.inv
import cat.freya.khs.Khs
import cat.freya.khs.config.ItemConfig
import cat.freya.khs.game.Game
import cat.freya.khs.player.Inventory
import cat.freya.khs.player.Player
const val DEBUG_TITLE = "Teleport"
val BECOME_HIDER = ItemConfig("&6Become a &lHider", "LEATHER_CHESTPLATE")
val BECOME_SEEKER = ItemConfig("&cBecome a &lSEEKER", "GOLDEN_CHESTPLATE")
val BECOME_SPECTATOR = ItemConfig("&8Become a &lSPECTATOR", "IRON_CHESTPLATE")
val DIE_IN_GAME = ItemConfig("&cDie in game", "SKELETON_SKULL")
val REVEAL_DISGUISE = ItemConfig("&cReveal disguise", "BARRIER")
fun becomeHider(plugin: Khs, player: Player) {
plugin.game.setTeam(player.uuid, Game.Team.HIDER)
plugin.game.loadHider(player)
if (plugin.game.status == Game.Status.SEEKING) plugin.game.giveHiderItems(player)
}
fun becomeSeeker(plugin: Khs, player: Player) {
plugin.game.setTeam(player.uuid, Game.Team.SEEKER)
plugin.game.loadSeeker(player)
if (plugin.game.status == Game.Status.SEEKING) plugin.game.giveSeekerItems(player)
}
fun becomeSpectator(plugin: Khs, player: Player) {
plugin.game.setTeam(player.uuid, Game.Team.SPECTATOR)
plugin.game.loadSpectator(player)
}
fun dieInGame(plugin: Khs, player: Player) {
val team = plugin.game.getTeam(player.uuid)
if (team == null || team == Game.Team.SPECTATOR) return
if (plugin.game.status != Game.Status.SEEKING) return
player.health = 0.1
}
fun createDebugMenu(plugin: Khs): Inventory? {
val inv = plugin.shim.createInventory(DEBUG_TITLE, 9u) ?: return null
val items = listOf(BECOME_HIDER, BECOME_SEEKER, BECOME_SPECTATOR, DIE_IN_GAME, REVEAL_DISGUISE)
items
.map { plugin.shim.parseItem(it) }
.filterNotNull()
.withIndex()
.forEach { (i, item) -> inv.set(i.toUInt(), item) }
return inv
}
|