Add a clear function to String

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
sigonasr2, Sig, Sigo 2022-06-09 19:28:55 +00:00 committed by GitHub
parent 9ba3105b1b
commit a3a2c62d4b
3 changed files with 11 additions and 2 deletions

Binary file not shown.

View File

@ -57,6 +57,11 @@ public class String{
return this.sb.indexOf(str);
}
public void clear() {
this.sb.setLength(0);
bounds = new Point(0,1);
}
/**
* Returns the index within this string of the first occurrence of the
* specified substring, starting at the specified index.

View File

@ -80,8 +80,12 @@ public class EditorRenderer extends LevelRenderer{
if (messageLog.length()>0) {
if (System.currentTimeMillis()-last_message_log>MESSAGE_TIME) {
last_message_log=System.currentTimeMillis();
int secondMarker = messageLog.indexOf("\n",messageLog.indexOf("\n")+1);
messageLog.replace(messageLog.indexOf("\n"), secondMarker==-1?messageLog.length():secondMarker, "");
if (messageLog.length()>1) {
int secondMarker = messageLog.indexOf("\n",messageLog.indexOf("\n")+1);
messageLog.replace(messageLog.indexOf("\n"), secondMarker==-1?messageLog.length():secondMarker, "");
} else {
messageLog.clear();
}
}
}
}