Add reverse chat feature for April Fools' and corresponding tests
This commit includes a new feature that reverses the text speech of chat users on April 1st as an April Fools' prank. It also includes a reset option, configurable via a new parameter in the configuration file. Furthermore, it provides tests for the reverse string functionality, ensuring that it works correctly, even with complex strings that include tags.
This commit is contained in:
@@ -29,6 +29,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -107,7 +109,10 @@ 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();
|
||||
}
|
||||
input = render(player, modifiableString.component());
|
||||
for (Player receiver : receivers) {
|
||||
receiver.sendMessage(input);
|
||||
|
||||
Reference in New Issue
Block a user