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
|
package io.dico.parcels2
import io.dico.parcels2.options.RuntimeWorldOptions
import io.dico.parcels2.storage.Storage
import io.dico.parcels2.util.Vec2i
import io.dico.parcels2.util.floor
import org.bukkit.Chunk
import org.bukkit.Location
import org.bukkit.World
import org.bukkit.block.Block
import org.bukkit.entity.Entity
import org.joda.time.DateTime
import java.util.UUID
interface ParcelProvider {
val worlds: Map<String, ParcelWorld>
fun getWorldById(id: ParcelWorldId): ParcelWorld?
fun getParcelById(id: ParcelId): Parcel?
fun getWorld(name: String): ParcelWorld?
fun getWorld(world: World): ParcelWorld? = getWorld(world.name)
fun getWorld(block: Block): ParcelWorld? = getWorld(block.world)
fun getWorld(loc: Location): ParcelWorld? = getWorld(loc.world)
fun getWorld(entity: Entity): ParcelWorld? = getWorld(entity.location)
fun getParcelAt(worldName: String, x: Int, z: Int): Parcel? = getWorld(worldName)?.locator?.getParcelAt(x, z)
fun getParcelAt(world: World, x: Int, z: Int): Parcel? = getParcelAt(world.name, x, z)
fun getParcelAt(world: World, vec: Vec2i): Parcel? = getParcelAt(world, vec.x, vec.z)
fun getParcelAt(loc: Location): Parcel? = getParcelAt(loc.world, loc.x.floor(), loc.z.floor())
fun getParcelAt(entity: Entity): Parcel? = getParcelAt(entity.location)
fun getParcelAt(block: Block): Parcel? = getParcelAt(block.world, block.x, block.z)
fun getWorldGenerator(worldName: String): ParcelGenerator?
fun loadWorlds()
}
interface ParcelLocator {
val world: World
fun getParcelIdAt(x: Int, z: Int): ParcelId?
fun getParcelAt(x: Int, z: Int): Parcel?
fun getParcelAt(vec: Vec2i): Parcel? = getParcelAt(vec.x, vec.z)
fun getParcelAt(loc: Location): Parcel? = getParcelAt(loc.x.floor(), loc.z.floor()).takeIf { loc.world == world }
fun getParcelAt(entity: Entity): Parcel? = getParcelAt(entity.location).takeIf { entity.world == world }
fun getParcelAt(block: Block): Parcel? = getParcelAt(block.x, block.z).takeIf { block.world == world }
}
typealias ParcelContainerFactory = (ParcelWorld) -> ParcelContainer
interface ParcelContainer {
fun getParcelById(x: Int, z: Int): Parcel?
fun getParcelById(id: Vec2i): Parcel? = getParcelById(id.x, id.z)
fun nextEmptyParcel(): Parcel?
}
interface ParcelWorld : ParcelLocator, ParcelContainer {
val id: ParcelWorldId
val name: String
val uid: UUID?
val options: RuntimeWorldOptions
val generator: ParcelGenerator
val storage: Storage
val container: ParcelContainer
val locator: ParcelLocator
val blockManager: ParcelBlockManager
val globalAddedData: GlobalAddedDataManager
val creationTime: DateTime?
}
|