Skip to content

Commit

Permalink
CommandAnnotation 2.7.0
Browse files Browse the repository at this point in the history
- Added ArgumentParser#throwIfBroken
- Added ArgumentParser#getOrThrow
  • Loading branch information
milkyway0308 committed Feb 24, 2021
1 parent 1d9c991 commit 91b4e93
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package skywolf46.commandannotation.data.parser;

import lombok.Getter;
import lombok.SneakyThrows;
import skywolf46.commandannotation.abstraction.AbstractParseDefine;
import skywolf46.commandannotation.data.ExceptionRelay;
import skywolf46.commandannotation.data.command.CommandArgument;
Expand Down Expand Up @@ -59,6 +60,12 @@ public ArgumentParser(CommandArgument args, AbstractParseDefine<?>[] targets) {
}
}

public void throwIfBroken(){
if(brokenCause != null)
brokenCause.printStackTrace();
}


public boolean handle(ExceptionRelay exr){
if(brokenCause == null)
return false;
Expand All @@ -76,6 +83,22 @@ public <T> T get(Class<T> positional, int pointer) {
return (T) params[pointer];
}

@SneakyThrows
public <T> T getOrThrow(int pointer) {
if(brokenPosition >= pointer){
throw brokenCause;
}
return (T) params[pointer];
}

@SneakyThrows
public <T> T getOrThrow(Class<T> positional, int pointer) {
if(brokenPosition >= pointer){
throw brokenCause;
}
return (T) params[pointer];
}


public int size() {
return params.length;
Expand Down

0 comments on commit 91b4e93

Please sign in to comment.