Consistent handling of wz files and their paths
This commit is contained in:
@@ -21,18 +21,18 @@
|
||||
*/
|
||||
package provider;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import provider.wz.WZFile;
|
||||
import provider.wz.WZFiles;
|
||||
import provider.wz.XMLWZFile;
|
||||
|
||||
public class MapleDataProviderFactory {
|
||||
private final static String wzPath = System.getProperty("wzpath");
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
private static MapleDataProvider getWZ(File in, boolean provideImages) {
|
||||
public class MapleDataProviderFactory {
|
||||
private static MapleDataProvider getWZ(File in) {
|
||||
if (in.getName().toLowerCase().endsWith("wz") && !in.isDirectory()) {
|
||||
try {
|
||||
return new WZFile(in, provideImages);
|
||||
return new WZFile(in, false);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Loading WZ File failed", e);
|
||||
}
|
||||
@@ -41,15 +41,7 @@ public class MapleDataProviderFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static MapleDataProvider getDataProvider(File in) {
|
||||
return getWZ(in, false);
|
||||
}
|
||||
|
||||
public static MapleDataProvider getImageProvidingDataProvider(File in) {
|
||||
return getWZ(in, true);
|
||||
}
|
||||
|
||||
public static File fileInWZPath(String filename) {
|
||||
return new File(wzPath, filename);
|
||||
public static MapleDataProvider getDataProvider(WZFiles in) {
|
||||
return getWZ(in.getFile());
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package provider.wz;
|
||||
|
||||
import provider.MapleDataProviderFactory;
|
||||
import tools.data.input.GenericLittleEndianAccessor;
|
||||
import tools.data.input.InputStreamByteStream;
|
||||
import tools.data.input.LittleEndianAccessor;
|
||||
@@ -69,7 +68,7 @@ public class ListWZFile {
|
||||
if (listWz != null) {
|
||||
ListWZFile listwz;
|
||||
try {
|
||||
listwz = new ListWZFile(MapleDataProviderFactory.fileInWZPath("List.wz"));
|
||||
listwz = new ListWZFile(WZFiles.LIST.getFile());
|
||||
modernImgs = new HashSet<>(listwz.getEntries());
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
35
src/main/java/provider/wz/WZFiles.java
Normal file
35
src/main/java/provider/wz/WZFiles.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package provider.wz;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public enum WZFiles {
|
||||
QUEST("Quest"),
|
||||
ETC("Etc"),
|
||||
ITEM("Item"),
|
||||
CHARACTER("Character"),
|
||||
STRING("String"),
|
||||
LIST("List"),
|
||||
MOB("Mob"),
|
||||
MAP("Map"),
|
||||
NPC("Npc"),
|
||||
REACTOR("Reactor"),
|
||||
SKILL("Skill"),
|
||||
SOUND("Sound"),
|
||||
UI("UI");
|
||||
|
||||
public static final String DIRECTORY = "wz";
|
||||
|
||||
private final String fileName;
|
||||
|
||||
WZFiles(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return new File(getFilePath());
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return String.format("%s/%s.wz", DIRECTORY, fileName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user