blob: fe2cc3cca235f09b2188645ccf9897fd8bfe7f9b (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
package cat.freya.khs
import cat.freya.khs.config.EffectConfig
import cat.freya.khs.config.ItemConfig
import cat.freya.khs.game.Board
import cat.freya.khs.player.Inventory
import cat.freya.khs.player.Player
import cat.freya.khs.world.Effect
import cat.freya.khs.world.Item
import cat.freya.khs.world.World
import java.io.InputStream
import java.util.UUID
// Logger wrapper
// (different baselines may use different logging systems)
interface Logger {
fun info(message: String)
fun warning(message: String)
fun error(message: String)
}
// Plugin wrapper
interface KhsShim {
/// @returns the string of the plugin version
val pluginVersion: String
/// @returns the release minecraft version (ignores the 1.)
val mcVersion: List<UInt>
/// the platform this shim is for
val platform: String
/// @returns the logger
val logger: Logger
/// @returns list of online players
val players: List<Player>
/// @returns list of world names
val worlds: List<String>
/// @returns list of supported blocks
val blocks: List<String>
/// were the khs.db is stored
val sqliteDatabasePath: String
/// @returns a stream from a file in the systems config dir
fun readConfigFile(fileName: String): InputStream?
/// write a config file
fun writeConfigFile(fileName: String, content: String)
/// @returns a valid material for the current mc version given the name
fun parseMaterial(materialName: String): String?
/// @returns a valid item given the config
fun parseItem(itemConfig: ItemConfig): Item?
/// @returns a valid item given the config
fun parseEffect(effectConfig: EffectConfig): Effect?
/// @returns a player that is online on the server right now
fun getPlayer(uuid: UUID): Player?
fun getPlayer(name: String): Player?
/// @returns a world on the server that exists with the given world name
fun getWorld(worldName: String): World?
/// @returns a manager to load/unload a world
fun getWorldLoader(worldName: String): World.Loader
/// create a new world
fun createWorld(worldName: String, type: World.Type): World?
/// create a inventory to use for a player
fun createInventory(title: String, size: UInt): Inventory?
/// @returns a new board
fun getBoard(name: String): Board?
/// broadcast a message to everyone
fun broadcast(message: String)
/// disable everything
fun disable()
/// schedule an event to run at a later date
fun scheduleEvent(ticks: ULong, event: () -> Unit)
fun supports(vararg versions: Int): Boolean {
val seq = versions.asSequence().map { it.toUInt() }.zip(mcVersion.asSequence()).toList()
for ((want, has) in seq) {
if (want < has) return true
if (want > has) return false
}
return true
}
}
|