Mutable String - roidrole/Roids-Tweaker GitHub Wiki
CraftTweaker's string addition is pretty inefficient. This class wraps StringBuilder, which is much more efficient if you add a lot of strings together. The resulting code is also often cleaner.
Import :
import mods.ctintegration.util.MutableString;
Here are ways to create a MutableString. They all return a new instance :
| Method | Parameters | Description |
|---|---|---|
| create | [None] | The most basic one. Creates an empty MutableString |
| create | starting as string | Creates a MutableString with this string |
| format | starting as string, arguments as Object[] | Same as above, but calls String.format on starting |
Here is what can be done with a MutableString :
| Method | Parameter | Return Type | Description |
|---|---|---|---|
| append | s as string | MutableString | Adds the specified string to the end of the built string |
| insert | offset as int, s as string | MutableString | Adds the specified string to the build string at the specified index |
| delete | start as int, end as int | MutableString | Removes the characters between start and end indexes. This changes its length |
| deleteCharAt | pos as int | MutableString | Same, but for a single character |
| reverse | [None] | MutableString | Reverses the order of the built string |
| getLength | [None] | int | Returns the number of characters comprising the built string |
| indexOf | character as string | int | Returns the position of the specified character. Note: "character" doesn't have to be of length 1 |
| build | [None] | string | Returns the built string |
Don't forget to MutableString.build() before using as a string!