Skip to content

Hey there! If you like my work, you can support me by sponsoring me on GitHub. Thanks! ❤

Sponsor me
on GitHub

Java Types

To use Java types like int, double, Duration, BigInteger, Enum, and more, you need to use the @Arg annotation and specify the type of the argument.

Argument TypeValuesExample
Booleantrue, falsetrue
Byte-128 - 12710
Short-32768 - 327671000
Integer-2147483648 - 21474836471000000000
Long-9223372036854775808 - 9223372036854775807100000000000
Float0.0 - 3.4028235E3810.5
Double0.0 - 1.7976931348623157E30810.5
StringAny stringtext
String (Quoted)Any string surrounded by quotes"Hello World"
EnumAny enumWORLD
DurationXd, Xh, Xm, Xs, Xms10m, 5d4h30m15s
Period1y, 1mo, 1w, 1d1y, 12mo, 1w
Instantyyyy-MM-dd HH:mm:ss2021-01-01 00:00
LocalDateTimeyyyy-MM-dd HH:mm:ss2021-01-01 00:00
UUIDxxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx123e4567-e89b-12d3-a456-426614174000
BigIntegerAny number100000000000
BigDecimalAny number100000000000.0
CharAny charactera

Here is an example of how to use the @Arg annotation with different types:

java
@Command(name = "time set")
public class TimeCommand {
    @Execute
    void time(@Arg int time) {
        // /time set <time>
    }
}
java
@Command(name = "balance set")
public class BalanceCommand {
    @Execute
    void balance(@Context SENDER sender, @Arg BigDecimal amount) {
        // /balance set <amount>
    }
}
java
@Command(name = "ban")
public class BanCommand {
    @Execute
    void ban(@Arg Player player, @Arg Duration duration) {
        // /ban <player> <duration>
    }
}
java
@Command(name = "give")
public class GiveCommand {
    @Execute
    void give(@Arg BigInteger amount) {
        // /give <amount>
    }
}
java
@Command(name = "alert")
public class AlertCommand {
    @Execute
    void alert(@Arg AlertType type, @Join String message) {
        // /alert <type> <message...>
    }
}

// AlertType.java
public enum Action {
    CHAT, ACTIONBAR, TITLE, SUBTITLE, BOSSBAR
}

Made by LiteDevelopers and Contributors with ❤️