Skip to main content

Adding Booster Holders

Here, you can learn how to add custom booster holders. Booster holders are objects that can hold boosts. By default, NeoExtras adds a global, player, and worldly holder. Adding booster holders is a little bit more involved than adding booster types, mainly due to lang. Upon adding a custom booster holder, users may want to regenerate all of their configs to better reflect the addition.


Getting Started

Firstly, you're going to need create a class extending dev.neovitalism.neoextras.api.boosters.holders.BoosterHolderType. There's a few methods that are required to override, and a handful of others you should know about.

Method Descriptions

Below, I explain each method in detail.


String getName()

Gets the name of this type of holder. Names should be all lowercase.
Required: True


String getValidationMessage(String holderName)

Validation method for holder names. Perform validation to make sure the holderName is valid here. If it's invalid, return either a lang key or a hardcoded message. If using a lang key, messages are grabbed from the /NeoExtras/boosters/general.yml lang. If the holderName is valid, return null. {arg} will replace the argument in lang if the holderName is invalid.
Required: True


String alterHolderNameForSaving(String holderName)

Method used for saving in the case that the saving name should not be the same value as the holderName. An example of this is in the player holder's case, where boosts should be saved under the player's UUID instead of their username.
Required: False


boolean matches(ServerPlayerEntity player, String holderName)

Checks whether the holderName is one that affects the player.
Required: True


boolean allowsMultipleMatches()

Method to determine whether your booster holder may have multiple matches with a player. On all 3 default holders, this is false; the global holder is singular, the player can only have one username/uuid for the player holder, and the player can only be in a single world at a time with the world holder. For that reason, this is an optional method that defaults to false.
Required: False


double getPermanentBoost(ServerPlayerEntity player, NeoExtrasBooster<?, ?> booster)

Gets the player's permanent boost for this holder type. Permanent boosts should differ between each booster type. Handling permanent boosts is not required, as this method defaults to 1.0.
Required: False


double getMaxBoost(ServerPlayerEntity player, NeoExtrasBooster<?, ?> booster)

Gets the player's maximum boost for this holder type. By default, this is grabbed from the booster's config. The only reason to override this is to extend functionality.
Required: False


net.kyori.adventure.audience.Audience getAudience(String holderName)

Gets the Audience for all players involved with this holderName for messages regarding boosters, except reminders.
Required: True


void remind(Map<String, List<TemporaryBooster<C>>> map, ServerPlayerEntity player)

Reminds the player of relevant boosters when they login after the general config's remind delay. map is a map of all boosters your custom booster holder is holding, with the key being the holder's name and the value being all of the temporary boosts. Default functionality loops over every holder name, checking if it's relevant with isBoosterRelevant. If the holder name is relevant to the player, then it reminds the player of all boosts that holder name has. There's not much of a reason to override this method.
Required: False


boolean isBoosterRelevant(ServerPlayerEntity player, String holderName)

Determines whether a booster is relevant to a player for reminders and the list command. By default, this mimics the matches method.
Required: False


List<String> getCompletions()

Gets all holder name examples of this holder type for use in the booster command's tab-complete.
Required: True


Configuration getDefaultLang(NeoExtrasBooster<?, ?> booster)

This is where you create the lang per-booster for your custom holder type. There are a lot of lang keys that need to be added, which you can see with their explanations here. Timed message examples are also required. Start with a new Configuration(). Then, on that object, to set a lang key with it's default value, use Configuration#set(String key, String value). For the best example, I suggest looking at GlobalBoosterHolder#getDefaultLang.
Required: True


Registering Your Custom Holder

Once you've done everything you need to with the above methods, you can register your custom holder with dev.neovitalism.neoextras.api.boosters.holders.BoosterHolderRegistry.register(BoosterHolderType holder) in your mod initialization. Users will need to reset their configs at this current moment to reflect the addition of the new holder.