Learn how to create custom Tooltips conditions in your plugin
Create a condition class
For this example, let's create a condition that checks if the players food level is equal to or higher than a given amount. As a result, our condition will look like: hunger {amount=10}
importorg.bukkit.entity.Player;importfi.septicuss.tooltips.object.preset.condition.Condition;importfi.septicuss.tooltips.object.preset.condition.argument.Arguments;importfi.septicuss.tooltips.object.validation.Validity;// Checks if players food level is above the given amountpublicclassHungerimplementsCondition {// These are the aliases for arguments. // You can yourself decide which aliases can be used.privatestaticfinalString[] AMOUNT = {"amt","amount"};// Returns whether this condition is true with the// given arguments @Overridepublicbooleancheck(Player player,Arguments args) {int amount =args.get(AMOUNT).getAsInt();int foodLevel =player.getFoodLevel();return (foodLevel >= amount); }// This method is used to check, whether the arguments are valid.// Once this check is complete, you can safely use the arguments in the// above check method. @OverridepublicValidityvalid(Arguments args) {if (!args.has(AMOUNT)) {returnValidity.of(false,"Amount argument is missing!"); }if (!args.isNumber(AMOUNT)) {returnValidity.of(false,"Amount argument must be a number!"); }returnValidity.TRUE; }}
Register the condition
Register this condition in your plugins onLoad like so: