mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-04-01 09:25:56 +02:00
Merge pull request #626 from Rsl1122/4.3.3
Update data-refactoring-bridge-fixes with commits in 4.3.3 branch
This commit is contained in:
commit
cbae1d3c4c
@ -9,6 +9,7 @@ import com.djrapitops.plan.utilities.SHA256Hash;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
@ -23,9 +24,9 @@ public class GeoInfo {
|
||||
private final String ipHash;
|
||||
private final long lastUsed;
|
||||
|
||||
public GeoInfo(String ip, String geolocation, long lastUsed)
|
||||
public GeoInfo(InetAddress address, String geolocation, long lastUsed)
|
||||
throws UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
this(FormatUtils.formatIP(ip), geolocation, lastUsed, new SHA256Hash(ip).create());
|
||||
this(FormatUtils.formatIP(address), geolocation, lastUsed, new SHA256Hash(address.getHostAddress()).create());
|
||||
}
|
||||
|
||||
public GeoInfo(String ip, String geolocation, long lastUsed, String ipHash) {
|
||||
|
@ -64,6 +64,9 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
||||
|
||||
for (UserInfo userInfo : serverUserInfo) {
|
||||
UUID uuid = userInfo.getUuid();
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
PlayerProfile profile = new PlayerProfile(uuid, userInfo.getName(), userInfo.getRegistered());
|
||||
profile.setTimesKicked(timesKicked.getOrDefault(uuid, 0));
|
||||
if (userInfo.isBanned()) {
|
||||
|
@ -19,6 +19,8 @@ import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -99,7 +101,7 @@ public class GeoInfoTable extends UserIDTable {
|
||||
continue;
|
||||
}
|
||||
GeoInfo updatedInfo = new GeoInfo(
|
||||
geoInfo.getIp(),
|
||||
InetAddress.getByName(geoInfo.getIp()),
|
||||
geoInfo.getGeolocation(),
|
||||
geoInfo.getLastUsed()
|
||||
);
|
||||
@ -107,7 +109,7 @@ public class GeoInfoTable extends UserIDTable {
|
||||
statement.setString(2, updatedInfo.getIpHash());
|
||||
statement.setString(3, geoInfo.getIp());
|
||||
statement.addBatch();
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
} catch (UnknownHostException | UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -89,7 +90,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
String world = player.getWorld().getName();
|
||||
String gm = player.getGameMode().name();
|
||||
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
InetAddress address = player.getAddress().getAddress();
|
||||
|
||||
String playerName = player.getName();
|
||||
String displayName = player.getDisplayName();
|
||||
@ -100,7 +101,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
|
||||
Processing.submit(
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,
|
||||
new IPUpdateProcessor(uuid, ip, time),
|
||||
new IPUpdateProcessor(uuid, address, time),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new PlayerPageUpdateProcessor(uuid)
|
||||
)
|
||||
|
@ -13,6 +13,7 @@ import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -28,11 +29,11 @@ public class PlayerOnlineListener implements Listener {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
String name = player.getName();
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
InetAddress address = player.getAddress().getAddress();
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
Processing.submit(new BungeePlayerRegisterProcessor(uuid, name, now,
|
||||
new IPUpdateProcessor(uuid, ip, now))
|
||||
new IPUpdateProcessor(uuid, address, now))
|
||||
);
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
|
@ -21,6 +21,7 @@ import org.spongepowered.api.profile.GameProfile;
|
||||
import org.spongepowered.api.service.ProviderRegistration;
|
||||
import org.spongepowered.api.service.ban.BanService;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -92,7 +93,7 @@ public class SpongePlayerListener {
|
||||
gm = gameMode.get().getName().toUpperCase();
|
||||
}
|
||||
|
||||
String ip = player.getConnection().getAddress().getAddress().getHostAddress();
|
||||
InetAddress address = player.getConnection().getAddress().getAddress();
|
||||
|
||||
String playerName = player.getName();
|
||||
String displayName = player.getDisplayNameData().displayName().get().toPlain();
|
||||
@ -103,7 +104,7 @@ public class SpongePlayerListener {
|
||||
|
||||
Processing.submit(
|
||||
new RegisterProcessor(uuid, time, time, playerName, playersOnline,
|
||||
new IPUpdateProcessor(uuid, ip, time),
|
||||
new IPUpdateProcessor(uuid, address, time),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new PlayerPageUpdateProcessor(uuid)
|
||||
)
|
||||
|
@ -17,6 +17,7 @@ import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.importing.ServerImportData;
|
||||
import com.djrapitops.plan.system.processing.importing.UserImportData;
|
||||
import com.djrapitops.plan.system.processing.importing.UserImportRefiner;
|
||||
import com.djrapitops.plan.utilities.SHA256Hash;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -230,7 +231,7 @@ public abstract class Importer {
|
||||
.map(ip -> {
|
||||
String geoLoc = GeolocationCache.getCountry(ip);
|
||||
try {
|
||||
return new GeoInfo(ip, geoLoc, date);
|
||||
return new GeoInfo(ip, geoLoc, date, new SHA256Hash(ip).create());
|
||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -24,10 +25,10 @@ import java.util.UUID;
|
||||
public class IPUpdateProcessor implements CriticalRunnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final String ip;
|
||||
private final InetAddress ip;
|
||||
private final long time;
|
||||
|
||||
public IPUpdateProcessor(UUID uuid, String ip, long time) {
|
||||
public IPUpdateProcessor(UUID uuid, InetAddress ip, long time) {
|
||||
this.uuid = uuid;
|
||||
this.ip = ip;
|
||||
this.time = time;
|
||||
@ -36,7 +37,7 @@ public class IPUpdateProcessor implements CriticalRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Settings.DATA_GEOLOCATIONS.isTrue()) {
|
||||
String country = GeolocationCache.getCountry(ip);
|
||||
String country = GeolocationCache.getCountry(ip.getHostAddress());
|
||||
try {
|
||||
GeoInfo geoInfo = new GeoInfo(ip, country, time);
|
||||
Database.getActive().save().geoInfo(uuid, geoInfo);
|
||||
|
@ -9,6 +9,7 @@ import com.djrapitops.plan.data.calculation.AnalysisData;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -22,6 +23,7 @@ public class AnalysisPage extends Page {
|
||||
private final AnalysisData data;
|
||||
|
||||
public AnalysisPage(AnalysisData analysisData) {
|
||||
Verify.nullCheck(analysisData, () -> new IllegalArgumentException("Analysis failed, data object was null"));
|
||||
this.data = analysisData;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -213,23 +215,40 @@ public class FormatUtils {
|
||||
return df.format(d);
|
||||
}
|
||||
|
||||
public static String formatIP(String ip) {
|
||||
public static String formatIP(InetAddress address) {
|
||||
String ip = address.getHostAddress();
|
||||
if ("localhost".equals(ip)) {
|
||||
return ip;
|
||||
}
|
||||
StringBuilder b = new StringBuilder();
|
||||
int i = 0;
|
||||
for (String part : ip.split("\\.")) {
|
||||
if (i >= 2) {
|
||||
break;
|
||||
if (address instanceof Inet6Address) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int i = 0;
|
||||
for (String part : ip.split(":")) {
|
||||
if (i >= 3) {
|
||||
break;
|
||||
}
|
||||
|
||||
b.append(part).append(':');
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
b.append(part).append('.');
|
||||
return b.append("xx..").toString();
|
||||
} else {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int i = 0;
|
||||
for (String part : ip.split("\\.")) {
|
||||
if (i >= 2) {
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
b.append(part).append('.');
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return b.append("xx.xx").toString();
|
||||
}
|
||||
|
||||
return b.append("xx.xx").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
<!-- AdminBSB Themes. You can choose a theme from css/themes instead of get all themes -->
|
||||
<link href="css/themes/all-themes.css" rel="stylesheet"/>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body class="theme-red">
|
||||
@ -250,9 +254,6 @@
|
||||
<!-- Waves Effect Plugin Js -->
|
||||
<script src="plugins/node-waves/waves.js"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<script src="plugins/font-awesome/fa-script.js"></script>
|
||||
|
||||
<!-- Header, Sidenav & Skin changer -->
|
||||
<script src="js/admin.js"></script>
|
||||
|
||||
@ -260,4 +261,4 @@
|
||||
<script src="js/demo.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -34,6 +34,10 @@
|
||||
|
||||
<!-- Jquery Core Js -->
|
||||
<script src="plugins/jquery/jquery.min.js"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body class="theme-red">
|
||||
@ -378,9 +382,6 @@
|
||||
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/no-data-to-display.js"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<script src="plugins/font-awesome/fa-script.js"></script>
|
||||
|
||||
<!-- Header, Sidenav & Skin changer -->
|
||||
<script src="js/admin.js"></script>
|
||||
|
||||
@ -474,4 +475,4 @@
|
||||
<script src="js/demo.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
<!-- AdminBSB Themes. You can choose a theme from css/themes instead of get all themes -->
|
||||
<link href="../css/themes/all-themes.css" rel="stylesheet"/>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body class="theme-red">
|
||||
@ -681,9 +685,6 @@
|
||||
<script src='../plugins/momentjs/moment.js'></script>
|
||||
<script src='../plugins/fullcalendar/fullcalendar.min.js'></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<script src="../plugins/font-awesome/fa-script.js"></script>
|
||||
|
||||
<!-- Header, Sidenav & Skin changer -->
|
||||
<script src="../js/admin.js"></script>
|
||||
|
||||
@ -786,4 +787,4 @@
|
||||
<script src="../js/demo.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
<!-- AdminBSB Themes. You can choose a theme from css/themes instead of get all themes -->
|
||||
<link href="css/themes/all-themes.css" rel="stylesheet"/>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body class="theme-red">
|
||||
@ -278,9 +282,6 @@
|
||||
<script src="plugins/jquery-datatable/jquery.dataTables.js"></script>
|
||||
<script src="plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<script src="plugins/font-awesome/fa-script.js"></script>
|
||||
|
||||
<!-- Header, Sidenav & Skin changer -->
|
||||
<script src="js/admin.js"></script>
|
||||
|
||||
@ -341,4 +342,4 @@
|
||||
<script src="js/demo.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
File diff suppressed because one or more lines are too long
@ -34,6 +34,10 @@
|
||||
|
||||
<!-- Jquery Core Js -->
|
||||
<script src="plugins/jquery/jquery.min.js"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body class="theme-red">
|
||||
@ -1111,9 +1115,6 @@
|
||||
<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/no-data-to-display.js"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<script src="plugins/font-awesome/fa-script.js"></script>
|
||||
|
||||
<!-- Header, Sidenav & Skin changer -->
|
||||
<script src="js/admin.js"></script>
|
||||
|
||||
@ -1402,4 +1403,4 @@
|
||||
<script src="js/demo.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
@ -11,6 +11,9 @@ import utilities.RandomData;
|
||||
import utilities.Teardown;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
@ -77,10 +80,10 @@ public class FormatUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatIP() {
|
||||
String ip = "1.2.3.4";
|
||||
String ip2 = "1.2.3.26";
|
||||
String ip3 = "1.2.3.235";
|
||||
public void testFormatIP() throws UnknownHostException {
|
||||
InetAddress ip = InetAddress.getByName("1.2.3.4");
|
||||
InetAddress ip2 = InetAddress.getByName("1.2.3.26");
|
||||
InetAddress ip3 = InetAddress.getByName("1.2.3.235");
|
||||
String expected = "1.2.xx.xx";
|
||||
|
||||
assertEquals(expected, FormatUtils.formatIP(ip));
|
||||
@ -88,4 +91,13 @@ public class FormatUtilsTest {
|
||||
assertEquals(expected, FormatUtils.formatIP(ip3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatIPv6() throws UnknownHostException {
|
||||
InetAddress ip = InetAddress.getByName("1234:1234:1234:1234:1234:1234:1234:1234%0");
|
||||
String expected = "1234:1234:1234:xx..";
|
||||
|
||||
assertEquals(expected, FormatUtils.formatIP(ip));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,10 @@
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>advanced-achievements-repo</id>
|
||||
<url>https://raw.github.com/PyvesB/AdvancedAchievements/mvn-repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -94,9 +98,9 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hm</groupId>
|
||||
<artifactId>advanced.achievements</artifactId>
|
||||
<version>5.2</version>
|
||||
<groupId>com.hm.achievement</groupId>
|
||||
<artifactId>advanced-achievements-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -2,11 +2,10 @@ package com.djrapitops.pluginbridge.plan.advancedachievements;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import com.hm.achievement.AdvancedAchievements;
|
||||
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||
import com.hm.achievement.api.AdvancedAchievementsBukkitAPI;
|
||||
import com.hm.achievement.api.AdvancedAchievementsAPIFetcher;
|
||||
|
||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to AdvancedAchievements and registering 2
|
||||
@ -29,12 +28,12 @@ public class AdvancedAchievementsHook extends Hook {
|
||||
super("com.hm.achievement.AdvancedAchievements", hookH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hook() throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
AdvancedAchievements aa = getPlugin(AdvancedAchievements.class);
|
||||
if (Integer.parseInt(Character.toString(aa.getDescription().getVersion().charAt(0))) >= 5) {
|
||||
AdvancedAchievementsAPI aaAPI = AdvancedAchievementsBukkitAPI.linkAdvancedAchievements();
|
||||
addPluginDataSource(new AdvancedAchievementsData(aaAPI));
|
||||
Optional<AdvancedAchievementsAPI> aaAPI = AdvancedAchievementsAPIFetcher.fetchInstance();
|
||||
if (aaAPI.isPresent()) {
|
||||
addPluginDataSource(new AdvancedAchievementsData(aaAPI.get()));
|
||||
} else {
|
||||
enabled = false;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
@ -10,22 +10,16 @@ import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.plugin.ContainerSize;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.bukkit.Bukkit.getOnlinePlayers;
|
||||
|
||||
/**
|
||||
* PluginData for McMmo plugin.
|
||||
*
|
||||
@ -43,7 +37,7 @@ public class McMmoData extends PluginData {
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
DatabaseManager db = mcMMO.getDatabaseManager();
|
||||
|
||||
PlayerProfile profile = db.loadPlayerProfile(uuid);
|
||||
PlayerProfile profile = db.loadPlayerProfile("", uuid, false);
|
||||
|
||||
String skillS = Html.FONT_AWESOME_ICON.parse("star") + " Skill";
|
||||
String levelS = Html.FONT_AWESOME_ICON.parse("plus") + " Level";
|
||||
@ -59,34 +53,33 @@ public class McMmoData extends PluginData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisContainer getServerData(Collection<UUID> collection, AnalysisContainer analysisContainer) {
|
||||
public AnalysisContainer getServerData(Collection<UUID> uuids, AnalysisContainer analysisContainer) {
|
||||
String skillS = Html.FONT_AWESOME_ICON.parse("star") + " Skill";
|
||||
String tLevel = Html.FONT_AWESOME_ICON.parse("plus") + " Total Level";
|
||||
String aLevel = Html.FONT_AWESOME_ICON.parse("plus") + " Average Level";
|
||||
|
||||
analysisContainer.addValue("Only Online Players Shown", "Skills available on Inspect pages.");
|
||||
DatabaseManager databaseManager = mcMMO.getDatabaseManager();
|
||||
|
||||
TableContainer skillTable = new TableContainer(skillS, tLevel, aLevel);
|
||||
skillTable.setColor("indigo");
|
||||
|
||||
List<PlayerProfile> profiles = getOnlinePlayers().stream()
|
||||
List<PlayerProfile> profiles = uuids.stream()
|
||||
.map(uuid -> databaseManager.loadPlayerProfile("", uuid, false))
|
||||
.filter(Objects::nonNull)
|
||||
.map(UserManager::getOfflinePlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(McMMOPlayer::getProfile)
|
||||
.filter(PlayerProfile::isLoaded)
|
||||
.collect(Collectors.toList());
|
||||
if (profiles.isEmpty()) {
|
||||
skillTable.addRow("No players online");
|
||||
skillTable.addRow("No players");
|
||||
}
|
||||
|
||||
List<SkillType> skills = Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList());
|
||||
|
||||
for (SkillType skill : skills) {
|
||||
long total = MathUtils.sumInt(profiles.stream().map(p -> (Serializable) p.getSkillLevel(skill)));
|
||||
long total = profiles.stream().mapToInt(p -> p.getSkillLevel(skill)).sum();
|
||||
skillTable.addRow(
|
||||
StringUtils.capitalize(skill.getName().toLowerCase()),
|
||||
Long.toString(total),
|
||||
FormatUtils.cutDecimals(MathUtils.average((int) total, profiles.size()))
|
||||
total,
|
||||
FormatUtils.cutDecimals(total * 1.0 / profiles.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
@ -13,6 +13,7 @@ import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
||||
import com.palmergames.bukkit.towny.object.Coord;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
@ -29,7 +30,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class TownyData extends PluginData {
|
||||
|
||||
|
||||
public TownyData() {
|
||||
super(ContainerSize.TAB, "Towny");
|
||||
super.setPluginIcon("bank");
|
||||
@ -37,33 +37,36 @@ public class TownyData extends PluginData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception {
|
||||
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
|
||||
String playerName = DataCache.getInstance().getName(uuid);
|
||||
|
||||
Resident resident = TownyUniverse.getDataSource().getResident(playerName);
|
||||
try {
|
||||
Resident resident = TownyUniverse.getDataSource().getResident(playerName);
|
||||
|
||||
if (resident.hasTown()) {
|
||||
Town town = resident.getTown();
|
||||
String townName = town.getName();
|
||||
String mayorName = town.getMayor().getName();
|
||||
String townMayor = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(mayorName), mayorName);
|
||||
if (resident.hasTown()) {
|
||||
Town town = resident.getTown();
|
||||
String townName = town.getName();
|
||||
String mayorName = town.getMayor().getName();
|
||||
String townMayor = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(mayorName), mayorName);
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Town", "bank", "brown"), townName);
|
||||
inspectContainer.addValue(getWithIcon("Town Mayor", "user", "brown"), townMayor);
|
||||
inspectContainer.addValue(getWithIcon("Town", "bank", "brown"), townName);
|
||||
inspectContainer.addValue(getWithIcon("Town Mayor", "user", "brown"), townMayor);
|
||||
|
||||
try {
|
||||
Coord homeBlock = town.getHomeBlock().getCoord();
|
||||
String coordinates = "x: " + homeBlock.getX() + " z: " + homeBlock.getZ();
|
||||
inspectContainer.addValue(getWithIcon("Town Coordinates", "map-pin", "red"), coordinates);
|
||||
} catch (TownyException e) {
|
||||
try {
|
||||
Coord homeBlock = town.getHomeBlock().getCoord();
|
||||
String coordinates = "x: " + homeBlock.getX() + " z: " + homeBlock.getZ();
|
||||
inspectContainer.addValue(getWithIcon("Town Coordinates", "map-pin", "red"), coordinates);
|
||||
} catch (TownyException e) {
|
||||
}
|
||||
|
||||
int residents = town.getResidents().size();
|
||||
inspectContainer.addValue(getWithIcon("Town Residents", "users", "brown"), residents);
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
int residents = town.getResidents().size();
|
||||
inspectContainer.addValue(getWithIcon("Town Residents", "users", "brown"), residents);
|
||||
} else {
|
||||
inspectContainer.addValue(getWithIcon("Town", "bank", "brown"), "No Town");
|
||||
} catch (NotRegisteredException ignore) {
|
||||
/* No Towny Resident. */
|
||||
}
|
||||
|
||||
inspectContainer.addValue(getWithIcon("Town", "bank", "brown"), "No Town");
|
||||
return inspectContainer;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user