diff --git a/kore/src/main/kotlin/io/github/ayfri/kore/arguments/selector/SelectorType.kt b/kore/src/main/kotlin/io/github/ayfri/kore/arguments/selector/SelectorType.kt index dc88afd..4361f4c 100644 --- a/kore/src/main/kotlin/io/github/ayfri/kore/arguments/selector/SelectorType.kt +++ b/kore/src/main/kotlin/io/github/ayfri/kore/arguments/selector/SelectorType.kt @@ -1,10 +1,11 @@ package io.github.ayfri.kore.arguments.selector enum class SelectorType(val value: String) { + ALL_ENTITIES("e"), + ALL_PLAYERS("a"), + NEAREST_ENTITY("n"), NEAREST_PLAYER("p"), RANDOM_PLAYER("r"), - ALL_PLAYERS("a"), - ALL_ENTITIES("e"), SELF("s"); val isPlayer get() = this == NEAREST_PLAYER || this == RANDOM_PLAYER || this == ALL_PLAYERS diff --git a/kore/src/main/kotlin/io/github/ayfri/kore/arguments/types/literals/SelectorArgument.kt b/kore/src/main/kotlin/io/github/ayfri/kore/arguments/types/literals/SelectorArgument.kt index f7989a3..7b3fe92 100644 --- a/kore/src/main/kotlin/io/github/ayfri/kore/arguments/types/literals/SelectorArgument.kt +++ b/kore/src/main/kotlin/io/github/ayfri/kore/arguments/types/literals/SelectorArgument.kt @@ -28,6 +28,7 @@ fun allEntities(limitToOne: Boolean = false, data: SelectorArguments.() -> Unit fun allEntities(limit: Int, data: SelectorArguments.() -> Unit = {}) = allEntities { this.limit = limit; data() } fun allEntitiesLimitToOne(data: SelectorArguments.() -> Unit = {}) = allEntities(true, data) +fun nearestEntity(data: SelectorArguments.() -> Unit = {}) = selector(SelectorType.NEAREST_ENTITY, data = data) fun nearestPlayer(data: SelectorArguments.() -> Unit = {}) = selector(SelectorType.NEAREST_PLAYER, data = data) fun player(name: String, limitToOne: Boolean = true, data: SelectorArguments.() -> Unit = {}) = allPlayers(limitToOne) { this.name = name; data() } diff --git a/kore/src/test/kotlin/io/github/ayfri/kore/serialization/Selector.kt b/kore/src/test/kotlin/io/github/ayfri/kore/serialization/Selector.kt index 851a460..4cda767 100644 --- a/kore/src/test/kotlin/io/github/ayfri/kore/serialization/Selector.kt +++ b/kore/src/test/kotlin/io/github/ayfri/kore/serialization/Selector.kt @@ -32,6 +32,7 @@ fun selectorTests() = dataPack("selector_tests") { allEntities() assertsIs "@e" allPlayers() assertsIs "@a" randomPlayer() assertsIs "@r" + nearestEntity() assertsIs "@n" nearestPlayer() assertsIs "@p" self() assertsIs "@s"