From 2cbafceb496246140459eae04d4c47b7b93e496f Mon Sep 17 00:00:00 2001 From: imDMK Date: Sat, 15 Feb 2025 14:22:03 +0100 Subject: [PATCH 1/9] Add seen feature. --- .../core/feature/seen/SeenCommand.java | 55 +++ .../core/translation/Translation.java | 382 ++++++++++++++---- .../implementation/ENTranslation.java | 17 + .../implementation/PLTranslation.java | 17 + 4 files changed, 402 insertions(+), 69 deletions(-) create mode 100644 eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java new file mode 100644 index 000000000..3423d4df8 --- /dev/null +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java @@ -0,0 +1,55 @@ +package com.eternalcode.core.feature.seen; + +import com.eternalcode.annotations.scan.command.DescriptionDocs; +import com.eternalcode.core.injector.annotations.Inject; +import com.eternalcode.core.notice.NoticeService; +import com.eternalcode.core.user.User; +import com.eternalcode.core.util.DurationUtil; +import dev.rollczi.litecommands.annotations.argument.Arg; +import dev.rollczi.litecommands.annotations.command.Command; +import dev.rollczi.litecommands.annotations.context.Context; +import dev.rollczi.litecommands.annotations.execute.Execute; +import dev.rollczi.litecommands.annotations.permission.Permission; +import org.bukkit.entity.Player; + +import java.time.Duration; +import java.time.Instant; + +@Command(name = "seen") +@Permission("eternalcore.seen") +class SeenCommand { + + private final NoticeService noticeService; + + @Inject + public SeenCommand(NoticeService noticeService) { + this.noticeService = noticeService; + } + + @Execute + @DescriptionDocs(description = "Shows when the player was last seen on the server") + void execute(@Context User sender, @Arg Player target) { + long lastPlayed = target.getLastPlayed(); + + // If the time is 0, it means the player has never joined before, indicating their first join. + if (lastPlayed == 0) { + this.noticeService.create() + .user(sender) + .notice(translation -> translation.seen().firstJoin()) + .placeholder("{PLAYER}", target.getName()) + .send(); + + return; + } + + Duration lastPlayedBetween = Duration.between(Instant.ofEpochMilli(lastPlayed), Instant.now()); + String lastPlayedFormatted = DurationUtil.format(lastPlayedBetween); + + this.noticeService.create() + .user(sender) + .notice(translation -> translation.seen().lastSeen()) + .placeholder("{PLAYER}", target.getName()) + .placeholder("{SEEN}", lastPlayedFormatted) + .send(); + } +} diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java index 975f79937..0fbd21922 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java @@ -1,35 +1,79 @@ package com.eternalcode.core.translation; -import com.eternalcode.core.bridge.litecommand.argument.messages.ArgumentMessages; import com.eternalcode.core.configuration.contextual.ConfigItem; -import com.eternalcode.core.feature.adminchat.messages.AdminChatMessages; -import com.eternalcode.core.feature.afk.messages.AfkMessages; -import com.eternalcode.core.feature.automessage.messages.AutoMessageMessages; -import com.eternalcode.core.feature.itemedit.messages.ItemEditMessages; -import com.eternalcode.core.feature.helpop.messages.HelpOpSection; -import com.eternalcode.core.feature.home.messages.HomeMessages; -import com.eternalcode.core.feature.jail.messages.JailMessages; import com.eternalcode.core.feature.language.Language; -import com.eternalcode.core.feature.privatechat.messages.PrivateChatMessages; -import com.eternalcode.core.feature.randomteleport.messages.RandomTeleportMessages; -import com.eternalcode.core.feature.setslot.messages.SetSlotMessages; -import com.eternalcode.core.feature.spawn.messages.SpawnMessages; -import com.eternalcode.core.feature.sudo.messages.SudoMessages; -import com.eternalcode.core.feature.teleportrequest.messages.TeleportRequestMessages; -import com.eternalcode.core.feature.time.messages.TimeAndWeatherMessages; -import com.eternalcode.core.feature.warp.messages.WarpMessages; +import com.eternalcode.core.feature.warp.WarpInventoryItem; import com.eternalcode.multification.notice.Notice; +import org.bukkit.Material; +import org.bukkit.event.entity.EntityDamageEvent; + +import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; -import org.bukkit.event.entity.EntityDamageEvent; public interface Translation { + Language getLanguage(); + + // argument section + ArgumentSection argument(); + + interface ArgumentSection { + Notice missingPlayerName(); + Notice permissionMessage(); + Notice usageMessage(); + Notice usageMessageHead(); + Notice usageMessageEntry(); + Notice offlinePlayer(); + Notice onlyPlayer(); + Notice numberBiggerThanOrEqualZero(); + Notice noItem(); + Notice noArgument(); + Notice noDamaged(); + Notice noDamagedItems(); + Notice noEnchantment(); + Notice noValidEnchantmentLevel(); + Notice invalidTimeFormat(); + Notice worldDoesntExist(); + Notice incorrectNumberOfChunks(); + Notice incorrectLocation(); + } + + // format section + Format format(); + interface Format { String enable(); String disable(); } + // HelpOp Section + HelpOpSection helpOp(); + + interface HelpOpSection { + Notice format(); + Notice send(); + Notice helpOpDelay(); + } + + // AdminChat Section + AdminChatSection adminChat(); + + interface AdminChatSection { + Notice format(); + } + + SudoSection sudo(); + + interface SudoSection { + Notice sudoMessageSpy(); + Notice sudoMessage(); + } + + // Teleport Section + TeleportSection teleport(); + interface TeleportSection { // teleport Notice teleportedToPlayer(); @@ -57,6 +101,20 @@ interface TeleportSection { Notice teleportedToRandomPlayer(); } + // Random Teleport Section + RandomTeleportSection randomTeleport(); + + interface RandomTeleportSection { + Notice randomTeleportStarted(); + Notice randomTeleportFailed(); + Notice teleportedToRandomLocation(); + Notice teleportedSpecifiedPlayerToRandomLocation(); + Notice randomTeleportDelay(); + } + + // Chat Section + ChatSection chat(); + interface ChatSection { Notice disabled(); Notice enabled(); @@ -76,13 +134,158 @@ interface ChatSection { Notice tellrawMultipleSent(); Notice tellrawCleared(); Notice alertQueueAdded(); - Notice alertQueueRemovedSingle(); - Notice alertQueueRemovedAll(); + Notice alertQueueRemoved(); Notice alertQueueCleared(); Notice alertQueueEmpty(); Notice alertQueueSent(); } + // Warp Section + WarpSection warp(); + + interface WarpSection { + Notice warpAlreadyExists(); + Notice notExist(); + Notice create(); + Notice remove(); + Notice available(); + Notice itemAdded(); + Notice noWarps(); + Notice itemLimit(); + Notice noPermission(); + Notice addPermissions(); + Notice removePermission(); + Notice permissionDoesNotExist(); + Notice permissionAlreadyExist(); + Notice noPermissionsProvided(); + Notice missingWarpArgument(); + Notice missingPermissionArgument(); + + WarpInventorySection warpInventory(); + + interface WarpInventorySection { + String title(); + + Map items(); + void setItems(Map items); + + default void addItem(String name, WarpInventoryItem item) { + Map items = new HashMap<>(this.items()); + items.put(name, item); + + this.setItems(items); + } + + default void removeItem(String name) { + Map items = new HashMap<>(this.items()); + items.remove(name); + + this.setItems(items); + } + + BorderSection border(); + DecorationItemsSection decorationItems(); + + interface BorderSection { + boolean enabled(); + + Material material(); + + FillType fillType(); + + String name(); + + List lore(); + + enum FillType { + TOP, BOTTOM, BORDER, ALL + } + } + + interface DecorationItemsSection { + List items(); + } + } + } + + // Home section + HomeSection home(); + + interface HomeSection { + Notice homeList(); + Notice create(); + Notice delete(); + Notice limit(); + Notice overrideHomeLocation(); + Notice noHomesOwned(); + String noHomesOwnedPlaceholder(); + + Notice overrideHomeLocationAsAdmin(); + Notice playerNoOwnedHomes(); + Notice createAsAdmin(); + Notice deleteAsAdmin(); + Notice homeListAsAdmin(); + } + + // tpa section + TpaSection tpa(); + + interface TpaSection { + Notice tpaSelfMessage(); + Notice tpaAlreadySentMessage(); + Notice tpaSentMessage(); + Notice tpaReceivedMessage(); + Notice tpaTargetIgnoresYou(); + + Notice tpaDenyNoRequestMessage(); + Notice tpaDenyDoneMessage(); + Notice tpaDenyReceivedMessage(); + Notice tpaDenyAllDenied(); + + Notice tpaAcceptMessage(); + Notice tpaAcceptNoRequestMessage(); + Notice tpaAcceptReceivedMessage(); + Notice tpaAcceptAllAccepted(); + } + + // private section + PrivateChatSection privateChat(); + + interface PrivateChatSection { + Notice noReply(); + Notice privateMessageYouToTarget(); + Notice privateMessageTargetToYou(); + + Notice socialSpyMessage(); + Notice socialSpyEnable(); + Notice socialSpyDisable(); + + Notice ignorePlayer(); + Notice ignoreAll(); + Notice unIgnorePlayer(); + Notice unIgnoreAll(); + Notice alreadyIgnorePlayer(); + Notice notIgnorePlayer(); + Notice cantIgnoreYourself(); + Notice cantUnIgnoreYourself(); + } + + // afk section + AfkSection afk(); + + interface AfkSection { + Notice afkOn(); + Notice afkOff(); + Notice afkDelay(); + String afkKickReason(); + + String afkEnabledPlaceholder(); + String afkDisabledPlaceholder(); + } + + // event section + EventSection event(); + interface EventSection { List deathMessage(); List unknownDeathCause(); @@ -95,12 +298,18 @@ interface EventSection { Notice welcome(); } + // inventory section + InventorySection inventory(); + interface InventorySection { Notice inventoryClearMessage(); Notice inventoryClearMessageBy(); String disposalTitle(); } + // player section + PlayerSection player(); + interface PlayerSection { // feed Notice feedMessage(); @@ -159,7 +368,34 @@ interface PlayerSection { Notice safeChunksMessage(); } + // spawn section + SpawnSection spawn(); + + interface SpawnSection { + // spawn + Notice spawnSet(); + Notice spawnNoSet(); + + Notice spawnTeleportedBy(); + Notice spawnTeleportedOther(); + } + + // item section + ItemSection item(); + interface ItemSection { + // item name & lore + Notice itemClearNameMessage(); + Notice itemClearLoreMessage(); + + Notice itemChangeNameMessage(); + Notice itemChangeLoreMessage(); + + // item flags + Notice itemFlagRemovedMessage(); + Notice itemFlagAddedMessage(); + Notice itemFlagClearedMessage(); + // give Notice giveReceived(); Notice giveGiven(); @@ -176,65 +412,73 @@ interface ItemSection { Notice enchantedMessageBy(); } + // time and weather + TimeAndWeatherSection timeAndWeather(); + + interface TimeAndWeatherSection { + Notice timeSetDay(); + Notice timeSetNight(); + + Notice timeSet(); + Notice timeAdd(); + + Notice weatherSetRain(); + Notice weatherSetSun(); + Notice weatherSetThunder(); + } + + // language section + LanguageSection language(); + interface LanguageSection { Notice languageChanged(); List decorationItems(); } + // container section + ContainerSection container(); + interface ContainerSection { Notice genericContainerOpened(); Notice genericContainerOpenedBy(); Notice genericContainerOpenedFor(); } - Language getLanguage(); - // argument section - ArgumentMessages argument(); - // format section - Format format(); - // HelpOp Section - HelpOpSection helpOp(); - // AdminChat Section - AdminChatMessages adminChat(); - SudoMessages sudo(); - // Teleport Section - TeleportSection teleport(); - // Random Teleport Section - RandomTeleportMessages randomTeleport(); - // Chat Section - ChatSection chat(); - // Warp Section - WarpMessages warp(); - // Home section - HomeMessages home(); - // tpa section - TeleportRequestMessages tpa(); - // private section - PrivateChatMessages privateChat(); - // afk section - AfkMessages afk(); - // event section - EventSection event(); - // inventory section - InventorySection inventory(); - // player section - PlayerSection player(); - // spawn section - SpawnMessages spawn(); - // set slot section - SetSlotMessages setSlot(); - // item section - ItemSection item(); - // itemedit - ItemEditMessages itemEdit(); - // time and weather - TimeAndWeatherMessages timeAndWeather(); - // language section - LanguageSection language(); - // container section - ContainerSection container(); - // auto message section - AutoMessageMessages autoMessage(); - // jail section - JailMessages jailSection(); + + AutoMessageSection autoMessage(); + + interface AutoMessageSection { + Collection messages(); + + Notice enabled(); + Notice disabled(); + } + + JailSection jailSection(); + + interface JailSection { + Notice jailLocationSet(); + Notice jailLocationRemove(); + Notice jailLocationNotSet(); + Notice jailLocationOverride(); + + Notice jailDetainBroadcast(); + Notice jailDetainPrivate(); + Notice jailDetainCountdown(); + Notice jailDetainOverride(); + Notice jailDetainAdmin(); + + Notice jailReleaseBroadcast(); + Notice jailReleasePrivate(); + Notice jailReleaseAll(); + Notice jailReleaseNoPlayers(); + Notice jailIsNotPrisoner(); + + Notice jailListHeader(); + Notice jailListEmpty(); + Notice jailListPlayerEntry(); + + Notice jailCannotUseCommand(); + } + } diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java index 550579987..757b814b6 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java @@ -131,6 +131,23 @@ public static class ENFormatSection implements Format { }) public ENHelpOpMessages helpOp = new ENHelpOpMessages(); + @Description({ + " ", + "# This section is responsible for the messages of the /seen command" + }) + public ENSeenSection seen = new ENSeenSection(); + + @Getter + @Contextual + public static class ENSeenSection implements SeenSection { + + @Description("# {PLAYER} - The player who is joining the server for the first time") + public Notice firstJoin = Notice.chat("[Seen] {PLAYER} is joining the server for the first time, so there is no last login time."); + + @Description("# {PLAYER} - The player who was last seen on the server, {SEEN} - Time since last login") + public Notice lastSeen = Notice.chat("[Seen] {PLAYER} was last seen {SEEN} ago."); + } + @Description({ " ", "# This section is responsible for the communication between administration", diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java index 09dd4bf93..2af44a06f 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java @@ -140,6 +140,23 @@ public static class PLFormatSection implements Format { }) public PLSudoMessages sudo = new PLSudoMessages(); + @Description({ + " ", + "# Ta sekcja odpowiada za wiadomości komendy /seen" + }) + public PLSeenSection seen = new PLSeenSection(); + + @Getter + @Contextual + public static class PLSeenSection implements SeenSection { + + @Description("# {PLAYER} - Gracz który jest pierwszy raz na serwerze") + public Notice firstJoin = Notice.chat("[Seen] {PLAYER} pierwszy raz jest na serwerze, więc nie ma ostatniego czasu zalogowania."); + + @Description("# {PLAYER} - Gracz który ostatnio był widziany na serwerze, {SEEN} - Czas od ostatniego logowania") + public Notice lastSeen = Notice.chat("[Seen] {PLAYER} był ostatnio widziany {SEEN}."); + } + @Description({ " ", "# Ta sekcja odpowiada za komunikaty związane z teleportacją", From ca9098cf29acaa317c6a69b7135e540731962843 Mon Sep 17 00:00:00 2001 From: imDMK Date: Sat, 15 Feb 2025 15:06:13 +0100 Subject: [PATCH 2/9] Improvements. --- .../core/feature/seen/SeenCommand.java | 29 ++++++++++++++----- .../implementation/ENTranslation.java | 7 +++-- .../implementation/PLTranslation.java | 9 ++++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java index 3423d4df8..eb8a9e6c1 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java @@ -10,7 +10,8 @@ import dev.rollczi.litecommands.annotations.context.Context; import dev.rollczi.litecommands.annotations.execute.Execute; import dev.rollczi.litecommands.annotations.permission.Permission; -import org.bukkit.entity.Player; +import org.bukkit.OfflinePlayer; +import org.bukkit.Server; import java.time.Duration; import java.time.Instant; @@ -19,23 +20,37 @@ @Permission("eternalcore.seen") class SeenCommand { + private final Server server; private final NoticeService noticeService; @Inject - public SeenCommand(NoticeService noticeService) { + public SeenCommand(Server server, NoticeService noticeService) { + this.server = server; this.noticeService = noticeService; } @Execute @DescriptionDocs(description = "Shows when the player was last seen on the server") - void execute(@Context User sender, @Arg Player target) { - long lastPlayed = target.getLastPlayed(); + void execute(@Context User sender, @Arg User target) { + OfflinePlayer targetPlayer = this.server.getOfflinePlayer(target.getUniqueId()); - // If the time is 0, it means the player has never joined before, indicating their first join. + if (targetPlayer.isOnline()) { + this.noticeService.create() + .user(sender) + .notice(translation -> translation.seen().nowOnline()) + .placeholder("{PLAYER}", target.getName()) + .send(); + + return; + } + + long lastPlayed = targetPlayer.getLastPlayed(); + + // If the time is 0, it means the player has never joined before if (lastPlayed == 0) { this.noticeService.create() .user(sender) - .notice(translation -> translation.seen().firstJoin()) + .notice(translation -> translation.seen().neverPlayedBefore()) .placeholder("{PLAYER}", target.getName()) .send(); @@ -43,7 +58,7 @@ void execute(@Context User sender, @Arg Player target) { } Duration lastPlayedBetween = Duration.between(Instant.ofEpochMilli(lastPlayed), Instant.now()); - String lastPlayedFormatted = DurationUtil.format(lastPlayedBetween); + String lastPlayedFormatted = DurationUtil.format(lastPlayedBetween, true); this.noticeService.create() .user(sender) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java index 757b814b6..fdf6695d5 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java @@ -141,11 +141,14 @@ public static class ENFormatSection implements Format { @Contextual public static class ENSeenSection implements SeenSection { - @Description("# {PLAYER} - The player who is joining the server for the first time") - public Notice firstJoin = Notice.chat("[Seen] {PLAYER} is joining the server for the first time, so there is no last login time."); + @Description("# {PLAYER} - The player who is never played before on the server") + public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} have not played before on this server."); @Description("# {PLAYER} - The player who was last seen on the server, {SEEN} - Time since last login") public Notice lastSeen = Notice.chat("[Seen] {PLAYER} was last seen {SEEN} ago."); + + @Description("# {PLAYER} - The player who is now online") + public Notice nowOnline = Notice.chat("[Seen] {PLAYER} is now online!"); } @Description({ diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java index 2af44a06f..9f471874d 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java @@ -150,11 +150,14 @@ public static class PLFormatSection implements Format { @Contextual public static class PLSeenSection implements SeenSection { - @Description("# {PLAYER} - Gracz który jest pierwszy raz na serwerze") - public Notice firstJoin = Notice.chat("[Seen] {PLAYER} pierwszy raz jest na serwerze, więc nie ma ostatniego czasu zalogowania."); + @Description("# {PLAYER} - Gracz który nigdy nie grał na serwerze") + public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} nie grał nigdy na tym serwerze."); @Description("# {PLAYER} - Gracz który ostatnio był widziany na serwerze, {SEEN} - Czas od ostatniego logowania") - public Notice lastSeen = Notice.chat("[Seen] {PLAYER} był ostatnio widziany {SEEN}."); + public Notice lastSeen = Notice.chat("[Seen] {PLAYER} był ostatnio widziany {SEEN} temu."); + + @Description("# {PLAYER} - Gracz który jest aktualnie online") + public Notice nowOnline = Notice.chat("[Seen] {PLAYER} jest aktualnie online!"); } @Description({ From 183053e3b5a96a415c2f419ffcf1aa4bb394669a Mon Sep 17 00:00:00 2001 From: imDMK Date: Sat, 15 Feb 2025 15:25:33 +0100 Subject: [PATCH 3/9] Fix conflict. --- .../core/translation/Translation.java | 388 ++++-------------- 1 file changed, 76 insertions(+), 312 deletions(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java index 0fbd21922..3c153f530 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java @@ -1,79 +1,35 @@ package com.eternalcode.core.translation; +import com.eternalcode.core.bridge.litecommand.argument.messages.ArgumentMessages; import com.eternalcode.core.configuration.contextual.ConfigItem; +import com.eternalcode.core.feature.adminchat.messages.AdminChatMessages; +import com.eternalcode.core.feature.afk.messages.AfkMessages; +import com.eternalcode.core.feature.automessage.messages.AutoMessageMessages; +import com.eternalcode.core.feature.itemedit.messages.ItemEditMessages; +import com.eternalcode.core.feature.helpop.messages.HelpOpSection; +import com.eternalcode.core.feature.home.messages.HomeMessages; +import com.eternalcode.core.feature.jail.messages.JailMessages; import com.eternalcode.core.feature.language.Language; -import com.eternalcode.core.feature.warp.WarpInventoryItem; +import com.eternalcode.core.feature.privatechat.messages.PrivateChatMessages; +import com.eternalcode.core.feature.randomteleport.messages.RandomTeleportMessages; +import com.eternalcode.core.feature.setslot.messages.SetSlotMessages; +import com.eternalcode.core.feature.spawn.messages.SpawnMessages; +import com.eternalcode.core.feature.sudo.messages.SudoMessages; +import com.eternalcode.core.feature.teleportrequest.messages.TeleportRequestMessages; +import com.eternalcode.core.feature.time.messages.TimeAndWeatherMessages; +import com.eternalcode.core.feature.warp.messages.WarpMessages; import com.eternalcode.multification.notice.Notice; -import org.bukkit.Material; -import org.bukkit.event.entity.EntityDamageEvent; - -import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; +import org.bukkit.event.entity.EntityDamageEvent; public interface Translation { - Language getLanguage(); - - // argument section - ArgumentSection argument(); - - interface ArgumentSection { - Notice missingPlayerName(); - Notice permissionMessage(); - Notice usageMessage(); - Notice usageMessageHead(); - Notice usageMessageEntry(); - Notice offlinePlayer(); - Notice onlyPlayer(); - Notice numberBiggerThanOrEqualZero(); - Notice noItem(); - Notice noArgument(); - Notice noDamaged(); - Notice noDamagedItems(); - Notice noEnchantment(); - Notice noValidEnchantmentLevel(); - Notice invalidTimeFormat(); - Notice worldDoesntExist(); - Notice incorrectNumberOfChunks(); - Notice incorrectLocation(); - } - - // format section - Format format(); - interface Format { String enable(); String disable(); } - // HelpOp Section - HelpOpSection helpOp(); - - interface HelpOpSection { - Notice format(); - Notice send(); - Notice helpOpDelay(); - } - - // AdminChat Section - AdminChatSection adminChat(); - - interface AdminChatSection { - Notice format(); - } - - SudoSection sudo(); - - interface SudoSection { - Notice sudoMessageSpy(); - Notice sudoMessage(); - } - - // Teleport Section - TeleportSection teleport(); - interface TeleportSection { // teleport Notice teleportedToPlayer(); @@ -101,20 +57,6 @@ interface TeleportSection { Notice teleportedToRandomPlayer(); } - // Random Teleport Section - RandomTeleportSection randomTeleport(); - - interface RandomTeleportSection { - Notice randomTeleportStarted(); - Notice randomTeleportFailed(); - Notice teleportedToRandomLocation(); - Notice teleportedSpecifiedPlayerToRandomLocation(); - Notice randomTeleportDelay(); - } - - // Chat Section - ChatSection chat(); - interface ChatSection { Notice disabled(); Notice enabled(); @@ -134,158 +76,13 @@ interface ChatSection { Notice tellrawMultipleSent(); Notice tellrawCleared(); Notice alertQueueAdded(); - Notice alertQueueRemoved(); + Notice alertQueueRemovedSingle(); + Notice alertQueueRemovedAll(); Notice alertQueueCleared(); Notice alertQueueEmpty(); Notice alertQueueSent(); } - // Warp Section - WarpSection warp(); - - interface WarpSection { - Notice warpAlreadyExists(); - Notice notExist(); - Notice create(); - Notice remove(); - Notice available(); - Notice itemAdded(); - Notice noWarps(); - Notice itemLimit(); - Notice noPermission(); - Notice addPermissions(); - Notice removePermission(); - Notice permissionDoesNotExist(); - Notice permissionAlreadyExist(); - Notice noPermissionsProvided(); - Notice missingWarpArgument(); - Notice missingPermissionArgument(); - - WarpInventorySection warpInventory(); - - interface WarpInventorySection { - String title(); - - Map items(); - void setItems(Map items); - - default void addItem(String name, WarpInventoryItem item) { - Map items = new HashMap<>(this.items()); - items.put(name, item); - - this.setItems(items); - } - - default void removeItem(String name) { - Map items = new HashMap<>(this.items()); - items.remove(name); - - this.setItems(items); - } - - BorderSection border(); - DecorationItemsSection decorationItems(); - - interface BorderSection { - boolean enabled(); - - Material material(); - - FillType fillType(); - - String name(); - - List lore(); - - enum FillType { - TOP, BOTTOM, BORDER, ALL - } - } - - interface DecorationItemsSection { - List items(); - } - } - } - - // Home section - HomeSection home(); - - interface HomeSection { - Notice homeList(); - Notice create(); - Notice delete(); - Notice limit(); - Notice overrideHomeLocation(); - Notice noHomesOwned(); - String noHomesOwnedPlaceholder(); - - Notice overrideHomeLocationAsAdmin(); - Notice playerNoOwnedHomes(); - Notice createAsAdmin(); - Notice deleteAsAdmin(); - Notice homeListAsAdmin(); - } - - // tpa section - TpaSection tpa(); - - interface TpaSection { - Notice tpaSelfMessage(); - Notice tpaAlreadySentMessage(); - Notice tpaSentMessage(); - Notice tpaReceivedMessage(); - Notice tpaTargetIgnoresYou(); - - Notice tpaDenyNoRequestMessage(); - Notice tpaDenyDoneMessage(); - Notice tpaDenyReceivedMessage(); - Notice tpaDenyAllDenied(); - - Notice tpaAcceptMessage(); - Notice tpaAcceptNoRequestMessage(); - Notice tpaAcceptReceivedMessage(); - Notice tpaAcceptAllAccepted(); - } - - // private section - PrivateChatSection privateChat(); - - interface PrivateChatSection { - Notice noReply(); - Notice privateMessageYouToTarget(); - Notice privateMessageTargetToYou(); - - Notice socialSpyMessage(); - Notice socialSpyEnable(); - Notice socialSpyDisable(); - - Notice ignorePlayer(); - Notice ignoreAll(); - Notice unIgnorePlayer(); - Notice unIgnoreAll(); - Notice alreadyIgnorePlayer(); - Notice notIgnorePlayer(); - Notice cantIgnoreYourself(); - Notice cantUnIgnoreYourself(); - } - - // afk section - AfkSection afk(); - - interface AfkSection { - Notice afkOn(); - Notice afkOff(); - Notice afkDelay(); - String afkKickReason(); - - String afkEnabledPlaceholder(); - String afkDisabledPlaceholder(); - } - - // event section - EventSection event(); - interface EventSection { List deathMessage(); List unknownDeathCause(); @@ -298,17 +95,17 @@ interface EventSection { Notice welcome(); } - // inventory section - InventorySection inventory(); - interface InventorySection { Notice inventoryClearMessage(); Notice inventoryClearMessageBy(); String disposalTitle(); } - // player section - PlayerSection player(); + interface SeenSection { + Notice neverPlayedBefore(); + Notice lastSeen(); + Notice nowOnline(); + } interface PlayerSection { // feed @@ -368,34 +165,7 @@ interface PlayerSection { Notice safeChunksMessage(); } - // spawn section - SpawnSection spawn(); - - interface SpawnSection { - // spawn - Notice spawnSet(); - Notice spawnNoSet(); - - Notice spawnTeleportedBy(); - Notice spawnTeleportedOther(); - } - - // item section - ItemSection item(); - interface ItemSection { - // item name & lore - Notice itemClearNameMessage(); - Notice itemClearLoreMessage(); - - Notice itemChangeNameMessage(); - Notice itemChangeLoreMessage(); - - // item flags - Notice itemFlagRemovedMessage(); - Notice itemFlagAddedMessage(); - Notice itemFlagClearedMessage(); - // give Notice giveReceived(); Notice giveGiven(); @@ -412,73 +182,67 @@ interface ItemSection { Notice enchantedMessageBy(); } - // time and weather - TimeAndWeatherSection timeAndWeather(); - - interface TimeAndWeatherSection { - Notice timeSetDay(); - Notice timeSetNight(); - - Notice timeSet(); - Notice timeAdd(); - - Notice weatherSetRain(); - Notice weatherSetSun(); - Notice weatherSetThunder(); - } - - // language section - LanguageSection language(); - interface LanguageSection { Notice languageChanged(); List decorationItems(); } - // container section - ContainerSection container(); - interface ContainerSection { Notice genericContainerOpened(); Notice genericContainerOpenedBy(); Notice genericContainerOpenedFor(); } - - AutoMessageSection autoMessage(); - - interface AutoMessageSection { - Collection messages(); - - Notice enabled(); - Notice disabled(); - } - - JailSection jailSection(); - - interface JailSection { - Notice jailLocationSet(); - Notice jailLocationRemove(); - Notice jailLocationNotSet(); - Notice jailLocationOverride(); - - Notice jailDetainBroadcast(); - Notice jailDetainPrivate(); - Notice jailDetainCountdown(); - Notice jailDetainOverride(); - Notice jailDetainAdmin(); - - Notice jailReleaseBroadcast(); - Notice jailReleasePrivate(); - Notice jailReleaseAll(); - Notice jailReleaseNoPlayers(); - Notice jailIsNotPrisoner(); - - Notice jailListHeader(); - Notice jailListEmpty(); - Notice jailListPlayerEntry(); - - Notice jailCannotUseCommand(); - } - + Language getLanguage(); + // argument section + ArgumentMessages argument(); + // format section + Format format(); + // HelpOp Section + HelpOpSection helpOp(); + // AdminChat Section + AdminChatMessages adminChat(); + SudoMessages sudo(); + // Teleport Section + TeleportSection teleport(); + // Random Teleport Section + RandomTeleportMessages randomTeleport(); + // Chat Section + ChatSection chat(); + // Warp Section + WarpMessages warp(); + // Home section + HomeMessages home(); + // tpa section + TeleportRequestMessages tpa(); + // private section + PrivateChatMessages privateChat(); + // afk section + AfkMessages afk(); + // event section + EventSection event(); + // inventory section + InventorySection inventory(); + // player section + PlayerSection player(); + //Seen section + SeenSection seen(); + // spawn section + SpawnMessages spawn(); + // set slot section + SetSlotMessages setSlot(); + // item section + ItemSection item(); + // itemedit + ItemEditMessages itemEdit(); + // time and weather + TimeAndWeatherMessages timeAndWeather(); + // language section + LanguageSection language(); + // container section + ContainerSection container(); + // auto message section + AutoMessageMessages autoMessage(); + // jail section + JailMessages jailSection(); } From 315762bdb3d9b56a2b776007b18b6ee7667fa64a Mon Sep 17 00:00:00 2001 From: imDMK Date: Sat, 15 Feb 2025 15:35:25 +0100 Subject: [PATCH 4/9] Follow coderabbit review --- .../core/translation/implementation/ENTranslation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java index fdf6695d5..72f0afdb7 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java @@ -142,7 +142,7 @@ public static class ENFormatSection implements Format { public static class ENSeenSection implements SeenSection { @Description("# {PLAYER} - The player who is never played before on the server") - public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} have not played before on this server."); + public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} has not played before on this server."); @Description("# {PLAYER} - The player who was last seen on the server, {SEEN} - Time since last login") public Notice lastSeen = Notice.chat("[Seen] {PLAYER} was last seen {SEEN} ago."); From 412837900b95e6243da4dda54a2fff865af81c69 Mon Sep 17 00:00:00 2001 From: imDMK Date: Sat, 15 Feb 2025 20:15:31 +0100 Subject: [PATCH 5/9] Follow team review. --- .../core/feature/seen/SeenCommand.java | 2 +- .../feature/seen/messages/EnSeenMessages.java | 23 +++++++++++++++++++ .../feature/seen/messages/PLSeenMessages.java | 23 +++++++++++++++++++ .../feature/seen/messages/SeenMessages.java | 11 +++++++++ .../core/translation/Translation.java | 9 ++------ .../implementation/ENTranslation.java | 17 ++------------ .../implementation/PLTranslation.java | 17 ++------------ 7 files changed, 64 insertions(+), 38 deletions(-) create mode 100644 eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java create mode 100644 eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java create mode 100644 eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/SeenMessages.java diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java index eb8a9e6c1..7bad43a69 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java @@ -16,7 +16,7 @@ import java.time.Duration; import java.time.Instant; -@Command(name = "seen") +@Command(name = "seen", aliases = { "lastonline" }) @Permission("eternalcore.seen") class SeenCommand { diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java new file mode 100644 index 000000000..62496d0c9 --- /dev/null +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java @@ -0,0 +1,23 @@ +package com.eternalcode.core.feature.seen.messages; + +import com.eternalcode.multification.notice.Notice; +import lombok.Getter; +import lombok.experimental.Accessors; +import net.dzikoysk.cdn.entity.Contextual; +import net.dzikoysk.cdn.entity.Description; + +@Getter +@Accessors(fluent = true) +@Contextual +public class EnSeenMessages { + + @Description("# {PLAYER} - The player who is never played before on the server") + public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} has not played before on this server."); + + @Description("# {PLAYER} - The player who was last seen on the server, {SEEN} - Time since last login") + public Notice lastSeen = Notice.chat("[Seen] {PLAYER} was last seen {SEEN} ago."); + + @Description("# {PLAYER} - The player who is now online") + public Notice nowOnline = Notice.chat("[Seen] {PLAYER} is now online!"); + +} diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java new file mode 100644 index 000000000..9b0e51d52 --- /dev/null +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java @@ -0,0 +1,23 @@ +package com.eternalcode.core.feature.seen.messages; + +import com.eternalcode.multification.notice.Notice; +import lombok.Getter; +import lombok.experimental.Accessors; +import net.dzikoysk.cdn.entity.Contextual; +import net.dzikoysk.cdn.entity.Description; + +@Getter +@Accessors(fluent = true) +@Contextual +public class PLSeenMessages implements SeenMessages { + + @Description("# {PLAYER} - Gracz który nigdy nie grał na serwerze") + public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} nie grał nigdy na tym serwerze."); + + @Description("# {PLAYER} - Gracz który ostatnio był widziany na serwerze, {SEEN} - Czas od ostatniego logowania") + public Notice lastSeen = Notice.chat("[Seen] {PLAYER} był ostatnio widziany {SEEN} temu."); + + @Description("# {PLAYER} - Gracz który jest aktualnie online") + public Notice nowOnline = Notice.chat("[Seen] {PLAYER} jest aktualnie online!"); + +} diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/SeenMessages.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/SeenMessages.java new file mode 100644 index 000000000..a6814e225 --- /dev/null +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/SeenMessages.java @@ -0,0 +1,11 @@ +package com.eternalcode.core.feature.seen.messages; + +import com.eternalcode.multification.notice.Notice; + +public interface SeenMessages { + + Notice neverPlayedBefore(); + Notice lastSeen(); + Notice nowOnline(); + +} diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java index 3c153f530..ccda6ba7f 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java @@ -12,6 +12,7 @@ import com.eternalcode.core.feature.language.Language; import com.eternalcode.core.feature.privatechat.messages.PrivateChatMessages; import com.eternalcode.core.feature.randomteleport.messages.RandomTeleportMessages; +import com.eternalcode.core.feature.seen.messages.SeenMessages; import com.eternalcode.core.feature.setslot.messages.SetSlotMessages; import com.eternalcode.core.feature.spawn.messages.SpawnMessages; import com.eternalcode.core.feature.sudo.messages.SudoMessages; @@ -101,12 +102,6 @@ interface InventorySection { String disposalTitle(); } - interface SeenSection { - Notice neverPlayedBefore(); - Notice lastSeen(); - Notice nowOnline(); - } - interface PlayerSection { // feed Notice feedMessage(); @@ -226,7 +221,7 @@ interface ContainerSection { // player section PlayerSection player(); //Seen section - SeenSection seen(); + SeenMessages seen(); // spawn section SpawnMessages spawn(); // set slot section diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java index 72f0afdb7..3054f6ee6 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java @@ -10,6 +10,7 @@ import com.eternalcode.core.feature.home.messages.ENHomeMessages; import com.eternalcode.core.feature.jail.messages.ENJailMessages; import com.eternalcode.core.feature.language.Language; +import com.eternalcode.core.feature.seen.messages.EnSeenMessages; import com.eternalcode.core.feature.setslot.messages.ENSetSlotMessages; import com.eternalcode.core.feature.privatechat.messages.ENPrivateMessages; import com.eternalcode.core.feature.randomteleport.messages.ENRandomTeleportMessages; @@ -135,21 +136,7 @@ public static class ENFormatSection implements Format { " ", "# This section is responsible for the messages of the /seen command" }) - public ENSeenSection seen = new ENSeenSection(); - - @Getter - @Contextual - public static class ENSeenSection implements SeenSection { - - @Description("# {PLAYER} - The player who is never played before on the server") - public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} has not played before on this server."); - - @Description("# {PLAYER} - The player who was last seen on the server, {SEEN} - Time since last login") - public Notice lastSeen = Notice.chat("[Seen] {PLAYER} was last seen {SEEN} ago."); - - @Description("# {PLAYER} - The player who is now online") - public Notice nowOnline = Notice.chat("[Seen] {PLAYER} is now online!"); - } + public EnSeenMessages seen = new EnSeenMessages(); @Description({ " ", diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java index 9f471874d..9452dadd1 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java @@ -10,6 +10,7 @@ import com.eternalcode.core.feature.home.messages.PLHomeMessages; import com.eternalcode.core.feature.jail.messages.PLJailMessages; import com.eternalcode.core.feature.language.Language; +import com.eternalcode.core.feature.seen.messages.PLSeenMessages; import com.eternalcode.core.feature.setslot.messages.PLSetSlotMessages; import com.eternalcode.core.feature.privatechat.messages.PLPrivateChatMessages; import com.eternalcode.core.feature.randomteleport.messages.PLRandomTeleportMessages; @@ -144,21 +145,7 @@ public static class PLFormatSection implements Format { " ", "# Ta sekcja odpowiada za wiadomości komendy /seen" }) - public PLSeenSection seen = new PLSeenSection(); - - @Getter - @Contextual - public static class PLSeenSection implements SeenSection { - - @Description("# {PLAYER} - Gracz który nigdy nie grał na serwerze") - public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} nie grał nigdy na tym serwerze."); - - @Description("# {PLAYER} - Gracz który ostatnio był widziany na serwerze, {SEEN} - Czas od ostatniego logowania") - public Notice lastSeen = Notice.chat("[Seen] {PLAYER} był ostatnio widziany {SEEN} temu."); - - @Description("# {PLAYER} - Gracz który jest aktualnie online") - public Notice nowOnline = Notice.chat("[Seen] {PLAYER} jest aktualnie online!"); - } + public PLSeenMessages seen = new PLSeenMessages(); @Description({ " ", From d6202dfdcaee4bd2a7bfaab4ccb71f7ffb43a1d8 Mon Sep 17 00:00:00 2001 From: imDMK Date: Sat, 15 Feb 2025 20:21:52 +0100 Subject: [PATCH 6/9] Fix --- .../eternalcode/core/feature/seen/messages/EnSeenMessages.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java index 62496d0c9..800014009 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java @@ -9,7 +9,7 @@ @Getter @Accessors(fluent = true) @Contextual -public class EnSeenMessages { +public class EnSeenMessages implements SeenMessages { @Description("# {PLAYER} - The player who is never played before on the server") public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} has not played before on this server."); From 1fb059b2738330f1be795e95ab72a8ca7afab4fd Mon Sep 17 00:00:00 2001 From: Martin Sulikowski Date: Sun, 16 Feb 2025 15:00:52 +0100 Subject: [PATCH 7/9] Follow review feedback. --- .../eternalcode/core/feature/seen/SeenCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java index 7bad43a69..ca46ad280 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java @@ -5,6 +5,7 @@ import com.eternalcode.core.notice.NoticeService; import com.eternalcode.core.user.User; import com.eternalcode.core.util.DurationUtil; +import com.eternalcode.core.viewer.Viewer; import dev.rollczi.litecommands.annotations.argument.Arg; import dev.rollczi.litecommands.annotations.command.Command; import dev.rollczi.litecommands.annotations.context.Context; @@ -20,6 +21,7 @@ @Permission("eternalcore.seen") class SeenCommand { + public static final int NEVER_JOINED_BEFORE = 0; private final Server server; private final NoticeService noticeService; @@ -31,12 +33,12 @@ public SeenCommand(Server server, NoticeService noticeService) { @Execute @DescriptionDocs(description = "Shows when the player was last seen on the server") - void execute(@Context User sender, @Arg User target) { + void execute(@Context Viewer sender, @Arg User target) { OfflinePlayer targetPlayer = this.server.getOfflinePlayer(target.getUniqueId()); if (targetPlayer.isOnline()) { this.noticeService.create() - .user(sender) + .viewer(sender) .notice(translation -> translation.seen().nowOnline()) .placeholder("{PLAYER}", target.getName()) .send(); @@ -46,10 +48,9 @@ void execute(@Context User sender, @Arg User target) { long lastPlayed = targetPlayer.getLastPlayed(); - // If the time is 0, it means the player has never joined before - if (lastPlayed == 0) { + if (lastPlayed == NEVER_JOINED_BEFORE) { this.noticeService.create() - .user(sender) + .viewer(sender) .notice(translation -> translation.seen().neverPlayedBefore()) .placeholder("{PLAYER}", target.getName()) .send(); @@ -61,7 +62,7 @@ void execute(@Context User sender, @Arg User target) { String lastPlayedFormatted = DurationUtil.format(lastPlayedBetween, true); this.noticeService.create() - .user(sender) + .viewer(sender) .notice(translation -> translation.seen().lastSeen()) .placeholder("{PLAYER}", target.getName()) .placeholder("{SEEN}", lastPlayedFormatted) From 71b5dca6549869870e40d6ba988f09914df0d076 Mon Sep 17 00:00:00 2001 From: Martin Sulikowski Date: Sun, 16 Feb 2025 15:03:01 +0100 Subject: [PATCH 8/9] Follow other messages files. --- .../messages/{EnSeenMessages.java => ENSeenMessages.java} | 8 ++++---- .../core/feature/seen/messages/PLSeenMessages.java | 6 +++--- .../core/translation/implementation/ENTranslation.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) rename eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/{EnSeenMessages.java => ENSeenMessages.java} (55%) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/ENSeenMessages.java similarity index 55% rename from eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java rename to eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/ENSeenMessages.java index 800014009..3f1eff3aa 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/EnSeenMessages.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/ENSeenMessages.java @@ -9,15 +9,15 @@ @Getter @Accessors(fluent = true) @Contextual -public class EnSeenMessages implements SeenMessages { +public class ENSeenMessages implements SeenMessages { @Description("# {PLAYER} - The player who is never played before on the server") - public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} has not played before on this server."); + public Notice neverPlayedBefore = Notice.chat("{PLAYER} has not played before on this server."); @Description("# {PLAYER} - The player who was last seen on the server, {SEEN} - Time since last login") - public Notice lastSeen = Notice.chat("[Seen] {PLAYER} was last seen {SEEN} ago."); + public Notice lastSeen = Notice.chat("{PLAYER} was last seen {SEEN} ago."); @Description("# {PLAYER} - The player who is now online") - public Notice nowOnline = Notice.chat("[Seen] {PLAYER} is now online!"); + public Notice nowOnline = Notice.chat("{PLAYER} is now online!"); } diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java index 9b0e51d52..abf054ca2 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/messages/PLSeenMessages.java @@ -12,12 +12,12 @@ public class PLSeenMessages implements SeenMessages { @Description("# {PLAYER} - Gracz który nigdy nie grał na serwerze") - public Notice neverPlayedBefore = Notice.chat("[Seen] {PLAYER} nie grał nigdy na tym serwerze."); + public Notice neverPlayedBefore = Notice.chat("{PLAYER} nie grał nigdy na tym serwerze."); @Description("# {PLAYER} - Gracz który ostatnio był widziany na serwerze, {SEEN} - Czas od ostatniego logowania") - public Notice lastSeen = Notice.chat("[Seen] {PLAYER} był ostatnio widziany {SEEN} temu."); + public Notice lastSeen = Notice.chat("{PLAYER} był ostatnio widziany {SEEN} temu."); @Description("# {PLAYER} - Gracz który jest aktualnie online") - public Notice nowOnline = Notice.chat("[Seen] {PLAYER} jest aktualnie online!"); + public Notice nowOnline = Notice.chat("{PLAYER} jest aktualnie online!"); } diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java index 3054f6ee6..a4f1bb9c2 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java @@ -10,7 +10,7 @@ import com.eternalcode.core.feature.home.messages.ENHomeMessages; import com.eternalcode.core.feature.jail.messages.ENJailMessages; import com.eternalcode.core.feature.language.Language; -import com.eternalcode.core.feature.seen.messages.EnSeenMessages; +import com.eternalcode.core.feature.seen.messages.ENSeenMessages; import com.eternalcode.core.feature.setslot.messages.ENSetSlotMessages; import com.eternalcode.core.feature.privatechat.messages.ENPrivateMessages; import com.eternalcode.core.feature.randomteleport.messages.ENRandomTeleportMessages; @@ -136,7 +136,7 @@ public static class ENFormatSection implements Format { " ", "# This section is responsible for the messages of the /seen command" }) - public EnSeenMessages seen = new EnSeenMessages(); + public ENSeenMessages seen = new ENSeenMessages(); @Description({ " ", From 99ad0d5ad38fb34896f4eaa2290e927ce00541ee Mon Sep 17 00:00:00 2001 From: Martin Sulikowski Date: Sun, 16 Feb 2025 15:25:24 +0100 Subject: [PATCH 9/9] Allow use OfflinePlayer. --- .../java/com/eternalcode/core/feature/seen/SeenCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java index ca46ad280..2c1085e32 100644 --- a/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java +++ b/eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java @@ -7,6 +7,7 @@ import com.eternalcode.core.util.DurationUtil; import com.eternalcode.core.viewer.Viewer; import dev.rollczi.litecommands.annotations.argument.Arg; +import dev.rollczi.litecommands.annotations.async.Async; import dev.rollczi.litecommands.annotations.command.Command; import dev.rollczi.litecommands.annotations.context.Context; import dev.rollczi.litecommands.annotations.execute.Execute; @@ -16,6 +17,7 @@ import java.time.Duration; import java.time.Instant; +import org.bukkit.entity.Player; @Command(name = "seen", aliases = { "lastonline" }) @Permission("eternalcore.seen") @@ -33,7 +35,7 @@ public SeenCommand(Server server, NoticeService noticeService) { @Execute @DescriptionDocs(description = "Shows when the player was last seen on the server") - void execute(@Context Viewer sender, @Arg User target) { + void execute(@Context Viewer sender, @Arg @Async OfflinePlayer target) { OfflinePlayer targetPlayer = this.server.getOfflinePlayer(target.getUniqueId()); if (targetPlayer.isOnline()) {