File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/main/java/me/hsgamer/bettergui/builder Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1111import me .hsgamer .hscore .common .CollectionUtils ;
1212
1313import java .util .List ;
14+ import java .util .Optional ;
15+ import java .util .regex .Matcher ;
16+ import java .util .regex .Pattern ;
1417import java .util .stream .Collectors ;
1518
1619/**
@@ -48,8 +51,19 @@ public List<Action> build(Menu menu, Object object) {
4851 }
4952
5053 public interface Input extends ActionInput , MenuElement {
54+ Pattern pattern = Pattern .compile ("\\ s*([\\ w\\ -$]+)\\ s*(?:\\ ((.*?)\\ ))?\\ s*(?::\\ s*(.*))?" );
55+
5156 static Input create (Menu menu , String input ) {
52- ActionInput actionInput = ActionInput .create (input );
57+ ActionInput actionInput ;
58+ Matcher matcher = pattern .matcher (input );
59+ if (matcher .matches ()) {
60+ String type = matcher .group (1 );
61+ String option = Optional .ofNullable (matcher .group (2 )).orElse ("" );
62+ String value = Optional .ofNullable (matcher .group (3 )).orElse ("" );
63+ actionInput = ActionInput .create (type , option , value );
64+ } else {
65+ actionInput = ActionInput .create ("" , "" , input );
66+ }
5367 return new Input () {
5468 @ Override
5569 public String getType () {
You can’t perform that action at this time.
0 commit comments