Skip to content

Commit 1fb059b

Browse files
committed
Follow review feedback.
1 parent d6202df commit 1fb059b

File tree

1 file changed

+7
-6
lines changed
  • eternalcore-core/src/main/java/com/eternalcode/core/feature/seen

1 file changed

+7
-6
lines changed

eternalcore-core/src/main/java/com/eternalcode/core/feature/seen/SeenCommand.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.eternalcode.core.notice.NoticeService;
66
import com.eternalcode.core.user.User;
77
import com.eternalcode.core.util.DurationUtil;
8+
import com.eternalcode.core.viewer.Viewer;
89
import dev.rollczi.litecommands.annotations.argument.Arg;
910
import dev.rollczi.litecommands.annotations.command.Command;
1011
import dev.rollczi.litecommands.annotations.context.Context;
@@ -20,6 +21,7 @@
2021
@Permission("eternalcore.seen")
2122
class SeenCommand {
2223

24+
public static final int NEVER_JOINED_BEFORE = 0;
2325
private final Server server;
2426
private final NoticeService noticeService;
2527

@@ -31,12 +33,12 @@ public SeenCommand(Server server, NoticeService noticeService) {
3133

3234
@Execute
3335
@DescriptionDocs(description = "Shows when the player was last seen on the server")
34-
void execute(@Context User sender, @Arg User target) {
36+
void execute(@Context Viewer sender, @Arg User target) {
3537
OfflinePlayer targetPlayer = this.server.getOfflinePlayer(target.getUniqueId());
3638

3739
if (targetPlayer.isOnline()) {
3840
this.noticeService.create()
39-
.user(sender)
41+
.viewer(sender)
4042
.notice(translation -> translation.seen().nowOnline())
4143
.placeholder("{PLAYER}", target.getName())
4244
.send();
@@ -46,10 +48,9 @@ void execute(@Context User sender, @Arg User target) {
4648

4749
long lastPlayed = targetPlayer.getLastPlayed();
4850

49-
// If the time is 0, it means the player has never joined before
50-
if (lastPlayed == 0) {
51+
if (lastPlayed == NEVER_JOINED_BEFORE) {
5152
this.noticeService.create()
52-
.user(sender)
53+
.viewer(sender)
5354
.notice(translation -> translation.seen().neverPlayedBefore())
5455
.placeholder("{PLAYER}", target.getName())
5556
.send();
@@ -61,7 +62,7 @@ void execute(@Context User sender, @Arg User target) {
6162
String lastPlayedFormatted = DurationUtil.format(lastPlayedBetween, true);
6263

6364
this.noticeService.create()
64-
.user(sender)
65+
.viewer(sender)
6566
.notice(translation -> translation.seen().lastSeen())
6667
.placeholder("{PLAYER}", target.getName())
6768
.placeholder("{SEEN}", lastPlayedFormatted)

0 commit comments

Comments
 (0)