Skip to content

Commit

Permalink
Add chatslowmode off messages, add support for "0" arg value for that…
Browse files Browse the repository at this point in the history
… command.
  • Loading branch information
CitralFlo committed Dec 11, 2023
1 parent e941560 commit 9b6664c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,25 @@ void disable(@Context Viewer viewer, @Context CommandSender sender) {
}

@Execute(name = "slowmode")
@DescriptionDocs(description = "Sets slowmode for chat", arguments = "<time>")
@DescriptionDocs(description = "Sets SlowMode for chat", arguments = "<time>")
void slowmode(@Context Viewer viewer, @Arg Duration duration) {
if (duration.isNegative()) {
this.noticeService.viewer(viewer, translation -> translation.argument().numberBiggerThanOrEqualZero());

return;
}

if (duration.isZero()) {
this.noticeService.create()
.notice(translation -> translation.chat().slowModeOff())
.placeholder("{PLAYER}", viewer.getName())
.viewer(viewer)
.send();

this.chatManager.getChatSettings().setChatDelay(duration);
return;
}

this.chatManager.getChatSettings().setChatDelay(duration);

this.noticeService.create()
Expand All @@ -95,6 +106,13 @@ void slowmode(@Context Viewer viewer, @Arg Duration duration) {
.send();
}

@Execute(name = "slowmode 0")
@DescriptionDocs(description = "Disable SlowMode for chat")
void slowmodeOff(@Context Viewer viewer) {
Duration noSlowMode = Duration.ZERO;
this.slowmode(viewer, noSlowMode);
}

private static Supplier<Notice> create(ChatSettings settings) {
return () -> Notice.chat("<newline>".repeat(Math.max(0, settings.linesToClear())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.bukkit.Material;
import org.bukkit.event.entity.EntityDamageEvent;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -114,6 +113,7 @@ interface ChatSection {
Notice alreadyDisabled();
Notice alreadyEnabled();
Notice slowModeSet();
Notice slowModeOff();
Notice slowMode();
Notice disabledChatInfo();
Notice commandNotFound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ public static class ENChatSection implements ChatSection {
@Description({ " ", "# {SLOWMODE} - Time for next message" })
public Notice slowModeSet = Notice.chat("<green>► <white>Slowmode set to: {SLOWMODE}");

@Description({ " ", "# {PLAYER} - Player who performed the actions for the chat" })
public Notice slowModeOff = Notice.chat("<green>► <white>Slowmode has been disabled by <green>{PLAYER}<white>!");

@Description({ " ", "# {TIME} - Time to next use (cooldown)" })
public Notice slowMode = Notice.chat("<red>✘ <dark_red>You can write the next message for: <red>{TIME}<dark_red>!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public static class PLChatSection implements ChatSection {
@Description({ " ", "# {SLOWMODE} - Czas powolnego wysyłania wiadomości" })
public Notice slowModeSet = Notice.chat("<green>► <white>Tryb powolnego wysyłania został ustawiony na {SLOWMODE}");

@Description({ " ", "# {PLAYER} - Gracz który wyłączył tryb powolnego wysyłania wiadomości" })
public Notice slowModeOff = Notice.chat("<green>► <white>Tryb powolnego wysyłania został wyłączony przez <green>{PLAYER}<white>!");

@Description({ " ", "# {TIME} - Czas powolnego wysyłania wiadomości" })
public Notice slowMode = Notice.chat("<red>✘ <dark_red>Następną wiadomość możesz wysłać za: <red>{TIME}<dark_red>!");

Expand Down

0 comments on commit 9b6664c

Please sign in to comment.