Skip to content

Commit

Permalink
feat(selector): Add nearestEntity selector in SelectorArgument an…
Browse files Browse the repository at this point in the history
…d tests.
  • Loading branch information
Ayfri committed Sep 6, 2024
1 parent 4471ae7 commit 51f2cdd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 51f2cdd

Please sign in to comment.