Skip to content

Hey there! If you like my work, you can support me by sponsoring me on GitHub. Thanks! ❤

Sponsor me
on GitHub

Permission Messages

To customize a message about missing permissions, you can choose from two ways:

  • Use the message system
  • Implement a missing permissions handler

Message System

To change the default message, register a custom message in the builder:

java
.commands(
    new SomeCommand()
)
.message(LiteMessages.MISSING_PERMISSIONS, permissions -> "Required permissions: (" + permissions.asJoinedText() + ")")
.build();

The permissions parameter is a MissingPermissions object that contains the missing permissions.

Missing Permissions Handler

To implement a missing permissions handler, create a class that implements the MissingPermissionsHandler interface:

java
// PermissionsHandler.java
public class PermissionsHandler implements MissingPermissionsHandler<SENDER> {

    @Override
    public void handle(
            Invocation<SENDER> invocation,
            MissingPermissions missingPermissions,
            ResultHandlerChain<SENDER> chain
    ) {
        String permissions = missingPermissions.asJoinedText();
        SENDER sender = invocation.sender();

        sender.sendMessage("Required permissions: (" + permissions + ")");
    }
}

Then, register the handler in the builder:

java
.commands(
    new SomeCommand()
)
.missingPermission(new PermissionsHandler())
.build();

And that's it! Now, when a player without the required permissions tries to execute a command, the handler will send a custom message.

Made by LiteDevelopers and Contributors with ❤️