Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. private static String getSplitedText(String text) {
  2. String[] split = text.split(" ");
  3. String ret = "";
  4. text = "";
  5. int length = 1000;
  6. int maxLenght = 100;
  7. for (int i = 0; i<split.length; i++) {
  8. int addLength = CenterMessage.getLength(split[i]);
  9. if (length + addLength > maxLenght) {
  10. ret += "§§§7" + text;
  11. text = split[i];
  12. length = addLength+4;
  13. continue;
  14. }
  15. length += addLength+4;
  16. text += " " +split[i];
  17. }
  18. if (text.endsWith(" ")) text = text.substring(0, text.length()-1);
  19. if (text != "") ret += "§§§7" + text;
  20. return ret.replaceFirst("§§§7", "");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement