Skip to content

Commit

Permalink
Added a way to access the default/pre-made processors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqzn committed Nov 4, 2024
1 parent c991fb9 commit 30b60c3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/src/main/java/dev/velix/imperat/ImperatConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import dev.velix.imperat.command.processors.CommandPostProcessor;
import dev.velix.imperat.command.processors.CommandPreProcessor;
import dev.velix.imperat.command.processors.CommandProcessingChain;
import dev.velix.imperat.command.processors.impl.UsageCooldownProcessor;
import dev.velix.imperat.command.processors.impl.UsagePermissionProcessor;
import dev.velix.imperat.command.processors.impl.DefaultProcessors;
import dev.velix.imperat.command.suggestions.SuggestionResolverRegistry;
import dev.velix.imperat.context.Context;
import dev.velix.imperat.context.ParamTypeRegistry;
Expand Down Expand Up @@ -65,8 +64,8 @@ final class ImperatConfigImpl<S extends Source> implements ImperatConfig<S> {
regDefThrowableResolvers();

globalPreProcessors = CommandProcessingChain.<S>preProcessors()
.then(new UsagePermissionProcessor<>())
.then(new UsageCooldownProcessor<>())
.then(DefaultProcessors.preUsagePermission())
.then(DefaultProcessors.preUsageCooldown())
.build();

globalPostProcessors = CommandProcessingChain.<S>postProcessors()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.velix.imperat.command.processors.impl;

import dev.velix.imperat.context.Source;

public final class DefaultProcessors {

public static <S extends Source> UsageCooldownProcessor<S> preUsageCooldown() {
return new UsageCooldownProcessor<>();
}

public static <S extends Source> UsagePermissionProcessor<S> preUsagePermission() {
return new UsagePermissionProcessor<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import dev.velix.imperat.exception.ImperatException;

public final class UsageCooldownProcessor<S extends Source> implements CommandPreProcessor<S> {

UsageCooldownProcessor() {

}
/**
* Processes context BEFORE the resolving operation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import dev.velix.imperat.exception.PermissionDeniedException;

public final class UsagePermissionProcessor<S extends Source> implements CommandPreProcessor<S> {

UsagePermissionProcessor() {

}
/**
* Processes context BEFORE the resolving operation.
*
Expand Down

0 comments on commit 30b60c3

Please sign in to comment.