mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fixed possible backwards compatibility issues with html files in wrong location
(/plugins/Plan/ instead of /plugins/Plan/web/charts/ for example)
This commit is contained in:
parent
0ff2fe89d6
commit
3742cd65dc
@ -74,6 +74,7 @@ public class PlayerProfile implements OfflinePlayer {
|
||||
|
||||
// Calculating Getters
|
||||
|
||||
@Deprecated // TODO Remove after 4.1.0, made for old html users
|
||||
public boolean isActive(long date) {
|
||||
return getActivityIndex(date) > 1.0;
|
||||
}
|
||||
@ -119,9 +120,10 @@ public class PlayerProfile implements OfflinePlayer {
|
||||
|
||||
double extraMultiplier = 1.0;
|
||||
double loginTotal = weekLogin + week2Login + week3Login;
|
||||
|
||||
double loginAvg = loginTotal / 3.0;
|
||||
if (loginTotal < 2.0) {
|
||||
|
||||
if (loginTotal <= 2.0) {
|
||||
// Reduce index for players that have not logged in the threshold amount for 2 weeks
|
||||
extraMultiplier = 0.75;
|
||||
}
|
||||
|
||||
|
@ -213,12 +213,12 @@ public class FormatUtils {
|
||||
}
|
||||
|
||||
public static String[] readableActivityIndex(double activityIndex) {
|
||||
if (activityIndex >= 5.0) {
|
||||
if (activityIndex >= 3.5) {
|
||||
return new String[]{"green", "Very Active"};
|
||||
} else if (activityIndex >= 2.0) {
|
||||
} else if (activityIndex >= 1.75) {
|
||||
return new String[]{"green", "Active"};
|
||||
} else if (activityIndex >= 1.0) {
|
||||
return new String[]{"green", "Regular"};
|
||||
return new String[]{"lime", "Regular"};
|
||||
} else if (activityIndex >= 0.5) {
|
||||
return new String[]{"amber", "Irregular"};
|
||||
} else {
|
||||
|
@ -11,9 +11,7 @@ import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -35,10 +33,44 @@ public class FileUtil {
|
||||
public static List<String> lines(IPlan plugin, File savedFile, String defaults) throws IOException {
|
||||
if (savedFile.exists()) {
|
||||
return lines(savedFile);
|
||||
} else {
|
||||
String fileName = savedFile.getName();
|
||||
File found = attemptToFind(fileName, plugin.getDataFolder());
|
||||
if (found != null) {
|
||||
return lines(found);
|
||||
}
|
||||
}
|
||||
return lines(plugin, defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Breadth-First search through the file tree to find the file.
|
||||
*
|
||||
* @param fileName Name of the searched file
|
||||
* @param dataFolder Folder to look from
|
||||
* @return File if found or null
|
||||
*/
|
||||
private static File attemptToFind(String fileName, File dataFolder) {
|
||||
if (dataFolder.isDirectory()) {
|
||||
ArrayDeque<File> que = new ArrayDeque<>();
|
||||
que.add(dataFolder);
|
||||
|
||||
while (!que.isEmpty()) {
|
||||
File file = que.pop();
|
||||
if (file.isFile() && fileName.equals(file.getName())) {
|
||||
return file;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
que.addAll(Arrays.asList(files));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<String> lines(IPlan plugin, String resource) throws IOException {
|
||||
List<String> lines = new ArrayList<>();
|
||||
Scanner scanner = null;
|
||||
|
Loading…
Reference in New Issue
Block a user