Skip to content

Commit d914a55

Browse files
committed
Minor Improvements
1 parent ca2fee3 commit d914a55

File tree

11 files changed

+34
-22
lines changed

11 files changed

+34
-22
lines changed

core/src/main/java/dev/velix/imperat/ImperatConfigImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ else if (range.getMax() != Double.MAX_VALUE)
204204

205205
this.setThrowableResolver(
206206
InvalidUUIDException.class, (exception, imperat, context) ->
207-
context.source().error("Invalid uuid-format '" + exception.getRaw() + "'")
207+
context.source().error("Invalid uuid-format '" + exception.getInput() + "'")
208208
);
209209

210210
this.setThrowableResolver(

core/src/main/java/dev/velix/imperat/annotations/GlobalAttachmentMode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
import java.lang.annotation.RetentionPolicy;
99
import java.lang.annotation.Target;
1010

11+
/**
12+
* Represents the Fallback attachment mode that will be set for all subcommands that have
13+
* their attachment mode = `UNSET`.
14+
*/
1115
@Retention(RetentionPolicy.RUNTIME)
1216
@Target({ElementType.TYPE, ElementType.METHOD})
1317
@ApiStatus.AvailableSince("1.9.0")

core/src/main/java/dev/velix/imperat/annotations/Help.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import java.lang.annotation.RetentionPolicy;
99
import java.lang.annotation.Target;
1010

11+
/**
12+
* Represents a help provider per {@link dev.velix.imperat.command.Command} instance.
13+
*/
1114
@Retention(RetentionPolicy.RUNTIME)
1215
@Target({ElementType.TYPE, ElementType.METHOD})
1316
@ApiStatus.AvailableSince("1.9.0")

core/src/main/java/dev/velix/imperat/annotations/base/element/ClassElement.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dev.velix.imperat.annotations.base.AnnotationParser;
55
import dev.velix.imperat.command.Command;
66
import dev.velix.imperat.context.Source;
7+
import dev.velix.imperat.exception.UnknownDependencyException;
78
import dev.velix.imperat.util.reflection.Reflections;
89
import org.jetbrains.annotations.NotNull;
910
import org.jetbrains.annotations.Nullable;
@@ -57,6 +58,9 @@ private void injectDependencies() {
5758
field.setAccessible(true);
5859
try {
5960
var supplied = parser.getImperat().config().resolveDependency(field.getType());
61+
if(supplied == null) {
62+
throw new UnknownDependencyException("In class '" + this.element.getTypeName() + "', Field '" + field.getName() +"' of type '" + field.getType().getTypeName() + "'" + " has no dependency registered for its type.");
63+
}
6064
field.set(instance, supplied);
6165
} catch (IllegalAccessException e) {
6266
exception = e;

core/src/main/java/dev/velix/imperat/context/internal/sur/handlers/FlagInputHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import dev.velix.imperat.context.internal.CommandInputStream;
1111
import dev.velix.imperat.context.internal.ExtractedInputFlag;
1212
import dev.velix.imperat.context.internal.sur.HandleResult;
13-
import dev.velix.imperat.exception.FlagException;
13+
import dev.velix.imperat.exception.ShortHandFlagException;
1414
import dev.velix.imperat.exception.ImperatException;
1515
import dev.velix.imperat.util.ImperatDebugger;
1616
import dev.velix.imperat.util.Patterns;
@@ -45,11 +45,11 @@ public HandleResult handle(ResolvedContext<S> context, CommandInputStream<S> str
4545
long numberOfTrueFlags = extracted.size() - numberOfSwitches;
4646

4747
if (extracted.size() != numberOfSwitches && extracted.size() != numberOfTrueFlags) {
48-
return HandleResult.failure(new FlagException("Unsupported use of a mixture of switches and true flags!"));
48+
return HandleResult.failure(new ShortHandFlagException("Unsupported use of a mixture of switches and true flags!"));
4949
}
5050

5151
if (extracted.size() == numberOfTrueFlags && !TypeUtility.areTrueFlagsOfSameInputTpe(extracted)) {
52-
return HandleResult.failure(new FlagException("You cannot use compressed true-flags, while they are not of same input type"));
52+
return HandleResult.failure(new ShortHandFlagException("You cannot use compressed true-flags, while they are not of same input type"));
5353
}
5454

5555
for (FlagData<S> extractedFlagData : extracted) {

core/src/main/java/dev/velix/imperat/exception/InvalidSyntaxException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
public final class InvalidSyntaxException extends ImperatException {
44

5-
65
}
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package dev.velix.imperat.exception;
22

3-
public class InvalidUUIDException extends ImperatException {
4-
5-
private final String raw;
6-
3+
public class InvalidUUIDException extends ParseException {
4+
75
public InvalidUUIDException(final String raw) {
8-
this.raw = raw;
6+
super(raw);
97
}
10-
11-
public String getRaw() {
12-
return raw;
13-
}
14-
8+
159
}

core/src/main/java/dev/velix/imperat/exception/OnlyPlayerAllowedException.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
public final class OnlyPlayerAllowedException extends ImperatException {
44

5-
6-
75
}

core/src/main/java/dev/velix/imperat/exception/FlagException.java renamed to core/src/main/java/dev/velix/imperat/exception/ShortHandFlagException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import org.jetbrains.annotations.ApiStatus;
44

55
@ApiStatus.AvailableSince("1.9.8")
6-
public class FlagException extends ImperatException {
7-
public FlagException(String message) {
6+
public class ShortHandFlagException extends ImperatException {
7+
public ShortHandFlagException(String message) {
88
super(message);
99
}
1010
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dev.velix.imperat.exception;
2+
3+
public final class UnknownDependencyException extends RuntimeException {
4+
public UnknownDependencyException(String message, Throwable cause) {
5+
super(message, cause);
6+
}
7+
8+
public UnknownDependencyException(String message) {
9+
super(message);
10+
}
11+
}

0 commit comments

Comments
 (0)