Get Started
- 📚 Setup
- ➡️ Importers
- 📄 Config
- 📝 Translations
- 🔌 Hooks
Documentation
- 🖥️ Commands
- ⛔ Permissions
- 🥄 Claims
- ❤️ Trust
- 🎛️ Operation Groups
- 🪧 Sign Moderation
- 🪦 Drops Moderation
- 😴 Inactivity Pruning
- 🐕 Pets
HuskClaims exposes API to let you register OperationType
s to call custom operations and check if they should be allowed with the Handler
.
OperationTypeRegistry
is the registry containing registered OperationType
s.Handler
class.OperationTypeRegistry
with HuskClaimsAPI#getOperationTypeRegistry
void getRegistry() {
final OperationTypeRegistry reg = huskClaims.getOperationTypeRegistry();
}
Operation
s represent actions in a world that can be prevented from occuring entity based on:
OperationType
.Operation
s with custom registered OperationType
s and call Handler#isOperationAllowed
to allow to determine whether your custom plugin/mod's actions should be permittedOperationType
s to their trust levels config.OperationType
. We recommend doing this onEnable
(not onLoad
before HuskClaims has loaded).OperationTypeRegistry#registerOperationType(@NotNull Key key, boolean silent)
to create an OperationType
key
- the key identifier of the OperationType (e.g. Key.of("my_plugin", "operation_name")
-> my_plugin:operation_name
).silent
- whether players should be informed when this operation is cancelled (usually you want this on, unless your operation doesn't affect players or is particularly spammy such as pressure plate triggering operations)OperationType
. You should save this Operation Type somewhere for later use.private OperationType releaseMonOpType;
void getRegistry() {
final OperationTypeRegistry reg = huskClaims.getOperationTypeRegistry();
releaseMonOpType = reg.createOperationType(Key.of("mons_mod", "release_mon"));
reg.registerOperationType(releaseMonOpType);
}
Handler
with OperationTypeRegistry#getHandler
Operation
with your newly made OperationType
using Operation#of()
Operation#of
variants letting you specify the performing user, operation type, operation position, silent state of this operation (overriding the default value of the operation type), and victim user in various combinations.Handler#cancelOperation
to get a boolean true
or false
value of whether the Operation should be allowedprivate OperationType releaseMonOpType;
void onMonReleased(Player bukkitPlayer, Location releasedAt) {
final OperationTypeRegistry reg = huskClaims.getOperationTypeRegistry();
final boolean cancelled = reg.getHandler().cancelOperation(Operation.of(
huskClaims.getPlayer(bukkitPlayer), // OnlineUser implements OperationUser
releaseMonOpType,
huskClaims.getPosition(releasedAt) // Position implements OperationPosition
));
if (cancelled) {
// Don't continue with the action
return;
}
// Logic would continue if the operation wasn't cancelled...
}