Fixes one JavaDoc mistake (one linebreak is missing)

Changes some variable names (e.g. to lowerCamelCase to fulfill the java convention)
Changes .replaceAll to .replace where no regex is needed (Same output everywhere)
Removes .replaceAll(":", "-") in ManageUtils.backup because no ':' is present in the String that it replaces (and it's every time the same in terms of the construction)
Changes '(Long start) ->' to 'start' in ManageUtils.containsCombinable
This commit is contained in:
Fuzzlemann 2017-07-24 15:47:23 +02:00
parent 31b432d01e
commit 4c317221f4
4 changed files with 12 additions and 11 deletions

View File

@ -36,6 +36,7 @@ public class HtmlUtils {
resourceStream = plugin.getResource(fileName);
scanner = new Scanner(resourceStream);
}
StringBuilder html = new StringBuilder();
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
@ -77,7 +78,7 @@ public class HtmlUtils {
String ip = Plan.getInstance().getVariable().getIp() + ":" + port;
boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
if (useAlternativeIP) {
ip = Settings.ALTERNATIVE_IP.toString().replaceAll("%port%", "" + port);
ip = Settings.ALTERNATIVE_IP.toString().replace("%port%", "" + port);
}
return "//" + ip + "/server";
}
@ -101,7 +102,7 @@ public class HtmlUtils {
String ip = Plan.getInstance().getVariable().getIp() + ":" + port;
boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
if (useAlternativeIP) {
ip = Settings.ALTERNATIVE_IP.toString().replaceAll("%port%", "" + port);
ip = Settings.ALTERNATIVE_IP.toString().replace("%port%", "" + port);
}
return "//" + ip + "/player/" + playerName;
}
@ -179,13 +180,13 @@ public class HtmlUtils {
Html.COLOR_a, Html.COLOR_b, Html.COLOR_c, Html.COLOR_d, Html.COLOR_e, Html.COLOR_f};
for (Html html : replacer) {
string = string.replaceAll("§" + html.name().charAt(6), html.parse());
string = string.replace("§" + html.name().charAt(6), html.parse());
}
int spans = string.split("<span").length - 1;
for (int i = 0; i < spans; i++) {
string = Html.SPAN.parse(string);
}
return string.replaceAll("§r", "");
return string.replace("§r", "");
}
public static String separateWithQuotes(String... strings) {

View File

@ -29,7 +29,7 @@ public class ManageUtils {
*/
public static boolean backup(String dbName, Database copyFromDB) throws SQLException {
Plan plugin = Plan.getInstance();
String timeStamp = new Date().toString().substring(4, 10).replaceAll(" ", "-").replaceAll(":", "-");
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
String fileName = dbName + "-backup-" + timeStamp;
SQLiteDB backupDB = new SQLiteDB(plugin, fileName);
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
@ -95,7 +95,7 @@ public class ManageUtils {
.anyMatch(s -> sessions.stream()
.filter(ses -> !ses.equals(s))
.map(SessionData::getSessionStart)
.anyMatch((Long start) -> (Math.abs(s.getSessionEnd() - start) < threshold)));
.anyMatch(start -> Math.abs(s.getSessionEnd() - start) < threshold));
}
/**

View File

@ -25,7 +25,8 @@ public class ExportUtility {
/**
*
* @return @throws IOException
* @return
* @throws IOException
*/
public static File getFolder() throws IOException {
String path = Settings.ANALYSIS_EXPORT_PATH.toString();
@ -124,10 +125,10 @@ public class ExportUtility {
Files.write(analysisHtmlFile.toPath(), Collections.singletonList(analysisHtml));
}
private static void writePlayersPageHtml(List<UserData> rawData, File playersfolder) throws IOException {
private static void writePlayersPageHtml(List<UserData> rawData, File playersFolder) throws IOException {
String playersHtml = PlayersPageResponse.buildContent(rawData);
playersfolder.mkdirs();
File playersHtmlFile = new File(playersfolder, "index.html");
playersFolder.mkdirs();
File playersHtmlFile = new File(playersFolder, "index.html");
Files.write(playersHtmlFile.toPath(), Collections.singletonList(playersHtml));
}

View File

@ -175,5 +175,4 @@ public class ManageUtilsTest {
SessionData exp3 = new SessionData(threshold * 8, threshold * 10);
assertEquals(exp3, result.get(2));
}
}