Creating your first command
We will create our very first command
In this page, you will learn how to create commands using annotations.
We will be using the Bukkit platform, as it is the most widely used platform for Lamp. However, the same concepts apply to all other platforms.
A /greet command
That's it! We have our own /greet command. Let's register it:
Let's see Lamp in action:
Great! Let's buff our command with more arguments.
We will add a target
argument, which is a player. When executed, the target player will receive a welcome message.
Which will generate the following command:
Running it, we get:
Notice that by specifying the Player type, we automatically get tab completions for free! Also, if we try to input an invalid player, we get the following error message:
This is the beauty of Lamp! You describe the command and write the code that needs to be executed. Everything else, like auto-completions, validation, and parsing is done under the hood.
💡 It may seem like magic that Lamp knows how to parse the
org.bukkit.entity.Player
type. Not much magic is involved, though! Lamp has built-in support for the following types:
java.lang.String
long, int, short, byte, double, and float
boolean
java.util.UUID
Any
enum
typeThe following platform-specific types are also supported:
org.bukkit.World
org.bukkit.entity.Player
org.bukkit.OfflinePlayer
EntitySelector<SomeEntityType>
, which is a Lamp-provided type for matching@p
,@r
,@e[type=cow,distance=10]
, etc.And, good news! For all the types above, you get
List<T>
,Set<T>
andT[]
types for free. The same applies for any parameter type you register, which we will do in the next tutorials.
Last updated
Was this helpful?