Fixing indents !

This commit is contained in:
Đạt Nhân Trương
2022-08-02 23:14:17 +07:00
parent 4496e0854f
commit d9a86d6d75
32 changed files with 691 additions and 703 deletions

View File

@@ -50,7 +50,11 @@ import server.maps.*;
import tools.PacketCreator;
import tools.Pair;
import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ScheduledFuture;
@@ -448,8 +452,14 @@ public final class Channel {
private static String[] getEvents() {
List<String> events = new ArrayList<>();
for (File file : new File("scripts/event").listFiles()) {
events.add(file.getName().substring(0, file.getName().length() - 3));
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("scripts/event"))) {
for (Path path : stream) {
String fileName = path.getFileName().toString();
events.add(fileName.substring(0, fileName.length() - 3));
}
} catch (IOException e) {
log.warn("Unable to load events !");
e.printStackTrace();
}
return events.toArray(new String[0]);
}

View File

@@ -36,8 +36,7 @@ public enum WZFiles {
}
private static String getWzDirectory() {
// Either provide a custom directory path through the "wz-path" property when launching the .jar,
// or don't provide one to use the default "wz" directory
// Either provide a custom directory path through the "wz-path" property when launching the .jar, or don't provide one to use the default "wz" directory
String propertyPath = System.getProperty("wz-path");
if (propertyPath != null && new File(propertyPath).isDirectory()) {
return propertyPath;

View File

@@ -80,7 +80,8 @@ public class XMLDomMapleData implements Data {
boolean foundChild = false;
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE && childNode.getAttributes().getNamedItem("name").getNodeValue().equals(s)) {
if (childNode.getNodeType() == Node.ELEMENT_NODE
&& childNode.getAttributes().getNamedItem("name").getNodeValue().equals(s)) {
myNode = childNode;
foundChild = true;
break;

View File

@@ -233,7 +233,7 @@ public class SkillbookInformationProvider {
private static String readFileToString(Path file, String encoding) throws IOException {
Scanner scanner = new Scanner(file, encoding);
String text = "";
try(scanner) {
try (scanner) {
text = scanner.useDelimiter("\\A").next();

View File

@@ -23,7 +23,6 @@ import server.life.MonsterStats;
import tools.Pair;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.Connection;
import java.sql.PreparedStatement;

View File

@@ -3,7 +3,6 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -171,7 +170,6 @@ public class BossHpBarFetcher {
System.out.println("Reporting results...");
printReportFileHeader(printWriter);
printReportFileResults(printWriter);

View File

@@ -621,7 +621,8 @@ public class CashCosmeticsChecker {
printReportFileHeader();
if (!missingCosmeticsNpcTypes.isEmpty()) {
printWriter.println("Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries.");
printWriter.println(
"Found " + missingCosmeticsNpcTypes.size() + " entries with missing cosmetic entries.");
for (Pair<Pair<Integer, String>, List<Integer>> mcn : getSortedMapEntries(missingCosmeticsNpcTypes)) {
printWriter.println(" NPC " + mcn.getLeft());

View File

@@ -1,12 +1,9 @@
package tools.mapletools;
import provider.wz.WZDirectoryEntry;
import provider.wz.WZFileEntry;
import provider.wz.WZFiles;
import tools.Pair;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -267,7 +264,6 @@ public class CashDropFetcher {
}
private static void reportNxDropData() {
//NEED FUTURE UPDATE
try (con; PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_FILE))) {
System.out.println("Reading Character.wz ...");
ArrayList<Path> files = new ArrayList<>();

View File

@@ -3,7 +3,6 @@ package tools.mapletools;
import tools.Pair;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.*;

View File

@@ -3,7 +3,8 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -16,8 +17,8 @@ import java.sql.SQLException;
* a SQL table that the server will make use.
*/
public class CouponInstaller {
private static final File COUPON_INPUT_FILE_1 = new File(WZFiles.ITEM.getFilePath(), "/Cash/0521.img.xml");
private static final File COUPON_INPUT_FILE_2 = new File(WZFiles.ITEM.getFilePath(), "/Cash/0536.img.xml");
private static final Path COUPON_INPUT_FILE_1 = WZFiles.ITEM.getFile().resolve("Cash/0521.img.xml");
private static final Path COUPON_INPUT_FILE_2 = WZFiles.ITEM.getFile().resolve("Cash/0536.img.xml");
private static final Connection con = SimpleDatabaseConnection.getConnection();
private static BufferedReader bufferedReader = null;
private static byte status = 0;
@@ -192,20 +193,17 @@ public class CouponInstaller {
}
}
private static void installRateCoupons(File file) {
private static void installRateCoupons(Path file) {
// This will reference one line at a time
String line = null;
try {
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(fileReader);
try (BufferedReader br = Files.newBufferedReader(file)) {
bufferedReader = br;
while ((line = bufferedReader.readLine()) != null) {
translateToken(line);
}
bufferedReader.close();
fileReader.close();
} catch (FileNotFoundException ex) {
System.out.println("Unable to open file '" + file + "'");
} catch (IOException ex) {

View File

@@ -126,7 +126,8 @@ public class DojoUpdate {
if (!isDojoMapid) {
return;
}
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
try (PrintWriter pw = new PrintWriter(
Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
BufferedReader br = Files.newBufferedReader(file);) {
printWriter = pw;
bufferedReader = br;
@@ -168,7 +169,7 @@ public class DojoUpdate {
folder = INPUT_DIRECTORY.resolve(curPath);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(folder)) {
for (Path path : stream) {
if(Files.isRegularFile(path)) {
if (Files.isRegularFile(path)) {
try {
parseDojoData(path, curPath);
} catch (FileNotFoundException ex) {
@@ -196,6 +197,5 @@ public class DojoUpdate {
Duration durationBetween = Duration.between(instantStarted, instantStopped);
System.out.println("Get elapsed time in milliseconds: " + durationBetween.toMillis());
System.out.println("Get elapsed time in seconds: " + durationBetween.toSeconds());
}
}

View File

@@ -409,7 +409,7 @@ public class EmptyItemWzChecker {
private static void generateStringWz() throws IOException {
System.out.println("Generating clean String.wz ...");
String[][] stringWzFiles = {{"Cash", "Consume", "Ins", "Pet"}, {"Etc"}, {"Eqp"}};
String[][] stringWzFiles = { { "Cash", "Consume", "Ins", "Pet" }, { "Etc" }, { "Eqp" } };
String stringWzPath = "/String.wz/";
File folder = new File(OUTPUT_PATH + "/String.wz/");

View File

@@ -3,7 +3,6 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -358,7 +357,8 @@ public class EquipmentOmniLeveller {
}
private static void copyCashItemData(Path file, String curPath) throws IOException {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
try (PrintWriter pw = new PrintWriter(
Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
BufferedReader br = Files.newBufferedReader(file);) {
printWriter = pw;
bufferedReader = br;
@@ -370,8 +370,8 @@ public class EquipmentOmniLeveller {
}
private static void parseEquipData(Path file, String curPath) throws IOException {
try(PrintWriter pw = new PrintWriter(Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
try (PrintWriter pw = new PrintWriter(
Files.newOutputStream(OUTPUT_DIRECTORY.resolve(curPath).resolve(file.getFileName())));
BufferedReader br = Files.newBufferedReader(file);) {
printWriter = pw;
bufferedReader = br;
@@ -391,8 +391,6 @@ public class EquipmentOmniLeveller {
} catch (RuntimeException e) {
copyCashItemData(file, curPath);
}
}
private static void printFileFooter() {

View File

@@ -1,7 +1,6 @@
package tools.mapletools;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;
@@ -302,7 +301,7 @@ public class GachaponItemIdRetriever {
}
private static void setupDirectories(Path file) {
if(!Files.exists(file.getParent())) {
if (!Files.exists(file.getParent())) {
try {
Files.createDirectories(file.getParent());
} catch (IOException e) {
@@ -313,7 +312,7 @@ public class GachaponItemIdRetriever {
}
public static void main(String[] args) {
try(con) {
try (con) {
loadHandbookUseNames();
fetchDataOnMapleHandbook();
} catch (SQLException e) {

View File

@@ -3,7 +3,9 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
/**
@@ -72,18 +74,18 @@ public class MapFieldLimitChecker {
}
}
private static void listFiles(String directoryName, ArrayList<File> files) {
File directory = new File(directoryName);
// get all the files from a directory
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
files.add(file);
} else if (file.isDirectory()) {
listFiles(file.getAbsolutePath(), files);
private static void listFiles(Path directory, ArrayList<Path> files) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
for (Path path : stream) {
if (Files.isRegularFile(path)) {
files.add(path);
} else if (Files.isDirectory(path)) {
listFiles(path, files);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static int getMapIdFromFilename(String name) {
@@ -134,18 +136,17 @@ public class MapFieldLimitChecker {
private static void loadMapWz() throws IOException {
System.out.println("Reading Map.wz ...");
ArrayList<File> files = new ArrayList<>();
listFiles(WZFiles.MAP.getFilePath() + "/Map", files);
ArrayList<Path> files = new ArrayList<>();
listFiles(WZFiles.MAP.getFile().resolve("Map"), files);
for (File f : files) {
InputStreamReader fileReader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(fileReader);
for (Path f : files) {
try (BufferedReader br = Files.newBufferedReader(f)) {
bufferedReader = br;
mapid = getMapIdFromFilename(f.getName());
mapid = getMapIdFromFilename(f.getFileName().toString());
inspectMapEntry();
bufferedReader.close();
fileReader.close();
}
}
}

View File

@@ -3,9 +3,7 @@ package tools.mapletools;
import server.life.MonsterStats;
import tools.Pair;
import java.io.File;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;

View File

@@ -3,7 +3,6 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;

View File

@@ -3,9 +3,7 @@ package tools.mapletools;
import provider.*;
import provider.wz.WZFiles;
import java.io.File;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;

View File

@@ -3,7 +3,6 @@ package tools.mapletools;
import provider.wz.WZFiles;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;

View File

@@ -1,10 +1,11 @@
package tools.mapletools;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -40,15 +41,15 @@ public class ReactorDropFetcher {
}
private static void removeScriptedReactorids(String directoryName) {
File directory = new File(directoryName);
// get all the files from a directory
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
reactors.remove(getReactorIdFromFilename(file.getName()));
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(directoryName))) {
for (Path path : stream) {
if (Files.isRegularFile(path)) {
reactors.remove(getReactorIdFromFilename(path.getFileName().toString()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void loadReactoridsOnDB() throws SQLException {

View File

@@ -5,7 +5,6 @@ import server.ItemInformationProvider;
import tools.DatabaseConnection;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;

View File

@@ -4,7 +4,6 @@ import provider.wz.WZFiles;
import tools.Pair;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;

View File

@@ -3,10 +3,8 @@ package tools.mapletools;
import server.life.MonsterStats;
import tools.Pair;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Connection;

View File

@@ -6,7 +6,6 @@ import java.io.*;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.time.Duration;
import java.time.Instant;
@@ -151,7 +150,6 @@ public class SkillbookStackUpdate {
parseItemFile(path, outputDirectory.resolve(path.getFileName()));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}