mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-31 16:01:00 +01:00
[2.5.2] Fix for #11 & Player fetch optimization for analysis
- Removed bedlocation because it was causing issues - Total players now displays only players found in the database.
This commit is contained in:
parent
869df1f374
commit
b6d245725f
@ -9,7 +9,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -22,7 +21,6 @@ public class UserData {
|
||||
private UUID uuid;
|
||||
private Location location;
|
||||
private List<Location> locations;
|
||||
private Location bedLocation;
|
||||
private HashSet<InetAddress> ips;
|
||||
private HashSet<String> nicknames;
|
||||
private long registered;
|
||||
@ -49,10 +47,6 @@ public class UserData {
|
||||
|
||||
public UserData(Player player, DemographicsData demData, Database db) {
|
||||
uuid = player.getUniqueId();
|
||||
bedLocation = player.getBedSpawnLocation();
|
||||
if (bedLocation == null) {
|
||||
bedLocation = new Location(Bukkit.getServer().getWorlds().get(0), 0, 0, 0);
|
||||
}
|
||||
registered = player.getFirstPlayed();
|
||||
location = player.getLocation();
|
||||
isOp = player.isOp();
|
||||
@ -77,10 +71,6 @@ public class UserData {
|
||||
|
||||
public UserData(OfflinePlayer player, DemographicsData demData, Database db) {
|
||||
uuid = player.getUniqueId();
|
||||
bedLocation = player.getBedSpawnLocation();
|
||||
if (bedLocation == null) {
|
||||
bedLocation = new Location(Bukkit.getServer().getWorlds().get(0), 0, 0, 0);
|
||||
}
|
||||
registered = player.getFirstPlayed();
|
||||
isOp = player.isOp();
|
||||
locations = new ArrayList<>();
|
||||
@ -189,10 +179,6 @@ public class UserData {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public Location getBedLocation() {
|
||||
return bedLocation;
|
||||
}
|
||||
|
||||
public HashSet<InetAddress> getIps() {
|
||||
return ips;
|
||||
}
|
||||
@ -262,10 +248,6 @@ public class UserData {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public void setBedLocation(Location bedLocation) {
|
||||
this.bedLocation = bedLocation;
|
||||
}
|
||||
|
||||
public void setIps(HashSet<InetAddress> ips) {
|
||||
this.ips = ips;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.UserData;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -68,6 +67,5 @@ public class LocationHandler {
|
||||
if (bedSpawnLocation == null) {
|
||||
return;
|
||||
}
|
||||
handler.getCurrentData(p.getUniqueId()).setBedLocation(bedSpawnLocation);
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import main.java.com.djrapitops.plan.data.PlanLiteAnalyzedData;
|
||||
import main.java.com.djrapitops.plan.data.PlanLitePlayerData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
@ -61,15 +61,8 @@ public class Analysis {
|
||||
rawData.clear();
|
||||
added.clear();
|
||||
log(Phrase.ANALYSIS_START + "");
|
||||
OfflinePlayer[] offlinePlayers;
|
||||
try {
|
||||
offlinePlayers = plugin.getServer().getOfflinePlayers();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
plugin.log(Phrase.ANALYSIS_FAIL_NO_PLAYERS + "");
|
||||
return;
|
||||
}
|
||||
|
||||
List<UUID> uuids = fetchPlayersInDB(offlinePlayers);
|
||||
List<UUID> uuids = fetchPlayersInDB();
|
||||
if (uuids.isEmpty()) {
|
||||
plugin.log(Phrase.ANALYSIS_FAIL_NO_DATA + "");
|
||||
return;
|
||||
@ -187,7 +180,7 @@ public class Analysis {
|
||||
totalMobKills += uData.getMobKills();
|
||||
totalDeaths += uData.getDeaths();
|
||||
} catch (NullPointerException e) {
|
||||
plugin.logError(Phrase.DATA_CORRUPTION_WARN.parse(uData.getUuid()+""));
|
||||
plugin.logError(Phrase.DATA_CORRUPTION_WARN.parse(uData.getUuid() + ""));
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +243,7 @@ public class Analysis {
|
||||
data.setInactive(inactive);
|
||||
data.setBanned(totalBanned);
|
||||
data.setJoinleaver(joinleaver);
|
||||
data.setTotal(offlinePlayers.length);
|
||||
data.setTotal(uuids.size());
|
||||
}
|
||||
|
||||
private void analyzeAverageAge(List<Integer> ages, AnalysisData data) {
|
||||
@ -362,16 +355,15 @@ public class Analysis {
|
||||
}).runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
private List<UUID> fetchPlayersInDB(OfflinePlayer[] offlinePlayers) {
|
||||
private List<UUID> fetchPlayersInDB() {
|
||||
final List<UUID> uuids = new ArrayList<>();
|
||||
log(Phrase.ANALYSIS_FETCH_PLAYERS + "");
|
||||
Set<UUID> savedUUIDs = plugin.getDB().getSavedUUIDs();
|
||||
for (OfflinePlayer p : offlinePlayers) {
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (savedUUIDs.contains(uuid)) {
|
||||
uuids.add(uuid);
|
||||
}
|
||||
}
|
||||
savedUUIDs.parallelStream()
|
||||
.filter((uuid) -> (getOfflinePlayer(uuid).hasPlayedBefore()))
|
||||
.forEach((uuid) -> {
|
||||
uuids.add(uuid);
|
||||
});
|
||||
return uuids;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,6 @@ public class PlaceholderUtils {
|
||||
replaceMap.put("%uuid%", (showIPandUUID ? "" + data.getUuid() : Html.HIDDEN.parse()));
|
||||
replaceMap.put("%lastseen%", FormatUtils.formatTimeStamp("" + data.getLastPlayed()));
|
||||
replaceMap.put("%logintimes%", "" + data.getLoginTimes());
|
||||
replaceMap.put("%bed%", FormatUtils.formatLocation(data.getBedLocation()));
|
||||
replaceMap.put("%geoloc%", data.getDemData().getGeoLocation());
|
||||
boolean isActive = AnalysisUtils.isActive(data.getLastPlayed(), data.getPlayTime(), data.getLoginTimes());
|
||||
replaceMap.put("%active%", isActive ? Html.ACTIVE.parse() : Html.INACTIVE.parse());
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: com.djrapitops.plan.Plan
|
||||
version: 2.5.1
|
||||
version: 2.5.2
|
||||
|
||||
commands:
|
||||
plan:
|
||||
|
Loading…
Reference in New Issue
Block a user