@@ -62,7 +62,6 @@ Argument type, but there are many others:
6262| ---------------------| -----------------------| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6363| GAME_EVENT | GameEvent | [ Game events] ( https://minecraft.wiki/w/Sculk_Sensor#Vibration_frequencies ) |
6464| STRUCTURE_TYPE | StructureType | [ Structure types] ( https://minecraft.wiki/w/Structure#Overworld ) |
65- | INSTRUMENT | MusicInstrument | [ Goat horns] ( https://minecraft.wiki/w/Goat_Horn#Playing ) |
6665| MOB_EFFECT | PotionEffectType | [ Potion effect] ( https://minecraft.wiki/w/Effect#List ) |
6766| BLOCK | BlockType | [ Block type] ( https://minecraft.wiki/w/Block#List_of_blocks ) |
6867| ITEM | ItemType | [ Item type] ( https://minecraft.wiki/w/Item#List_of_items ) |
@@ -72,23 +71,24 @@ Argument type, but there are many others:
7271| VILLAGER_TYPE | Villager.Type | [ Villager biome specific type] ( https://minecraft.wiki/w/Villager#Professions ) |
7372| MAP_DECORATION_TYPE | MapCursor.Type | [ Types of sprites displayed on a map] ( https://minecraft.wiki/w/Map#Map_icons ) |
7473| MENU | MenuType | [ Menu type] ( https://wiki.vg/Inventory ) |
74+ | ATTRIBUTE | Attribute | [ Entity attribute] ( https://minecraft.wiki/w/Attribute ) |
75+ | FLUID | Fluid | [ Fluid types] ( https://minecraft.wiki/w/Fluid ) |
76+ | SOUND_EVENT | Sound | [ Events that trigger sound effects] ( https://minecraft.wiki/w/Sounds.json#Sound_events ) |
77+ | BIOME | Biome | [ Biome type] ( https://minecraft.wiki/w/Biome#Biome_types ) |
7578| STRUCTURE | Structure | [ Structures] ( https://minecraft.wiki/w/Structure#Overworld ) |
7679| TRIM_MATERIAL | TrimMaterial | [ Materials used to trim armor] ( https://minecraft.wiki/w/Smithing#Material ) |
7780| TRIM_PATTERN | TrimPattern | [ Trim patterns] ( https://minecraft.wiki/w/Smithing#Trimming ) |
7881| DAMAGE_TYPE | DamageType | [ All types of damage dealt to an entity] ( https://minecraft.wiki/w/Damage_type ) |
82+ | WOLF_VARIANT | Wolf.Variant | [ Wolf variants] ( https://minecraft.wiki/w/Wolf#Variants ) |
7983| ENCHANTMENT | Enchantment | [ Enchantment type] ( https://minecraft.wiki/w/Enchanting#Summary_of_enchantments ) |
8084| JUKEBOX_SONG | JukeboxSong | Music disc songs |
81- | WOLF_VARIANT | Wolf.Variant | [ Wolf variants] ( https://minecraft.wiki/w/Wolf#Variants ) |
8285| BANNER_PATTERN | PatternType | [ Banner patterns] ( https://minecraft.wiki/w/Banner_Pattern#Variants ) |
83- | BIOME | Biome | [ Biome type] ( https://minecraft.wiki/w/Biome#Biome_types ) |
8486| PAINTING_VARIANT | Art | [ Painting variants] ( https://minecraft.wiki/w/Painting#Canvases ) |
85- | ATTRIBUTE | Attribute | [ Entity attribute ] ( https://minecraft.wiki/w/Attribute ) |
87+ | INSTRUMENT | MusicInstrument | [ Goat horns ] ( https://minecraft.wiki/w/Goat_Horn#Playing ) |
8688| ENTITY_TYPE | EntityType | [ Every entity type] ( https://minecraft.wiki/w/Entity#Types_of_entities ) |
8789| PARTICLE_TYPE | Particle | [ Every particle type] ( https://minecraft.wiki/w/Particles_(Java_Edition)#Types_of_particles ) |
8890| POTION | PotionType | [ Every potion type] ( https://minecraft.wiki/w/Potion#Effect_potions ) |
89- | SOUND_EVENT | Sound | [ Events that trigger sound effects] ( https://minecraft.wiki/w/Sounds.json#Sound_events ) |
9091| MEMORY_MODULE_TYPE | MemoryKey | Keys for saving per-entity data |
91- | FLUID | Fluid | [ Fluid types] ( https://minecraft.wiki/w/Fluid ) |
9292
9393Paper specifies many more argument types. For more information on them, see <Javadoc name = { " io.papermc.paper.command.brigadier.argument.ArgumentTypes" } >ArgumentTypes</Javadoc >
9494
@@ -100,7 +100,7 @@ interface.
100100Now, let's say that we want to implement a command which lets you order ice cream. For that,
101101we add an enum that specifies all available values for our custom type.
102102
103- ``` java
103+ ``` java title="IceCreamType.java"
104104public enum IceCreamType {
105105 VANILLA ,
106106 CHOCOLATE ,
@@ -111,11 +111,11 @@ public enum IceCreamType {
111111```
112112Now, we have to define the argument itself. We do this by implementing the <Javadoc name = { " io.papermc.paper.command.brigadier.argument.CustomArgumentType$Converted" } >CustomArgumentType.Converted</Javadoc > interface:
113113
114- ``` java
114+ ``` java title="IceCreamTypeArgument.java"
115115public class IceCreamTypeArgument implements CustomArgumentType .Converted<IceCreamType , String > {
116116
117117 @Override
118- public @ NotNull IceCreamType convert (String nativeType ) throws CommandSyntaxException {
118+ public IceCreamType convert (String nativeType ) throws CommandSyntaxException {
119119 try {
120120 return IceCreamType . valueOf(nativeType. toUpperCase(Locale . ENGLISH ));
121121 } catch (IllegalArgumentException ignored) {
@@ -126,7 +126,7 @@ public class IceCreamTypeArgument implements CustomArgumentType.Converted<IceCre
126126 }
127127
128128 @Override
129- public @ NotNull ArgumentType<String > getNativeType () {
129+ public ArgumentType<String > getNativeType () {
130130 return StringArgumentType . word();
131131 }
132132
@@ -154,7 +154,8 @@ detail.
154154
155155We then need to register the command:
156156
157- ``` java
157+ ``` java title="TestPlugin.java"
158+ @Override
158159public void onEnable() {
159160 final LifecycleEventManager<Plugin > manager = this . getLifecycleManager();
160161 manager. registerEventHandler(LifecycleEvents . COMMANDS , event - > {
0 commit comments