Skip to content

Commit 91b4e93

Browse files
committed
CommandAnnotation 2.7.0
- Added ArgumentParser#throwIfBroken - Added ArgumentParser#getOrThrow
1 parent 1d9c991 commit 91b4e93

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/main/java/skywolf46/commandannotation/data/parser/ArgumentParser.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package skywolf46.commandannotation.data.parser;
22

33
import lombok.Getter;
4+
import lombok.SneakyThrows;
45
import skywolf46.commandannotation.abstraction.AbstractParseDefine;
56
import skywolf46.commandannotation.data.ExceptionRelay;
67
import skywolf46.commandannotation.data.command.CommandArgument;
@@ -59,6 +60,12 @@ public ArgumentParser(CommandArgument args, AbstractParseDefine<?>[] targets) {
5960
}
6061
}
6162

63+
public void throwIfBroken(){
64+
if(brokenCause != null)
65+
brokenCause.printStackTrace();
66+
}
67+
68+
6269
public boolean handle(ExceptionRelay exr){
6370
if(brokenCause == null)
6471
return false;
@@ -76,6 +83,22 @@ public <T> T get(Class<T> positional, int pointer) {
7683
return (T) params[pointer];
7784
}
7885

86+
@SneakyThrows
87+
public <T> T getOrThrow(int pointer) {
88+
if(brokenPosition >= pointer){
89+
throw brokenCause;
90+
}
91+
return (T) params[pointer];
92+
}
93+
94+
@SneakyThrows
95+
public <T> T getOrThrow(Class<T> positional, int pointer) {
96+
if(brokenPosition >= pointer){
97+
throw brokenCause;
98+
}
99+
return (T) params[pointer];
100+
}
101+
79102

80103
public int size() {
81104
return params.length;

0 commit comments

Comments
 (0)