mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-21 23:51:29 +01:00
1.4.2 Possible bugfix, Advanced Achievements 4.0.3 Offline player support
Added "* 1.0" to some calculations in analysis just to make sure returned values are doubles. Added AA 4.0.3 Offline player support and analysis feature. Ready for release once AA 4.0.3 is released.
This commit is contained in:
parent
c7fc4d93bd
commit
a3af8202e5
@ -16,10 +16,34 @@ public class AdvancedAchievementsHook implements Hook {
|
||||
private Plan plugin;
|
||||
private AdvancedAchievements aAPlugin;
|
||||
private int totalAchievements;
|
||||
private boolean usingUUID;
|
||||
|
||||
public AdvancedAchievementsHook(Plan plugin) throws Exception, NoClassDefFoundError {
|
||||
this.plugin = plugin;
|
||||
this.aAPlugin = getPlugin(AdvancedAchievements.class);
|
||||
String[] aAVersion = aAPlugin.getDescription().getVersion().split(".");
|
||||
try {
|
||||
double versionNumber = Double.parseDouble(aAVersion[0] + "." + aAVersion[1] + aAVersion[2]);
|
||||
if (versionNumber >= 4.03) {
|
||||
this.usingUUID = true;
|
||||
} else {
|
||||
this.usingUUID = false;
|
||||
plugin.logError("Advanced Achievements 4.0.3 or above required for Offline players");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
double versionNumber = Double.parseDouble(aAVersion[0] + "." + aAVersion[1]);
|
||||
if (versionNumber >= 4.03) {
|
||||
this.usingUUID = true;
|
||||
} else {
|
||||
this.usingUUID = false;
|
||||
plugin.logError("Advanced Achievements 4.0.3 or above required for Offline players");
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
plugin.logToFile("AAHOOK\nError getting version number.\n" + e2);
|
||||
}
|
||||
}
|
||||
|
||||
for (NormalAchievements category : NormalAchievements.values()) {
|
||||
String categoryName = category.toString();
|
||||
if (aAPlugin.getDisabledCategorySet().contains(categoryName)) {
|
||||
@ -46,15 +70,19 @@ public class AdvancedAchievementsHook implements Hook {
|
||||
@Override
|
||||
public HashMap<String, String> getData(String player) throws Exception {
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(player);
|
||||
Player p = getPlayer(player);
|
||||
if (uuid != null) {
|
||||
p = getPlayer(uuid);
|
||||
}
|
||||
if (p != null) {
|
||||
if (totalAchievements > 0) {
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(player);
|
||||
try {
|
||||
if (totalAchievements > 0) {
|
||||
data.put("AAC-ACHIEVEMENTS", aAPlugin.getDb().getPlayerAchievementsAmount(p) + " / " + totalAchievements);
|
||||
if (this.usingUUID) {
|
||||
Player p = getPlayer(player);
|
||||
if (uuid != null) {
|
||||
p = getPlayer(uuid);
|
||||
}
|
||||
if (p != null) {
|
||||
data.put("AAC-ACHIEVEMENTS", aAPlugin.getDb().getPlayerAchievementsAmount(p) + " / " + totalAchievements);
|
||||
}
|
||||
} else {
|
||||
data.put("AAC-ACHIEVEMENTS", aAPlugin.getDb().getPlayerAchievementsAmount(uuid.toString()) + " / " + totalAchievements);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.logToFile("AAHOOK-GetData\nFailed to get data\n" + e + "\nfor: " + player);
|
||||
|
@ -92,7 +92,7 @@ public class DataUtils {
|
||||
}
|
||||
}
|
||||
|
||||
String[] numbers = {"ESS-HEALTH", "ESS-XP LEVEL", "FAC-POWER", "FAC-POWER PER HOUR",
|
||||
String[] numbers = {"AAC-ACHIEVEMENTS","ESS-HEALTH", "ESS-XP LEVEL", "FAC-POWER", "FAC-POWER PER HOUR",
|
||||
"FAC-POWER PER DEATH", "SVO-VOTES", "ONT-TOTAL VOTES", "ONT-TOTAL REFERRED", "ECO-BALANCE"};
|
||||
List<String> numberKeys = new ArrayList<>();
|
||||
numberKeys.addAll(Arrays.asList(numbers));
|
||||
@ -125,7 +125,7 @@ public class DataUtils {
|
||||
errorTypes.add("" + e);
|
||||
}
|
||||
}
|
||||
analyzedData.put(dataKey, "" + (sum / playerData.size()));
|
||||
analyzedData.put(dataKey, "" + (sum * 1.0 / playerData.size()));
|
||||
|
||||
} else if (boolKeys.contains(dataKey)) {
|
||||
int amount = 0;
|
||||
@ -139,7 +139,7 @@ public class DataUtils {
|
||||
errorTypes.add("" + e);
|
||||
}
|
||||
}
|
||||
analyzedData.put(dataKey, "" + ((amount / playerData.size()) * 100) + "%");
|
||||
analyzedData.put(dataKey, "" + ((amount * 1.0 / playerData.size()) * 100) + "%");
|
||||
} else if (timeKeys.contains(dataKey)) {
|
||||
Long time = Long.parseLong("0");
|
||||
for (String dataPoint : playerDataLists.get(dataKey)) {
|
||||
@ -150,7 +150,7 @@ public class DataUtils {
|
||||
errorTypes.add("" + e);
|
||||
}
|
||||
}
|
||||
analyzedData.put(dataKey, "" + (time / playerData.size()));
|
||||
analyzedData.put(dataKey, "" + (time * 1.0 / playerData.size()));
|
||||
}
|
||||
}
|
||||
if (errors > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user