Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
public class ENAdminChatMessages extends OkaeriConfig implements AdminChatMessages {

@Comment({"# {PLAYER} - Player who sent message on adminchat, {TEXT} - message"})
public Notice format = Notice.chat("<dark_gray>[<dark_red>AdminChat<dark_gray>] <red>{PLAYER}<dark_gray>: <white>{TEXT}");
Notice format = Notice.chat("<dark_gray>[<dark_red>AdminChat<dark_gray>] <red>{PLAYER}<dark_gray>: <white>{TEXT}");

public Notice enabled = Notice.chat("<green>► <white>Enabled persistent admin chat!");
Notice enabled = Notice.chat("<green>► <white>Enabled persistent admin chat!");

public Notice disabled = Notice.chat("<green>► <white>Disabled persistent admin chat!");
Notice disabled = Notice.chat("<green>► <white>Disabled persistent admin chat!");

public Notice enabledReminder = Notice.actionbar("<green>AdminChat channel is enabled!");
Notice enabledReminder = Notice.actionbar("<green>AdminChat channel is enabled!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
public class PLAdminChatMessages extends OkaeriConfig implements AdminChatMessages {

@Comment({"# {PLAYER} - Gracz który wysłał wiadomość na czacie administracji, {TEXT} - Treść wysłanej wiadomości"})
public Notice format = Notice.chat("<dark_gray>[<dark_red>Administracja<dark_gray>] <red>{PLAYER}<dark_gray>: <white>{TEXT}");
Notice format = Notice.chat("<dark_gray>[<dark_red>Administracja<dark_gray>] <red>{PLAYER}<dark_gray>: <white>{TEXT}");

public Notice enabled = Notice.chat("<green>► <white>Włączono trwały czat administracji!");
Notice enabled = Notice.chat("<green>► <white>Włączono trwały czat administracji!");

public Notice disabled = Notice.chat("<green>► <white>Wyłączono trwały czat administracji!");
Notice disabled = Notice.chat("<green>► <white>Wyłączono trwały czat administracji!");

public Notice enabledReminder = Notice.actionbar("<green> Trwały czat administracji jest włączony!");
Notice enabledReminder = Notice.actionbar("<green> Trwały czat administracji jest włączony!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
public class ENAfkMessages extends OkaeriConfig implements AfkMessages {

@Comment("# {PLAYER} - Player who is in AFK")
public Notice afkOn = Notice.chat("<green>► <white>{PLAYER} is AFK!");
public Notice afkOff = Notice.chat("<green>► <white>{PLAYER} is no more AFK!");
Notice afkOn = Notice.chat("<green>► <white>{PLAYER} is AFK!");
Notice afkOff = Notice.chat("<green>► <white>{PLAYER} is no more AFK!");

@Comment({" ", "# {TIME} - Time after the player can execute the command."})
public Notice afkDelay = Notice.chat("<red>► <dark_red>You can use this command only after <red>{TIME}!");
Notice afkDelay = Notice.chat("<red>► <dark_red>You can use this command only after <red>{TIME}!");

@Comment({" "})
public String afkKickReason = "<red>You have been kicked due to inactivity!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class ENAutoMessageMessages extends OkaeriConfig implements AutoMessageMe
.build()
);

public Notice enabled = Notice.chat("<green>► <white>Enabled auto messages!");
public Notice disabled = Notice.chat("<green>► <white>Disabled auto messages!");
Notice enabled = Notice.chat("<green>► <white>Enabled auto messages!");
Notice disabled = Notice.chat("<green>► <white>Disabled auto messages!");

@Override
public Collection<Notice> messages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ void executeChat(@Flag("-raw") boolean raw, @Join String text) {
}

@Execute(name = "title")
@DescriptionDocs(description = "Broadcasts a TITLE message to all players.", arguments = "[-raw] <text>")
void executeTitle(@Flag("-raw") boolean raw, @Join String title) {
this.sendBroadcast(formatted -> Notice.title(formatted, "", this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()), title, raw);
}
@DescriptionDocs(description = "Broadcasts a combined title message to all players.", arguments = "[-raw] <text>")
void executeTitle(@Flag("-raw") boolean raw, @Join String text) {

@Execute(name = "subtitle")
@DescriptionDocs(description = "Broadcasts a SUBTITLE message to all players.", arguments = "[-raw] <text>")
void executeSubtitle(@Flag("-raw") boolean raw, @Join String subtitle) {
this.sendBroadcast(formatted -> Notice.title("", formatted, this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()), subtitle, raw);
this.noticeService.create()
.notice(translation -> Notice.title(raw ? " " : translation.broadcast().messageFormat(), text,
this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()))
.onlinePlayers()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

te zmiany na pewno są do tego PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jeszcze widzę parę usuniętych plików

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oj przez przypadek się połączyły poprawie to ;)

.send();
Comment on lines +41 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The new implementation of executeTitle seems to have a few issues:

  1. Placeholder Not Replaced: The title is set from translation.broadcast().messageFormat() when not in raw mode. This format string likely contains placeholders like {BROADCAST} which are not being replaced. This will result in players seeing the literal placeholder string.
  2. Unclear Functionality: The command has been changed to broadcast a "combined title message", and executeSubtitle has been removed. However, the implementation always uses the input text as the subtitle, and the title is either a space or the unformatted format string. This is a confusing and likely incorrect behavior. It's also a breaking change that isn't documented in the PR description.

If the intention is for this command to now broadcast a subtitle (as executeSubtitle was removed), you could reuse the sendBroadcast helper method which correctly handles placeholder replacement.

Here is a suggested implementation that would make /broadcast title behave like the old /broadcast subtitle:

Suggested change
this.noticeService.create()
.notice(translation -> Notice.title(raw ? " " : translation.broadcast().messageFormat(), text,
this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()))
.onlinePlayers()
.send();
this.sendBroadcast(
formatted -> Notice.title("", formatted, this.settings.titleFadeIn(), this.settings.titleStay(), this.settings.titleFadeOut()),
text,
raw
);

}

@Execute(name = "actionbar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public class ENBurnMessages extends OkaeriConfig implements BurnMessages {

@Comment("# Available placeholders: {PLAYER} - burned player, {TICKS} - number of ticks the player is on fire")
public Notice burnedSelf = Notice.chat("<green>► <white>You have been set on fire for <green>{TICKS}<white> ticks!");
Notice burnedSelf = Notice.chat("<green>► <white>You have been set on fire for <green>{TICKS}<white> ticks!");

@Comment(" ")
public Notice burnedOther = Notice.chat("<green>► {PLAYER} <white>has been set on fire for <green>{TICKS} <white>ticks!");
Notice burnedOther = Notice.chat("<green>► {PLAYER} <white>has been set on fire for <green>{TICKS} <white>ticks!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.eternalcode.core.feature.chat.ChatManagerController.CHAT_SLOWMODE_BYPASS_PERMISSION;

import com.eternalcode.annotations.scan.permission.PermissionDocs;
import com.eternalcode.core.configuration.implementation.PluginConfiguration;
import com.eternalcode.core.event.EventCaller;
import com.eternalcode.core.feature.chat.event.restrict.ChatRestrictCause;
import com.eternalcode.core.feature.chat.event.restrict.ChatRestrictEvent;
Expand All @@ -13,6 +14,8 @@
import com.eternalcode.core.util.DurationUtil;
import java.time.Duration;
import java.util.UUID;

import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -34,18 +37,24 @@ class ChatManagerController implements Listener {
private final ChatSettings chatSettings;
private final NoticeService noticeService;
private final EventCaller eventCaller;
private final PluginConfiguration config;
private final Server server;

@Inject
ChatManagerController(
ChatService chatService,
ChatSettings chatSettings,
NoticeService noticeService,
EventCaller eventCaller
EventCaller eventCaller,
PluginConfiguration config,
Server server
) {
this.chatService = chatService;
this.chatSettings = chatSettings;
this.noticeService = noticeService;
this.eventCaller = eventCaller;
this.config = config;
this.server = server;
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
Expand Down Expand Up @@ -90,4 +99,21 @@ void onChatSlowMode(AsyncPlayerChatEvent event) {
void markUseChat(AsyncPlayerChatEvent event) {
this.chatService.markUseChat(event.getPlayer().getUniqueId());
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
void sendSound(AsyncPlayerChatEvent event) {
PluginConfiguration.Sounds sound = this.config.sound;

if (!sound.enableAfterChatMessage) {
return;
}

if (!this.chatSettings.chatEnabled()) {
return;
}

for (Player online : this.server.getOnlinePlayers()) {
online.playSound(online.getLocation(), sound.afterChatMessage, sound.afterChatMessageVolume, sound.afterChatMessagePitch);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Accessors(fluent = true)
public class ENClearMessages extends OkaeriConfig implements ClearMessages {

public Notice inventoryCleared = Notice.chat("<green>► <white>Your inventory has been cleared");
public Notice targetInventoryCleared = Notice.chat("<green>► <white>Player inventory: <green>{PLAYER} <white>has been cleared");
Notice inventoryCleared = Notice.chat("<green>► <white>Your inventory has been cleared");
Notice targetInventoryCleared = Notice.chat("<green>► <white>Player inventory: <green>{PLAYER} <white>has been cleared");

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@
@Accessors(fluent = true)
public class ENContainerMessages extends OkaeriConfig implements ContainerMessages {

public Notice anvilOpened = Notice.chat("<green>► <white>Anvil opened!");
public Notice targetAnvilOpened = Notice.chat("<green>► <white>Opened an anvil for {PLAYER}!");
Notice anvilOpened = Notice.chat("<green>► <white>Anvil opened!");
Notice targetAnvilOpened = Notice.chat("<green>► <white>Opened an anvil for {PLAYER}!");

public Notice cartographyOpened = Notice.chat("<green>► <white>Cartography table opened!");
public Notice targetCartographyOpened = Notice.chat("<green>► <white>Opened a cartography table for {PLAYER}!");
Notice cartographyOpened = Notice.chat("<green>► <white>Cartography table opened!");
Notice targetCartographyOpened = Notice.chat("<green>► <white>Opened a cartography table for {PLAYER}!");

public Notice disposalOpened = Notice.chat("<green>► <white>Disposal opened!");
public Notice targetDisposalOpened = Notice.chat("<green>► <white>Opened a disposal for {PLAYER}!");
Notice disposalOpened = Notice.chat("<green>► <white>Disposal opened!");
Notice targetDisposalOpened = Notice.chat("<green>► <white>Opened a disposal for {PLAYER}!");

public Notice enderchestOpened = Notice.chat("<green>► <white>Ender chest opened!");
public Notice targetEnderchestOpened = Notice.chat("<green>► <white>Opened an ender chest for {PLAYER}!");
Notice enderchestOpened = Notice.chat("<green>► <white>Ender chest opened!");
Notice targetEnderchestOpened = Notice.chat("<green>► <white>Opened an ender chest for {PLAYER}!");

public Notice grindstoneOpened = Notice.chat("<green>► <white>Grindstone opened!");
public Notice targetGrindstoneOpened = Notice.chat("<green>► <white>Opened a grindstone for {PLAYER}!");
Notice grindstoneOpened = Notice.chat("<green>► <white>Grindstone opened!");
Notice targetGrindstoneOpened = Notice.chat("<green>► <white>Opened a grindstone for {PLAYER}!");

public Notice loomOpened = Notice.chat("<green>► <white>Loom opened!");
public Notice targetLoomOpened = Notice.chat("<green>► <white>Opened a loom for {PLAYER}!");
Notice loomOpened = Notice.chat("<green>► <white>Loom opened!");
Notice targetLoomOpened = Notice.chat("<green>► <white>Opened a loom for {PLAYER}!");

public Notice smithingOpened = Notice.chat("<green>► <white>Smithing table opened!");
public Notice targetSmithingOpened = Notice.chat("<green>► <white>Opened a smithing table for {PLAYER}!");
Notice smithingOpened = Notice.chat("<green>► <white>Smithing table opened!");
Notice targetSmithingOpened = Notice.chat("<green>► <white>Opened a smithing table for {PLAYER}!");

public Notice stonecutterOpened = Notice.chat("<green>► <white>Stonecutter opened!");
public Notice targetStonecutterOpened = Notice.chat("<green>► <white>Opened a stonecutter for {PLAYER}!");
Notice stonecutterOpened = Notice.chat("<green>► <white>Stonecutter opened!");
Notice targetStonecutterOpened = Notice.chat("<green>► <white>Opened a stonecutter for {PLAYER}!");

public Notice workbenchOpened = Notice.chat("<green>► <white>Workbench opened!");
public Notice targetWorkbenchOpened = Notice.chat("<green>► <white>Opened a workbench for {PLAYER}!");
Notice workbenchOpened = Notice.chat("<green>► <white>Workbench opened!");
Notice targetWorkbenchOpened = Notice.chat("<green>► <white>Opened a workbench for {PLAYER}!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
@Accessors(fluent = true)
public class ENFreezeMessages extends OkaeriConfig implements FreezeMessages {

public Notice frozenSelf = Notice.chat("<green>► <white>You have frozen yourself for <green>{DURATION}</green>!</white>");
Notice frozenSelf = Notice.chat("<green>► <white>You have frozen yourself for <green>{DURATION}</green>!</white>");

public Notice unfrozenSelf = Notice.chat("<green>► <white>You have unfrozen yourself!</white>");
Notice unfrozenSelf = Notice.chat("<green>► <white>You have unfrozen yourself!</white>");

public Notice frozenOther = Notice.chat("<green>► <white>You have frozen player <green>{PLAYER}</green> for <green>{DURATION}</green>!</white>");
Notice frozenOther = Notice.chat("<green>► <white>You have frozen player <green>{PLAYER}</green> for <green>{DURATION}</green>!</white>");

public Notice unfrozenOther = Notice.chat("<green>► <white>You have unfrozen player <green>{PLAYER}</green>!</white>");
Notice unfrozenOther = Notice.chat("<green>► <white>You have unfrozen player <green>{PLAYER}</green>!</white>");

public Notice frozenByOther = Notice.chat("<green>► <white>You have been frozen by player <green>{PLAYER}</green> for <green>{DURATION}</green>!</white>");
Notice frozenByOther = Notice.chat("<green>► <white>You have been frozen by player <green>{PLAYER}</green> for <green>{DURATION}</green>!</white>");

public Notice unfrozenByOther = Notice.chat("<green>► <white>You have been unfrozen by player <green>{PLAYER}</green>!</white>");
Notice unfrozenByOther = Notice.chat("<green>► <white>You have been unfrozen by player <green>{PLAYER}</green>!</white>");

public Notice selfNotFrozen = Notice.chat("<red>► <dark_red>You are not frozen!</dark_red>");
Notice selfNotFrozen = Notice.chat("<red>► <dark_red>You are not frozen!</dark_red>");

public Notice otherNotFrozen = Notice.chat("<red>► <dark_red>Player <red>{PLAYER}</red> is not frozen!</dark_red>");
Notice otherNotFrozen = Notice.chat("<red>► <dark_red>Player <red>{PLAYER}</red> is not frozen!</dark_red>");
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

public class ENDemoScreenMessages extends OkaeriConfig implements DemoScreenMessages {

public Notice shownToSelf = Notice.chat("<green>► <white>You have shown the demo screen to yourself!");
public Notice shownToOtherPlayer = Notice.chat("<green>► <white>You have shown the demo screen to player <green>{PLAYER}!");
Notice shownToSelf = Notice.chat("<green>► <white>You have shown the demo screen to yourself!");
Notice shownToOtherPlayer = Notice.chat("<green>► <white>You have shown the demo screen to player <green>{PLAYER}!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@Accessors(fluent = true)
public class ENElderGuardianMessages extends OkaeriConfig implements ElderGuardianMessages {

public Notice elderGuardianShown =
Notice elderGuardianShown =
Notice.chat("<green>► <white>Shown elder guardian to player <green>{PLAYER}<white>!");
public Notice elderGuardianShownSilently =
Notice elderGuardianShownSilently =
Notice.chat("<green>► <white>Shown elder guardian to player <green>{PLAYER}<white> silently!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

public class ENEndScreenMessages extends OkaeriConfig implements EndScreenMessages {

public Notice shownToSelf = Notice.chat("<green>► <white>You have shown the end screen to yourself!</white>");
Notice shownToSelf = Notice.chat("<green>► <white>You have shown the end screen to yourself!</white>");

@Comment("# {PLAYER} - returns player's name")
public Notice shownToOtherPlayer = Notice.chat("<green>► <white>You have shown the end screen to player <green>{PLAYER}!</green>");
Notice shownToOtherPlayer = Notice.chat("<green>► <white>You have shown the end screen to player <green>{PLAYER}!</green>");
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
@Accessors(fluent = true)
public class ENHelpOpMessages extends OkaeriConfig implements HelpOpSection {
@Comment("# {PLAYER} - Player who send message on /helpop, {TEXT} - message")
public Notice format =
Notice format =
Notice.chat("<dark_gray>[<dark_red>HelpOp<dark_gray>] <yellow>{PLAYER}<dark_gray>: <white>{TEXT}");
@Comment(" ")
public Notice send = Notice.chat("<green>► <white>This message has been successfully sent to administration");
Notice send = Notice.chat("<green>► <white>This message has been successfully sent to administration");
@Comment("# {TIME} - Time to next use (cooldown)")
public Notice helpOpDelay = Notice.chat("<gold>✘ <red>You can use this command for: <gold>{TIME}");
Notice helpOpDelay = Notice.chat("<gold>✘ <red>You can use this command for: <gold>{TIME}");
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
@Accessors(fluent = true)
public class PLHelpOpMessages extends OkaeriConfig implements HelpOpSection {
@Comment({"# {PLAYER} - Gracz który wysłał wiadomość na helpop, {TEXT} - Treść wysłanej wiadomości"})
public Notice format =
Notice format =
Notice.chat("<dark_gray>[<dark_red>HelpOp<dark_gray>] <yellow>{PLAYER}<white>: <white>{TEXT}");
@Comment(" ")
public Notice send = Notice.chat("<green>► <white>Wiadomość została wysłana do administracji");
Notice send = Notice.chat("<green>► <white>Wiadomość została wysłana do administracji");
@Comment("# {TIME} - Czas do końca blokady (cooldown)")
public Notice helpOpDelay = Notice.chat("<white>► <red>Możesz użyć tej komendy dopiero za <gold>{TIME}!");
Notice helpOpDelay = Notice.chat("<white>► <red>Możesz użyć tej komendy dopiero za <gold>{TIME}!");
}
Loading