mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 03:35:11 +01:00
Custom date time format support for /<admin> info <player> (#1783)
Fixes #1720
This commit is contained in:
parent
7de6563ece
commit
f88b8d4d6d
@ -1,6 +1,7 @@
|
||||
package world.bentobox.bentobox.database.objects;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
@ -1075,7 +1076,14 @@ public class Island implements DataObject, MetaDataAble {
|
||||
// Fixes #getLastPlayed() returning 0 when it is the owner's first connection.
|
||||
long lastPlayed = (Bukkit.getServer().getOfflinePlayer(getOwner()).getLastPlayed() != 0) ?
|
||||
Bukkit.getServer().getOfflinePlayer(getOwner()).getLastPlayed() : Bukkit.getServer().getOfflinePlayer(getOwner()).getFirstPlayed();
|
||||
user.sendMessage("commands.admin.info.last-login","[date]", new Date(lastPlayed).toString());
|
||||
String formattedDate;
|
||||
try {
|
||||
String dateTimeFormat = plugin.getLocalesManager().get("commands.admin.info.last-login-date-time-format");
|
||||
formattedDate = new SimpleDateFormat(dateTimeFormat).format(new Date(lastPlayed));
|
||||
} catch (NullPointerException | IllegalArgumentException ignored) {
|
||||
formattedDate = new Date(lastPlayed).toString();
|
||||
}
|
||||
user.sendMessage("commands.admin.info.last-login","[date]", formattedDate);
|
||||
|
||||
user.sendMessage("commands.admin.info.deaths", "[number]", String.valueOf(plugin.getPlayers().getDeaths(getWorld(), getOwner())));
|
||||
String resets = String.valueOf(plugin.getPlayers().getResets(getWorld(), getOwner()));
|
||||
|
@ -188,6 +188,7 @@ commands:
|
||||
island-uuid: "UUID: [uuid]"
|
||||
owner: "Owner: [owner] ([uuid])"
|
||||
last-login: "Last login: [date]"
|
||||
last-login-date-time-format: "EEE MMM dd HH:mm:ss zzz yyyy"
|
||||
deaths: "Deaths: [number]"
|
||||
resets-left: "Resets: [number] (Max: [total])"
|
||||
team-members-title: "Team members:"
|
||||
|
Loading…
Reference in New Issue
Block a user