Add method to remove string at start

A new method `removeStringAtStart` has been added to the `ModifiableString` class. It replaces the starting string in a given text. Also, a condition has been modified in the `ChatListener` class to invoke this new method when the input string starts with the `APRIL_FOOLS_RESET` string. Additional unit tests were created to validate these changes.
This commit is contained in:
2024-03-24 17:12:55 +01:00
parent 9270423928
commit ad91cda0c0
3 changed files with 36 additions and 2 deletions
@@ -110,8 +110,12 @@ public class ChatListener implements Listener {
Set<Player> playersToPing = new HashSet<>();
pingPlayers(playersToPing, modifiableString, player);
LocalDate now = LocalDate.now();
if (now.getMonth().equals(Month.APRIL) && now.getDayOfMonth() == 1 && !modifiableString.string().startsWith(Config.APRIL_FOOLS_RESET)) {
modifiableString.reverse();
if (now.getMonth().equals(Month.APRIL) && now.getDayOfMonth() == 1) {
if (modifiableString.string().startsWith(Config.APRIL_FOOLS_RESET + " ")) {
modifiableString.removeStringAtStart(Config.APRIL_FOOLS_RESET + " ");
} else {
modifiableString.reverse();
}
}
input = render(player, modifiableString.component());
for (Player receiver : receivers) {