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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user