Skip to content

Commit 2ccfad1

Browse files
authored
Add first login date to /seen (#6258)
1 parent 58726fb commit 2ccfad1

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ private void seenOnline(final CommandSource sender, final User user, final boole
113113
sender.sendTl("whoisUuid", user.getBase().getUniqueId().toString());
114114
}
115115

116+
if (sender.isAuthorized("essentials.seen.firstlogin")) {
117+
sender.sendTl("whoisFirstLogin", DateUtil.formatDate(user.getBase().getFirstPlayed(), ess));
118+
}
119+
116120
if (user.isAfk()) {
117121
sender.sendTl("whoisAFK", CommonPlaceholders.trueFalse(sender, true));
118122
}

Essentials/src/main/java/com/earth2me/essentials/utils/DateUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.earth2me.essentials.utils;
22

3+
import net.ess3.api.IEssentials;
34
import net.ess3.api.TranslatableException;
45

6+
import java.text.DateFormat;
57
import java.util.Calendar;
68
import java.util.GregorianCalendar;
79
import java.util.regex.Matcher;
@@ -170,4 +172,11 @@ public static String formatDateDiff(final Calendar fromDate, final Calendar toDa
170172
}
171173
return sb.toString().trim();
172174
}
175+
176+
public static String formatDate(final long date, final IEssentials ess) {
177+
final GregorianCalendar gc = new GregorianCalendar();
178+
gc.setTimeInMillis(date);
179+
final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, ess.getI18n().getCurrentLocale());
180+
return df.format(gc.getTime());
181+
}
173182
}

Essentials/src/main/resources/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,7 @@ whoisPlaytime=<primary> - Playtime\:<reset> {0}
15941594
whoisTempBanned=<primary> - Ban expires\:<reset> {0}
15951595
whoisTop=<primary> \=\=\=\=\=\= WhoIs\:<secondary> {0} <primary>\=\=\=\=\=\=
15961596
whoisUuid=<primary> - UUID\:<reset> {0}
1597+
whoisFirstLogin=<primary> - First login:<reset> {0}
15971598
whoisWhitelist=<primary> - Whitelist\:<reset> {0}
15981599
workbenchCommandDescription=Opens up a workbench.
15991600
workbenchCommandUsage=/<command>

Essentials/src/main/resources/plugin.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,8 @@ permissions:
11581158
description: Allows access to the /seen command with location
11591159
essentials.seen.uuid:
11601160
description: Allows access to the /seen command with UUID
1161+
essentials.seen.firstlogin:
1162+
description: Allows access to the /seen command with first login time
11611163
essentials.seen.whitelist:
11621164
description: Allows access to the /seen command with whitelist status
11631165
essentials.seen.ipsearch:
@@ -1170,6 +1172,7 @@ permissions:
11701172
essentials.seen.ip: true
11711173
essentials.seen.location: true
11721174
essentials.seen.uuid: true
1175+
essentials.seen.firstlogin: true
11731176
essentials.seen.whitelist: true
11741177
essentials.sell:
11751178
description: Allows access to the /sell command

0 commit comments

Comments
 (0)