diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/importing/importers/BukkitImporter.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/importing/importers/BukkitImporter.java index 188152b00..be302b93c 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/importing/importers/BukkitImporter.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/importing/importers/BukkitImporter.java @@ -177,8 +177,9 @@ public abstract class BukkitImporter implements Importer { long registered = userImportData.getRegistered(); boolean op = userImportData.isOp(); boolean banned = userImportData.isBanned(); + String hostname = userImportData.getHostname(); - return new UserInfo(uuid, serverUUID.get(), registered, op, banned); + return new UserInfo(uuid, serverUUID.get(), registered, op, hostname, banned); } private Session toSession(UserImportData userImportData) { diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java index 839731f76..18152ae14 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java @@ -155,6 +155,7 @@ public class PlayerOnlineListener implements Listener { String world = player.getWorld().getName(); String gm = player.getGameMode().name(); + String hostname = player.getAddress().getHostName(); Database database = dbSystem.getDatabase(); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world)); @@ -171,7 +172,9 @@ public class PlayerOnlineListener implements Listener { ); } - database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, player::getFirstPlayed, playerName, serverUUID)); + database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, + player::getFirstPlayed, playerName, serverUUID, hostname)); + Session session = new Session(playerUUID, serverUUID, time, world, gm); session.putRawData(SessionKeys.NAME, playerName); session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName()); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java index 6279cb09f..2ed5e374a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java @@ -125,6 +125,7 @@ public class NetworkPageExporter extends FileExporter { "graph?type=uniqueAndNew", "graph?type=hourlyUniqueAndNew", "graph?type=serverPie", + "graph?type=hostnamePie", "graph?type=activity", "graph?type=geolocation", "graph?type=uniqueAndNew", diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java index dc40f3e42..3579ab578 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java @@ -71,6 +71,7 @@ public class Contributors { new Contributor("galexrt", LANG), new Contributor("QuakyCZ", LANG), new Contributor("MrFriggo", LANG), + new Contributor("vacoup", CODE), }; private Contributors() { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/GraphJSONCreator.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/GraphJSONCreator.java index ad735cd91..78dee0b47 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/GraphJSONCreator.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/GraphJSONCreator.java @@ -405,4 +405,14 @@ public class GraphJSONCreator { .put("server_pie_series_30d", graphs.pie().serverPreferencePie(playtimePerServer).getSlices()) .build(); } + + public Map playerHostnamePieJSONAsMap() { + String[] pieColors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE); + Map hostnameResults = dbSystem.getDatabase().query(UserInfoQueries.hostnameTotals()); + + return Maps.builder(String.class, Object.class) + .put("hostname_pie_colors", pieColors) + .put("hostname_pie_slices", graphs.pie().HostnamePie(hostnameResults).getSlices()) + .build(); + } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/HostnamePie.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/HostnamePie.java new file mode 100644 index 000000000..7a6141eca --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/HostnamePie.java @@ -0,0 +1,38 @@ +/* + * This file is part of Player Analytics (Plan). + * + * Plan is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License v3 as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Plan is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Plan. If not, see . + */ +package com.djrapitops.plan.delivery.rendering.json.graphs.pie; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class HostnamePie extends Pie { + + HostnamePie(Map hostnames) { + super(turnToSlices(hostnames)); + } + + private static List turnToSlices(Map hostnames) { + List slices = new ArrayList<>(); + for (Map.Entry server : hostnames.entrySet()) { + String hostname = server.getKey(); + Integer total = server.getValue(); + slices.add(new PieSlice(hostname, total)); + } + return slices; + } +} diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieGraphFactory.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieGraphFactory.java index bd80c03e4..aad410e33 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieGraphFactory.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieGraphFactory.java @@ -68,6 +68,10 @@ public class PieGraphFactory { return new ServerPreferencePie(serverPlaytimes); } + public Pie HostnamePie(Map hostname) { + return new HostnamePie(hostname); + } + public WorldPie worldPie(WorldTimes worldTimes) { WorldAliasSettings worldAliasSettings = config.getWorldAliasSettings(); Map playtimePerAlias = worldAliasSettings.getPlaytimePerAlias(worldTimes); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java index 1ecf795a4..c25c4e196 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java @@ -40,6 +40,7 @@ public enum DataID { GRAPH_ACTIVITY, GRAPH_PING, GRAPH_SERVER_PIE, + GRAPH_HOSTNAME_PIE, GRAPH_PUNCHCARD, SERVER_OVERVIEW, ONLINE_OVERVIEW, diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/GraphsJSONResolver.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/GraphsJSONResolver.java index caf7eb672..89a67fd70 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/GraphsJSONResolver.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/GraphsJSONResolver.java @@ -131,6 +131,8 @@ public class GraphsJSONResolver implements Resolver { return DataID.GRAPH_PUNCHCARD; case "serverPie": return DataID.GRAPH_SERVER_PIE; + case "hostnamePie": + return DataID.GRAPH_HOSTNAME_PIE; default: throw new BadRequestException("unknown 'type' parameter."); } @@ -175,6 +177,8 @@ public class GraphsJSONResolver implements Resolver { return graphJSON.hourlyUniqueAndNewGraphJSON(); case GRAPH_SERVER_PIE: return graphJSON.serverPreferencePieJSONAsMap(); + case GRAPH_HOSTNAME_PIE: + return graphJSON.playerHostnamePieJSONAsMap(); case GRAPH_WORLD_MAP: return graphJSON.geolocationGraphsJSONAsMap(); default: diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/UserInfo.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/UserInfo.java index 77009af47..60f873564 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/UserInfo.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/UserInfo.java @@ -34,13 +34,15 @@ public class UserInfo { private final long registered; private final boolean banned; private final boolean opped; + private final String hostname; - public UserInfo(UUID playerUUID, UUID serverUUID, long registered, boolean opped, boolean banned) { + public UserInfo(UUID playerUUID, UUID serverUUID, long registered, boolean opped, String hostname, boolean banned) { this.playerUUID = playerUUID; this.serverUUID = serverUUID; this.registered = registered; this.opped = opped; this.banned = banned; + this.hostname = hostname; } public UUID getPlayerUuid() { @@ -51,6 +53,10 @@ public class UserInfo { return serverUUID; } + public String getHostname() { + return hostname; + } + public long getRegistered() { return registered; } @@ -77,7 +83,7 @@ public class UserInfo { @Override public int hashCode() { - return Objects.hash(playerUUID, serverUUID, registered, banned, opped); + return Objects.hash(playerUUID, serverUUID, registered, banned, hostname, opped); } @Override @@ -88,6 +94,7 @@ public class UserInfo { ", registered=" + registered + ", banned=" + banned + ", opped=" + opped + + ", hostname=" + hostname + '}'; } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/data/UserImportData.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/data/UserImportData.java index 79984df96..ccfa45969 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/data/UserImportData.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/data/UserImportData.java @@ -44,7 +44,11 @@ public class UserImportData { private int mobKills; private int deaths; - private UserImportData(String name, UUID uuid, List nicknames, long registered, boolean op, boolean banned, int timesKicked, List ips, Map worldTimes, List kills, int mobKills, int deaths) { + private String hostname; + + private UserImportData(String name, UUID uuid, List nicknames, long registered, boolean op, + boolean banned, int timesKicked, List ips, Map worldTimes, List kills, + int mobKills, int deaths, String hostname) { this.name = name; this.uuid = uuid; this.nicknames = nicknames; @@ -57,6 +61,7 @@ public class UserImportData { this.kills = kills; this.mobKills = mobKills; this.deaths = deaths; + this.hostname = hostname; } public static UserImportDataBuilder builder(UUID serverUUID) { @@ -111,6 +116,14 @@ public class UserImportData { this.banned = banned; } + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public String getHostname() { + return hostname; + } + public int getTimesKicked() { return timesKicked; } @@ -174,6 +187,7 @@ public class UserImportData { private int timesKicked; private int mobKills; private int deaths; + private String hostname; private UserImportDataBuilder(UUID serverUUID) { this.serverUUID = serverUUID; @@ -284,7 +298,8 @@ public class UserImportData { } public UserImportData build() { - return new UserImportData(name, uuid, nicknames, registered, op, banned, timesKicked, ips, worldTimes, kills, mobKills, deaths); + return new UserImportData(name, uuid, nicknames, registered, op, banned, timesKicked, ips, + worldTimes, kills, mobKills, deaths, hostname); } } @@ -299,6 +314,7 @@ public class UserImportData { timesKicked == that.timesKicked && mobKills == that.mobKills && deaths == that.deaths && + hostname.equals(that.hostname) && Objects.equals(name, that.name) && Objects.equals(uuid, that.uuid) && Objects.equals(nicknames, that.nicknames) && @@ -309,6 +325,7 @@ public class UserImportData { @Override public int hashCode() { - return Objects.hash(name, uuid, nicknames, registered, op, banned, timesKicked, ips, worldTimes, kills, mobKills, deaths); + return Objects.hash(name, uuid, nicknames, registered, op, banned, timesKicked, ips, + worldTimes, kills, mobKills, deaths, hostname); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java index e0d7dc508..afc291a24 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java @@ -174,6 +174,7 @@ public abstract class SQLDB extends AbstractDatabase { new LinkedToSecurityTablePatch(), new LinkUsersToPlayersSecurityTablePatch(), new LitebansTableHeaderPatch(), + new UserInfoHostnamePatch(), new ServerIsProxyPatch() }; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/DataStoreQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/DataStoreQueries.java index e57e8b0b9..6b9e89c96 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/DataStoreQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/DataStoreQueries.java @@ -190,7 +190,7 @@ public class DataStoreQueries { * @param serverUUID UUID of the Plan server. * @return Executable, use inside a {@link com.djrapitops.plan.storage.database.transactions.Transaction} */ - public static Executable registerUserInfo(UUID playerUUID, long registered, UUID serverUUID) { + public static Executable registerUserInfo(UUID playerUUID, long registered, UUID serverUUID, String hostname) { return new ExecStatement(UserInfoTable.INSERT_STATEMENT) { @Override public void prepare(PreparedStatement statement) throws SQLException { @@ -198,7 +198,8 @@ public class DataStoreQueries { statement.setLong(2, registered); statement.setString(3, serverUUID.toString()); statement.setBoolean(4, false); // Banned - statement.setBoolean(5, false); // Operator + statement.setString(5, hostname); // Hostname + statement.setBoolean(6, false); // Operator } }; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/LargeStoreQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/LargeStoreQueries.java index 06663ee1c..0b9e387a7 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/LargeStoreQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/LargeStoreQueries.java @@ -227,7 +227,8 @@ public class LargeStoreQueries { statement.setLong(2, user.getRegistered()); statement.setString(3, serverUUID.toString()); statement.setBoolean(4, user.isBanned()); - statement.setBoolean(5, user.isOperator()); + statement.setString(5, user.getHostname()); + statement.setBoolean(6, user.isOperator()); statement.addBatch(); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/UserInfoQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/UserInfoQueries.java index cd9879f42..44551f7bb 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/UserInfoQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/UserInfoQueries.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.gathering.domain.UserInfo; import com.djrapitops.plan.storage.database.queries.Query; import com.djrapitops.plan.storage.database.queries.QueryAllStatement; import com.djrapitops.plan.storage.database.queries.QueryStatement; +import com.djrapitops.plan.storage.database.sql.tables.ServerTable; import com.djrapitops.plan.storage.database.sql.tables.UserInfoTable; import com.djrapitops.plan.utilities.java.Lists; @@ -54,7 +55,8 @@ public class UserInfoQueries { UserInfoTable.BANNED + ',' + UserInfoTable.OP + ',' + UserInfoTable.USER_UUID + ',' + - UserInfoTable.SERVER_UUID + + UserInfoTable.SERVER_UUID + ',' + + UserInfoTable.HOSTNAME + FROM + UserInfoTable.TABLE_NAME; return new QueryAllStatement>>(sql, 50000) { @@ -70,8 +72,9 @@ public class UserInfoQueries { long registered = set.getLong(UserInfoTable.REGISTERED); boolean banned = set.getBoolean(UserInfoTable.BANNED); boolean op = set.getBoolean(UserInfoTable.OP); + String hostname = set.getString(UserInfoTable.HOSTNAME); - userInfos.add(new UserInfo(uuid, serverUUID, registered, op, banned)); + userInfos.add(new UserInfo(uuid, serverUUID, registered, op, hostname, banned)); } return serverMap; } @@ -89,7 +92,8 @@ public class UserInfoQueries { UserInfoTable.TABLE_NAME + '.' + UserInfoTable.REGISTERED + ',' + UserInfoTable.BANNED + ',' + UserInfoTable.OP + ',' + - UserInfoTable.SERVER_UUID + + UserInfoTable.SERVER_UUID + ',' + + UserInfoTable.HOSTNAME + FROM + UserInfoTable.TABLE_NAME + WHERE + UserInfoTable.TABLE_NAME + '.' + UserInfoTable.USER_UUID + "=?"; @@ -107,7 +111,9 @@ public class UserInfoQueries { boolean op = set.getBoolean(UserInfoTable.OP); boolean banned = set.getBoolean(UserInfoTable.BANNED); UUID serverUUID = UUID.fromString(set.getString(UserInfoTable.SERVER_UUID)); - userInformation.add(new UserInfo(playerUUID, serverUUID, registered, op, banned)); + String hostname = set.getString(UserInfoTable.HOSTNAME); + + userInformation.add(new UserInfo(playerUUID, serverUUID, registered, op, hostname, banned)); } return userInformation; } @@ -124,11 +130,13 @@ public class UserInfoQueries { String sql = SELECT + UserInfoTable.REGISTERED + ',' + UserInfoTable.BANNED + ',' + + UserInfoTable.HOSTNAME + ',' + UserInfoTable.OP + ',' + UserInfoTable.USER_UUID + ',' + UserInfoTable.SERVER_UUID + FROM + UserInfoTable.TABLE_NAME + WHERE + UserInfoTable.SERVER_UUID + "=?"; + return new QueryStatement>(sql, 1000) { @Override public void prepare(PreparedStatement statement) throws SQLException { @@ -146,7 +154,9 @@ public class UserInfoQueries { boolean banned = set.getBoolean(UserInfoTable.BANNED); boolean op = set.getBoolean(UserInfoTable.OP); - userInformation.put(uuid, new UserInfo(uuid, serverUUID, registered, op, banned)); + String hostname = set.getString(UserInfoTable.HOSTNAME); + + userInformation.put(uuid, new UserInfo(uuid, serverUUID, registered, op, hostname, banned)); } return userInformation; } @@ -184,6 +194,28 @@ public class UserInfoQueries { }; } + public static Query> hostnameTotals() { + String sql = SELECT + + "COUNT(hostname) as total," + + UserInfoTable.HOSTNAME + + FROM + UserInfoTable.TABLE_NAME + + GROUP_BY + UserInfoTable.HOSTNAME; + + return new QueryStatement>(sql, 100) { + @Override + public void prepare(PreparedStatement statement) {} + + @Override + public Map processResults(ResultSet set) throws SQLException { + Map hostnames = new HashMap<>(); + while (set.next()) { + hostnames.put(set.getString(UserInfoTable.HOSTNAME), set.getInt("total")); + } + return hostnames; + } + }; + } + public static Query> uuidsOfOperators() { return getUUIDsForBooleanGroup(UserInfoTable.OP, true); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/UserInfoTable.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/UserInfoTable.java index f3d939b15..3fe9e9678 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/UserInfoTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/UserInfoTable.java @@ -42,14 +42,16 @@ public class UserInfoTable { public static final String REGISTERED = "registered"; public static final String OP = "opped"; public static final String BANNED = "banned"; + public static final String HOSTNAME = "hostname"; public static final String INSERT_STATEMENT = "INSERT INTO " + TABLE_NAME + " (" + USER_UUID + ',' + REGISTERED + ',' + SERVER_UUID + ',' + BANNED + ',' + + HOSTNAME + ',' + OP + - ") VALUES (?, ?, ?, ?, ?)"; + ") VALUES (?, ?, ?, ?, ?, ?)"; private UserInfoTable() { /* Static information class */ @@ -60,6 +62,7 @@ public class UserInfoTable { .column(ID, Sql.INT).primaryKey() .column(USER_UUID, Sql.varchar(36)).notNull() .column(SERVER_UUID, Sql.varchar(36)).notNull() + .column(HOSTNAME, Sql.varchar(255)).notNull().defaultValue("'Unknown'") .column(REGISTERED, Sql.LONG).notNull() .column(OP, Sql.BOOL).notNull().defaultValue(false) .column(BANNED, Sql.BOOL).notNull().defaultValue(false) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java index 39734dd48..549ed0bd7 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java @@ -31,10 +31,13 @@ import java.util.function.LongSupplier; public class PlayerServerRegisterTransaction extends PlayerRegisterTransaction { private final UUID serverUUID; + private final String hostname; - public PlayerServerRegisterTransaction(UUID playerUUID, LongSupplier registered, String playerName, UUID serverUUID) { + public PlayerServerRegisterTransaction(UUID playerUUID, LongSupplier registered, + String playerName, UUID serverUUID, String hostname) { super(playerUUID, registered, playerName); this.serverUUID = serverUUID; + this.hostname = hostname; } @Override @@ -42,7 +45,7 @@ public class PlayerServerRegisterTransaction extends PlayerRegisterTransaction { super.performOperations(); long registerDate = registered.getAsLong(); if (Boolean.FALSE.equals(query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID)))) { - execute(DataStoreQueries.registerUserInfo(playerUUID, registerDate, serverUUID)); + execute(DataStoreQueries.registerUserInfo(playerUUID, registerDate, serverUUID, hostname)); } // Updates register date to smallest possible value. diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/UserInfoHostnamePatch.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/UserInfoHostnamePatch.java new file mode 100644 index 000000000..2f56688ba --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/UserInfoHostnamePatch.java @@ -0,0 +1,39 @@ +/* + * This file is part of Player Analytics (Plan). + * + * Plan is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License v3 as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Plan is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Plan. If not, see . + */ +package com.djrapitops.plan.storage.database.transactions.patches; + +import com.djrapitops.plan.storage.database.sql.building.Sql; +import com.djrapitops.plan.storage.database.sql.tables.UserInfoTable; + +/** + * Patch to add 'hostname' to 'plan_user_info' + * + * @author vacoup95 + */ +public class UserInfoHostnamePatch extends Patch { + + @Override + public boolean hasBeenApplied() { + return hasColumn(UserInfoTable.TABLE_NAME, UserInfoTable.HOSTNAME); + } + + @Override + protected void applyPatch() { + addColumn(UserInfoTable.TABLE_NAME, UserInfoTable.HOSTNAME + ' ' + + Sql.varchar(255) + " NOT NULL DEFAULT 'Unknown'"); + } +} \ No newline at end of file diff --git a/Plan/common/src/main/resources/assets/plan/web/js/graphs.js b/Plan/common/src/main/resources/assets/plan/web/js/graphs.js index fdc1665b3..1580b6323 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/graphs.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/graphs.js @@ -418,6 +418,34 @@ function serverPie(id, serverSeries) { })); } +function hostnamePie(id, hostnameTotals) { + graphs.push(Highcharts.chart(id, { + chart: { + plotBackgroundColor: null, + plotBorderWidth: null, + plotShadow: false, + type: 'pie' + }, + title: {text: ''}, + plotOptions: { + pie: { + allowPointSelect: true, + cursor: 'pointer', + dataLabels: { + enabled: false + }, + showInLegend: true + } + }, + tooltip: { + formatter: function () { + return '' + this.point.name + ': ' + this.y + ' (' + this.percentage.toFixed(2) + '%)'; + } + }, + series: [hostnameTotals] + })); +} + function formatTimeAmount(ms) { let out = ""; diff --git a/Plan/common/src/main/resources/assets/plan/web/js/network-values.js b/Plan/common/src/main/resources/assets/plan/web/js/network-values.js index 58ef7da87..a3de4f4d3 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/network-values.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/network-values.js @@ -415,4 +415,18 @@ function loadGeolocationGraph(json, error) { document.getElementById('worldMap').innerText = errorMessage; document.getElementById('countryBarChart').innerText = errorMessage; } +} + +function loadHostnamePie(json, error) { + if (json) { + hostnamePieSeries = { + name: 'Used IP Addresses', + colorByPoint: true, + colors: json.hostname_pie_colors, + data: json.hostname_pie_slices + }; + hostnamePie('hostnamePie', hostnamePieSeries); + } else if (error) { + document.getElementById('hostnamePie').innerText = `Failed to load graph data: ${error}`; + } } \ No newline at end of file diff --git a/Plan/common/src/main/resources/assets/plan/web/network.html b/Plan/common/src/main/resources/assets/plan/web/network.html index 2b0adf402..6b330db77 100644 --- a/Plan/common/src/main/resources/assets/plan/web/network.html +++ b/Plan/common/src/main/resources/assets/plan/web/network.html @@ -505,6 +505,7 @@
+
@@ -582,29 +583,43 @@
+ -
-
-
-
- Insights for 30 days
+
+
+
+
+
+ Insights for 30 days
+
+
+

New Regular

+

Regular Inactive

+

+ Comparing 30d ago to Now +

+
-
-

New Regular

-

Regular Inactive

-

- Comparing 30d ago to Now -

+ + +
+
+
+ + Used hostnames +
+
+
@@ -902,6 +917,7 @@ refreshingJsonRequest("./v1/graph?type=uniqueAndNew", loadUniqueAndNewGraph, 'network-overview'); refreshingJsonRequest("./v1/graph?type=hourlyUniqueAndNew", loadHourlyUniqueAndNewGraph, 'network-overview'); refreshingJsonRequest("./v1/graph?type=serverPie", loadServerPie, 'sessions-overview'); + refreshingJsonRequest("./v1/graph?type=hostnamePie", loadHostnamePie, 'playerbase-overview'); refreshingJsonRequest("./v1/graph?type=activity", loadActivityGraphs, 'playerbase-overview'); refreshingJsonRequest("./v1/graph?type=geolocation", loadGeolocationGraph, 'geolocations'); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java index 050ccd57f..c5e45b555 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java @@ -67,7 +67,8 @@ import static org.junit.jupiter.api.Assertions.*; public interface DatabaseTest extends DatabaseTestPreparer { default void saveUserOne() { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); db().executeTransaction(new KickStoreTransaction(playerUUID)); } @@ -93,7 +94,8 @@ public interface DatabaseTest extends DatabaseTestPreparer { default void testRemovalSingleUser() { saveUserTwo(); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); saveTwoWorlds(); Session session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID); @@ -271,7 +273,8 @@ public interface DatabaseTest extends DatabaseTestPreparer { @Test default void registerDateIsMinimized() { executeTransactions( - new PlayerServerRegisterTransaction(playerUUID, () -> 1000, TestConstants.PLAYER_ONE_NAME, serverUUID()) + new PlayerServerRegisterTransaction(playerUUID, () -> 1000, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME) , new Transaction() { @Override protected void performOperations() { @@ -299,8 +302,10 @@ public interface DatabaseTest extends DatabaseTestPreparer { default void serverTablePlayersQueryQueriesAtLeastOnePlayer() { db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0])); db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1])); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); - db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); + db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, + TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); db().executeTransaction(new SessionEndTransaction(RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID))); List result = db().query(new ServerTablePlayersQuery(serverUUID(), System.currentTimeMillis(), 10L, 1)); @@ -312,8 +317,10 @@ public interface DatabaseTest extends DatabaseTestPreparer { default void networkTablePlayersQueryQueriesAtLeastOnePlayer() { db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0])); db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1])); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); - db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); + db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, + TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); db().executeTransaction(new SessionEndTransaction(RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID))); List result = db().query(new NetworkTablePlayersQuery(System.currentTimeMillis(), 10L, 1)); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ActivityIndexQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ActivityIndexQueriesTest.java index 71e5da11d..cc9622f10 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ActivityIndexQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ActivityIndexQueriesTest.java @@ -51,8 +51,10 @@ import static org.junit.jupiter.api.Assertions.*; public interface ActivityIndexQueriesTest extends DatabaseTestPreparer { default void storeSessions(Predicate save) { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); - db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); + db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, + TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); for (String world : worlds) { db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), world)); } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/DatabaseBackupTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/DatabaseBackupTest.java index d06c773f5..9c71cf5c8 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/DatabaseBackupTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/DatabaseBackupTest.java @@ -47,8 +47,10 @@ public interface DatabaseBackupTest extends DatabaseTestPreparer { default void saveDataForBackup() { db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0])); db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1])); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); - db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); + db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, + TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); Session session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID); execute(DataStoreQueries.storeSession(session)); @@ -94,6 +96,7 @@ public interface DatabaseBackupTest extends DatabaseTestPreparer { assertQueryResultIsEqual(db(), backup, LargeFetchQueries.fetchAllTPSData()); assertQueryResultIsEqual(db(), backup, ServerQueries.fetchPlanServerInformation()); assertQueryResultIsEqual(db(), backup, WebUserQueries.fetchAllUsers()); + } finally { backup.close(); } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/GeolocationQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/GeolocationQueriesTest.java index bab8ea436..71439ad73 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/GeolocationQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/GeolocationQueriesTest.java @@ -40,7 +40,8 @@ public interface GeolocationQueriesTest extends DatabaseTestPreparer { @Test default void geoInformationIsStored() { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); List expected = RandomData.randomGeoInfo(); for (GeoInfo geoInfo : expected) { @@ -102,7 +103,8 @@ public interface GeolocationQueriesTest extends DatabaseTestPreparer { Database db = db(); for (UUID uuid : uuids) { - db.executeTransaction(new PlayerServerRegisterTransaction(uuid, () -> 0L, "", serverUUID())); + db.executeTransaction(new PlayerServerRegisterTransaction(uuid, () -> 0L, "", serverUUID(), + TestConstants.PLAYER_HOSTNAME)); } save(firstUuid, new GeoInfo("Norway", 0)); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/NicknameQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/NicknameQueriesTest.java index ddd52f8df..773451e14 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/NicknameQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/NicknameQueriesTest.java @@ -37,7 +37,8 @@ public interface NicknameQueriesTest extends DatabaseTestPreparer { @Test default void allNicknamesAreSaved() { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); List saved = RandomData.randomNicknames(serverUUID()); for (Nickname nickname : saved) { diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java index 054020384..c37106089 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java @@ -76,8 +76,10 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { default void prepareForSessionSave() { db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0])); db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1])); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID())); - db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, + TestConstants.PLAYER_ONE_NAME, serverUUID(),TestConstants.PLAYER_HOSTNAME)); + db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, + TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); } @Test diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java index 56bfcf4ee..7118b1419 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java @@ -42,41 +42,44 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer { @Test default void userInfoTableStoresCorrectUserInformation() { assertFalse(db().query(BaseUserQueries.fetchBaseUserOfPlayer(playerUUID)).isPresent()); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); List userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID)); - List expected = Collections.singletonList(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, false)); + List expected = Collections.singletonList(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, TestConstants.PLAYER_HOSTNAME, false)); assertEquals(expected, userInfo); } @Test default void userInfoTableUpdatesBanStatus() { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); db().executeTransaction(new BanStatusTransaction(playerUUID, () -> true)); List userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID)); - List expected = Collections.singletonList(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, true)); + List expected = Collections.singletonList(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, false, TestConstants.PLAYER_HOSTNAME, true)); assertEquals(expected, userInfo); } @Test default void userInfoTableUpdatesOperatorStatus() { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); db().executeTransaction(new OperatorStatusTransaction(playerUUID, true)); List userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID)); - List expected = Collections.singletonList(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, true, false)); + List expected = Collections.singletonList(new UserInfo(playerUUID, serverUUID(), TestConstants.REGISTER_TIME, true, TestConstants.PLAYER_HOSTNAME, false)); assertEquals(expected, userInfo); } @Test default void playerNameIsUpdatedWhenPlayerLogsIn() { - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); OptionalAssert.equals(playerUUID, db().query(UserIdentifierQueries.fetchPlayerUUIDOf(TestConstants.PLAYER_ONE_NAME))); @@ -149,7 +152,8 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer { default void playerIsRegisteredToBothTables() { assertFalse(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID))); assertFalse(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID()))); - db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID())); + db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, + TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.PLAYER_HOSTNAME)); assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID))); assertTrue(db().query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID()))); } @@ -175,9 +179,12 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer { db().executeTransaction(new Transaction() { @Override protected void performOperations() { - execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID())); - execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID())); - execute(DataStoreQueries.registerUserInfo(player2UUID, 0L, serverUUID())); + execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, + serverUUID(), TestConstants.PLAYER_HOSTNAME)); + execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, + serverUUID(), TestConstants.PLAYER_HOSTNAME)); + execute(DataStoreQueries.registerUserInfo(player2UUID, 0L, + serverUUID(), TestConstants.PLAYER_HOSTNAME)); } }).get(); @@ -185,13 +192,13 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer { List found = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID)); assertEquals( - Collections.singletonList(new UserInfo(playerUUID, serverUUID(), 0, false, false)), + Collections.singletonList(new UserInfo(playerUUID, serverUUID(), 0, false, TestConstants.PLAYER_HOSTNAME, false)), found ); List found2 = db().query(UserInfoQueries.fetchUserInformationOfUser(player2UUID)); assertEquals( - Collections.singletonList(new UserInfo(player2UUID, serverUUID(), 0, false, false)), + Collections.singletonList(new UserInfo(player2UUID, serverUUID(), 0, false, TestConstants.PLAYER_HOSTNAME,false)), found2 ); } diff --git a/Plan/common/src/test/java/utilities/TestConstants.java b/Plan/common/src/test/java/utilities/TestConstants.java index 83751e312..1a1a4a7e7 100644 --- a/Plan/common/src/test/java/utilities/TestConstants.java +++ b/Plan/common/src/test/java/utilities/TestConstants.java @@ -41,6 +41,8 @@ public class TestConstants { public static final String PLAYER_TWO_NAME = "Test_Player_two"; public static final String PLAYER_THREE_NAME = RandomData.randomString(16); + public static final String PLAYER_HOSTNAME = "play.example.com"; + public static final String WORLD_ONE_NAME = "World One"; public static final Long REGISTER_TIME = RandomData.randomTime(); diff --git a/Plan/common/src/test/java/utilities/TestData.java b/Plan/common/src/test/java/utilities/TestData.java index 670425b89..7d8584477 100644 --- a/Plan/common/src/test/java/utilities/TestData.java +++ b/Plan/common/src/test/java/utilities/TestData.java @@ -115,8 +115,10 @@ public class TestData { new Transaction() { @Override protected void performOperations() { - executeOther(new PlayerServerRegisterTransaction(playerUUID, () -> playerFirstJoin, playerName, serverUUID)); - executeOther(new PlayerServerRegisterTransaction(playerUUID, () -> playerSecondJoin, playerName, server2UUID)); + executeOther(new PlayerServerRegisterTransaction(playerUUID, () -> playerFirstJoin, + playerName, serverUUID, TestConstants.PLAYER_HOSTNAME)); + executeOther(new PlayerServerRegisterTransaction(playerUUID, () -> playerSecondJoin, + playerName, server2UUID, TestConstants.PLAYER_HOSTNAME)); for (GeoInfo geoInfo : playerGeoInfo) { executeOther(new GeoInfoStoreTransaction(playerUUID, geoInfo)); @@ -136,8 +138,10 @@ public class TestData { new Transaction() { @Override protected void performOperations() { - executeOther(new PlayerServerRegisterTransaction(player2UUID, () -> playerFirstJoin, player2Name, serverUUID)); - executeOther(new PlayerServerRegisterTransaction(player2UUID, () -> playerSecondJoin, player2Name, server2UUID)); + executeOther(new PlayerServerRegisterTransaction(player2UUID, () -> playerFirstJoin, + player2Name, serverUUID, TestConstants.PLAYER_HOSTNAME)); + executeOther(new PlayerServerRegisterTransaction(player2UUID, () -> playerSecondJoin, + player2Name, server2UUID, TestConstants.PLAYER_HOSTNAME)); for (GeoInfo geoInfo : playerGeoInfo) { executeOther(new GeoInfoStoreTransaction(player2UUID, geoInfo)); diff --git a/Plan/gradle/wrapper/gradle-wrapper.properties b/Plan/gradle/wrapper/gradle-wrapper.properties index d2adaf7cb..cf9ffc703 100644 --- a/Plan/gradle/wrapper/gradle-wrapper.properties +++ b/Plan/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Tue Mar 10 21:27:56 EET 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java b/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java index 2d9c22d46..632a3cf22 100644 --- a/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java +++ b/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java @@ -153,6 +153,7 @@ public class PlayerOnlineListener implements Listener { String world = player.getLevel().getName(); String gm = GMTimes.magicNumberToGMName(player.getGamemode()); + String hostname = player.getAddress(); Database database = dbSystem.getDatabase(); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world)); @@ -170,7 +171,8 @@ public class PlayerOnlineListener implements Listener { } long registerDate = TimeUnit.SECONDS.toMillis(player.getFirstPlayed()); - database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> registerDate, playerName, serverUUID)); + database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> registerDate, + playerName, serverUUID, hostname)); Session session = new Session(playerUUID, serverUUID, time, world, gm); session.putRawData(SessionKeys.NAME, playerName); session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName()); diff --git a/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java b/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java index 0590a1df5..773a19f01 100644 --- a/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java +++ b/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java @@ -158,6 +158,7 @@ public class PlayerOnlineListener { String world = player.getWorld().getName(); Optional gameMode = player.getGameModeData().get(Keys.GAME_MODE); String gm = gameMode.map(mode -> mode.getName().toUpperCase()).orElse("ADVENTURE"); + String hostname = player.getConnection().getVirtualHost().getHostString(); Database database = dbSystem.getDatabase(); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world)); @@ -174,7 +175,8 @@ public class PlayerOnlineListener { ); } - database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, playerName, serverUUID)); + database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> time, + playerName, serverUUID, hostname)); Session session = new Session(playerUUID, serverUUID, time, world, gm); session.putRawData(SessionKeys.NAME, playerName); session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName());