Fixes issue with file exporting in Windows system.
JAR files does not store files inside it with filesystem separator. Only spot where it makes sense to transform "/" into file separator is in output file saving.
This commit is contained in:
parent
e8e1d6184e
commit
575280d044
|
@ -12,6 +12,7 @@ import java.util.Optional;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
@ -263,7 +264,7 @@ public abstract class Addon {
|
||||||
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
jarResource = jarResource.replace("\\", File.separator).replace("/", File.separator);
|
jarResource = jarResource.replace('\\', '/');
|
||||||
try (JarFile jar = new JarFile(file)) {
|
try (JarFile jar = new JarFile(file)) {
|
||||||
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
||||||
if (jarConfig != null) {
|
if (jarConfig != null) {
|
||||||
|
@ -273,7 +274,9 @@ public abstract class Addon {
|
||||||
"The embedded resource '" + jarResource + "' cannot be found in " + jar.getName());
|
"The embedded resource '" + jarResource + "' cannot be found in " + jar.getName());
|
||||||
}
|
}
|
||||||
// There are two options, use the path of the resource or not
|
// There are two options, use the path of the resource or not
|
||||||
File outFile = new File(destinationFolder, jarResource);
|
File outFile = new File(destinationFolder,
|
||||||
|
jarResource.replaceAll("/", Matcher.quoteReplacement(File.separator)));
|
||||||
|
|
||||||
if (noPath) {
|
if (noPath) {
|
||||||
outFile = new File(destinationFolder, outFile.getName());
|
outFile = new File(destinationFolder, outFile.getName());
|
||||||
}
|
}
|
||||||
|
@ -308,7 +311,7 @@ public abstract class Addon {
|
||||||
throw new IllegalArgumentException("jarResource cannot be null or empty");
|
throw new IllegalArgumentException("jarResource cannot be null or empty");
|
||||||
}
|
}
|
||||||
YamlConfiguration result = new YamlConfiguration();
|
YamlConfiguration result = new YamlConfiguration();
|
||||||
jarResource = jarResource.replace("\\", File.separator).replace("/", File.separator);
|
jarResource = jarResource.replace('\\', '/');
|
||||||
try (JarFile jar = new JarFile(file)) {
|
try (JarFile jar = new JarFile(file)) {
|
||||||
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
||||||
if (jarConfig != null) {
|
if (jarConfig != null) {
|
||||||
|
@ -330,7 +333,7 @@ public abstract class Addon {
|
||||||
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
jarResource = jarResource.replace("\\", File.separator).replace("/", File.separator);
|
jarResource = jarResource.replace('\\', '/');
|
||||||
try (JarFile jar = new JarFile(file)) {
|
try (JarFile jar = new JarFile(file)) {
|
||||||
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
||||||
if (jarConfig != null) {
|
if (jarConfig != null) {
|
||||||
|
|
Loading…
Reference in New Issue