mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 17:18:40 +01:00
Add Join Address to /plan ingame and placeholders
Adds a %plan_player_join_address% placeholder Affects issues: - Close #3463
This commit is contained in:
parent
9ade3fbf01
commit
9c43287f60
@ -29,6 +29,7 @@ import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.exceptions.ExportException;
|
||||
import com.djrapitops.plan.gathering.domain.GeoInfo;
|
||||
import com.djrapitops.plan.gathering.domain.event.JoinAddress;
|
||||
import com.djrapitops.plan.gathering.importing.ImportSystem;
|
||||
import com.djrapitops.plan.gathering.importing.importers.Importer;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
@ -42,6 +43,7 @@ import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.HelpLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
|
||||
@ -258,12 +260,17 @@ public class DataUtilityCommands {
|
||||
Optional<GeoInfo> mostRecentGeoInfo = new GeoInfoMutator(geoInfo).mostRecent();
|
||||
String geolocation = mostRecentGeoInfo.isPresent() ? mostRecentGeoInfo.get().getGeolocation() : "-";
|
||||
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
|
||||
String latestJoinAddress = sessionsMutator.latestSession()
|
||||
.flatMap(session -> session.getExtraData(JoinAddress.class))
|
||||
.map(JoinAddress::getAddress)
|
||||
.orElse("-");
|
||||
|
||||
String table = locale.getString(CommandLang.HEADER_INSPECT, playerName) + '\n' +
|
||||
locale.getString(CommandLang.INGAME_ACTIVITY_INDEX, activityIndex.getFormattedValue(formatters.decimals()), activityIndex.getGroup()) + '\n' +
|
||||
locale.getString(CommandLang.INGAME_REGISTERED, timestamp.apply(() -> registered)) + '\n' +
|
||||
locale.getString(CommandLang.INGAME_LAST_SEEN, timestamp.apply(() -> lastSeen)) + '\n' +
|
||||
locale.getString(CommandLang.INGAME_GEOLOCATION, geolocation) + '\n' +
|
||||
locale.getString(HtmlLang.TITLE_LATEST_JOIN_ADDRESSES, latestJoinAddress) + '\n' +
|
||||
locale.getString(CommandLang.INGAME_TIMES_KICKED, player.getValue(PlayerKeys.KICK_COUNT).orElse(0)) + '\n' +
|
||||
'\n' +
|
||||
locale.getString(CommandLang.INGAME_PLAYTIME, length.apply(sessionsMutator.toPlaytime())) + '\n' +
|
||||
|
@ -27,6 +27,7 @@ import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.GeoInfo;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.event.JoinAddress;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
@ -157,6 +158,14 @@ public class PlayerPlaceHolders implements Placeholders {
|
||||
.orElse(locale.getString(GenericLang.UNKNOWN))
|
||||
);
|
||||
|
||||
placeholders.register("player_join_address",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.latestSession()
|
||||
.flatMap(session -> session.getExtraData(JoinAddress.class))
|
||||
.map(JoinAddress::getAddress)
|
||||
.orElse(locale.getString(GenericLang.UNKNOWN))
|
||||
);
|
||||
|
||||
registerPlaytimePlaceholders(placeholders, time);
|
||||
registerSessionLengethPlaceholders(placeholders, time);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user