mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-12 15:56:00 +08:00
Put Benchmark.stop into finally clause
This commit is contained in:
parent
a7b27d7b0b
commit
2a5a671786
@ -24,7 +24,7 @@ public class ManageCommand extends TreeCommand<Plan> {
|
|||||||
* @param plugin Current instance of Plan
|
* @param plugin Current instance of Plan
|
||||||
*/
|
*/
|
||||||
public ManageCommand(Plan plugin) {
|
public ManageCommand(Plan plugin) {
|
||||||
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE) + "", "plan m");
|
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE).toString(), "plan m");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,9 +62,9 @@ public class Locale implements Closeable {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
} finally {
|
||||||
|
Benchmark.stop("Enable", "Initializing locale");
|
||||||
}
|
}
|
||||||
Benchmark.stop("Enable", "Initializing locale");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNewDefaultLocale() throws IOException {
|
private void writeNewDefaultLocale() throws IOException {
|
||||||
|
@ -167,7 +167,7 @@ public class Analysis {
|
|||||||
|
|
||||||
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
||||||
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
|
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
|
||||||
ExportUtility.export(plugin, analysisData, rawData);
|
ExportUtility.export(analysisData, rawData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
plugin.processStatus().setStatus("Analysis", "Error: " + e);
|
plugin.processStatus().setStatus("Analysis", "Error: " + e);
|
||||||
|
@ -54,25 +54,31 @@ public class ExportUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plugin
|
|
||||||
* @param analysisData
|
* @param analysisData
|
||||||
* @param rawData
|
* @param rawData
|
||||||
*/
|
*/
|
||||||
public static void export(Plan plugin, AnalysisData analysisData, List<UserData> rawData) {
|
public static void export(AnalysisData analysisData, List<UserData> rawData) {
|
||||||
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Exporting Html pages");
|
Benchmark.start("Exporting Html pages");
|
||||||
try {
|
try {
|
||||||
File folder = getFolder();
|
File folder = getFolder();
|
||||||
Log.debug("Export", "Folder: " + folder.getAbsolutePath());
|
Log.debug("Export", "Folder: " + folder.getAbsolutePath());
|
||||||
|
|
||||||
writePlayersPageHtml(rawData, new File(folder, "players"));
|
writePlayersPageHtml(rawData, new File(folder, "players"));
|
||||||
writeAnalysisHtml(analysisData, new File(folder, "server"));
|
writeAnalysisHtml(analysisData, new File(folder, "server"));
|
||||||
|
|
||||||
File playersFolder = getPlayersFolder(folder);
|
File playersFolder = getPlayersFolder(folder);
|
||||||
Log.debug("Export", "Player html files.");
|
Log.debug("Export", "Player html files.");
|
||||||
Log.debug("Export", "Player Page Folder: " + playersFolder.getAbsolutePath());
|
Log.debug("Export", "Player Page Folder: " + playersFolder.getAbsolutePath());
|
||||||
|
|
||||||
String playerHtml = HtmlUtils.getStringFromResource("player.html");
|
String playerHtml = HtmlUtils.getStringFromResource("player.html");
|
||||||
|
|
||||||
|
Benchmark.start("Exporting Player pages");
|
||||||
rawData.forEach(userData -> writeInspectHtml(userData, playersFolder, playerHtml));
|
rawData.forEach(userData -> writeInspectHtml(userData, playersFolder, playerHtml));
|
||||||
|
Benchmark.stop("Exporting Player pages");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Log.toLog("ExportUtils.export", ex);
|
Log.toLog("ExportUtils.export", ex);
|
||||||
} finally {
|
} finally {
|
||||||
@ -94,17 +100,18 @@ public class ExportUtility {
|
|||||||
/**
|
/**
|
||||||
* @param userData
|
* @param userData
|
||||||
* @param playersFolder
|
* @param playersFolder
|
||||||
* @throws FileNotFoundException
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public static boolean writeInspectHtml(UserData userData, File playersFolder, String playerHtml) {
|
public static void writeInspectHtml(UserData userData, File playersFolder, String playerHtml) {
|
||||||
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = userData.getName();
|
String name = userData.getName();
|
||||||
|
|
||||||
if (name.endsWith(".")) {
|
if (name.endsWith(".")) {
|
||||||
name = name.replace(".", "%2E");
|
name = name.replace(".", "%2E");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.endsWith(" ")) {
|
if (name.endsWith(" ")) {
|
||||||
name = name.replace(" ", "%20");
|
name = name.replace(" ", "%20");
|
||||||
}
|
}
|
||||||
@ -112,16 +119,17 @@ public class ExportUtility {
|
|||||||
try {
|
try {
|
||||||
String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml,
|
String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml,
|
||||||
PlaceholderUtils.getInspectReplaceRules(userData));
|
PlaceholderUtils.getInspectReplaceRules(userData));
|
||||||
|
|
||||||
File playerFolder = new File(playersFolder, name);
|
File playerFolder = new File(playersFolder, name);
|
||||||
playerFolder.mkdirs();
|
playerFolder.mkdirs();
|
||||||
|
|
||||||
File inspectHtmlFile = new File(playerFolder, "index.html");
|
File inspectHtmlFile = new File(playerFolder, "index.html");
|
||||||
inspectHtmlFile.createNewFile();
|
inspectHtmlFile.createNewFile();
|
||||||
|
|
||||||
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
|
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.toLog("Export.inspectPage: " + name, e);
|
Log.toLog("Export.writeInspectHtml: " + name, e);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user