Paul2708 / simple-commands

An (even more) simplified and intuitive command framework for Spigot.
MIT License
14 stars 2 forks source link

Optional (argument) notation #11

Closed Paul2708 closed 5 years ago

Paul2708 commented 5 years ago

Description

A notation that declares an argument as optional.

Usage

Implementation idea The notation can be realised by @Optional or Optional<Type> or even both?

Screenshots or code Annotation:

@Command(name = "test")
public void test(Player sender, @Optional String name) {
  if (CommandArgument.isPresent(name)) {
     // Argument is present
  }
}

Optional:

@Command(name = "test")
public void test(Player sender, Optional<String> name) {
  if (name.isPresent()) {
     // Argument is present
  }
}