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
|
||||
*/
|
||||
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,10 +62,10 @@ public class Locale implements Closeable {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
|
||||
}
|
||||
} finally {
|
||||
Benchmark.stop("Enable", "Initializing locale");
|
||||
}
|
||||
}
|
||||
|
||||
private void writeNewDefaultLocale() throws IOException {
|
||||
final int length = messages.keySet().stream()
|
||||
|
@ -167,7 +167,7 @@ public class Analysis {
|
||||
|
||||
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
||||
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
|
||||
ExportUtility.export(plugin, analysisData, rawData);
|
||||
ExportUtility.export(analysisData, rawData);
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
plugin.processStatus().setStatus("Analysis", "Error: " + e);
|
||||
|
@ -54,25 +54,31 @@ public class ExportUtility {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
* @param analysisData
|
||||
* @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()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Benchmark.start("Exporting Html pages");
|
||||
try {
|
||||
File folder = getFolder();
|
||||
Log.debug("Export", "Folder: " + folder.getAbsolutePath());
|
||||
|
||||
writePlayersPageHtml(rawData, new File(folder, "players"));
|
||||
writeAnalysisHtml(analysisData, new File(folder, "server"));
|
||||
|
||||
File playersFolder = getPlayersFolder(folder);
|
||||
Log.debug("Export", "Player html files.");
|
||||
Log.debug("Export", "Player Page Folder: " + playersFolder.getAbsolutePath());
|
||||
|
||||
String playerHtml = HtmlUtils.getStringFromResource("player.html");
|
||||
|
||||
Benchmark.start("Exporting Player pages");
|
||||
rawData.forEach(userData -> writeInspectHtml(userData, playersFolder, playerHtml));
|
||||
Benchmark.stop("Exporting Player pages");
|
||||
} catch (IOException ex) {
|
||||
Log.toLog("ExportUtils.export", ex);
|
||||
} finally {
|
||||
@ -94,17 +100,18 @@ public class ExportUtility {
|
||||
/**
|
||||
* @param userData
|
||||
* @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()) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
String name = userData.getName();
|
||||
|
||||
if (name.endsWith(".")) {
|
||||
name = name.replace(".", "%2E");
|
||||
}
|
||||
|
||||
if (name.endsWith(" ")) {
|
||||
name = name.replace(" ", "%20");
|
||||
}
|
||||
@ -112,16 +119,17 @@ public class ExportUtility {
|
||||
try {
|
||||
String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml,
|
||||
PlaceholderUtils.getInspectReplaceRules(userData));
|
||||
|
||||
File playerFolder = new File(playersFolder, name);
|
||||
playerFolder.mkdirs();
|
||||
|
||||
File inspectHtmlFile = new File(playerFolder, "index.html");
|
||||
inspectHtmlFile.createNewFile();
|
||||
|
||||
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
|
||||
} catch (IOException e) {
|
||||
Log.toLog("Export.inspectPage: " + name, e);
|
||||
return false;
|
||||
Log.toLog("Export.writeInspectHtml: " + name, e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user