Skip to content

Instantly share code, notes, and snippets.

@Kovak
Created July 26, 2020 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kovak/079fb6d84f86c59eaca43418102b06d5 to your computer and use it in GitHub Desktop.
Save Kovak/079fb6d84f86c59eaca43418102b06d5 to your computer and use it in GitHub Desktop.
private static ITextComponent parseText(String text){
String parsing = text;
ITextComponent component = new StringTextComponent("");
while (!parsing.isEmpty()){
if (parsing.contains("{") && parsing.contains("}")){
int index = parsing.indexOf("{");
int endIndex = parsing.indexOf("}");
component.appendText(parsing.substring(0, index));
String textProviderRequest = parsing.substring(index, endIndex);
//handle request
parsing = parsing.substring(endIndex);
} else {
component.appendText(parsing);
parsing = "";
}
}
return component;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment