JorelAli / CommandAPI

A Bukkit/Spigot API for the command UI introduced in Minecraft 1.13

Home Page:https://commandapi.jorel.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option to toggle integer centering in LocationArgument and Location2DArgument

learliet opened this issue · comments

Description

Currently, the CommandAPI's LocationType.PRECISE_POSITION uses Vec3Argument.vec3(). This causes integer values to be centered, which may not always be desired. It seems that the Vec3Argument has a boolean option called "centerIntegers" that determines whether or not it performs the correction.

It would be beneficial to utilize this option, allowing for straightforward offset arguments that accept three numbers without any modifications. This enhancement would align with the behavior of the delta argument in the vanilla particle command.

Expected code

No response

Extra details

A temporary workaround for developers who ran into the same issue:

val delta = args[0] as Location

val deltaNew = args.getRaw(0)!!.split(" ").map {
    if (it.contains('.')) null else it.toDoubleOrNull()
}.toMutableList()

delta.x = deltaNew[0] ?: delta.x
delta.y = deltaNew[1] ?: delta.y
delta.z = deltaNew[2] ?: delta.z

Awesome! I didn't know there was a parameter in the Vec3Argument class, and this finally solves the mystery that I had discovered in one of the CommandAPI's tests for the LocationArgument:

image

Will implement for the next release.

Implemented in 9.2.0.