Skip to content

Commit

Permalink
fix: 修复含空格的文件夹下无法加载插件
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSoulHanxi committed Jun 14, 2023
1 parent 911d66d commit de4088f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion agent/src/main/java/com/ixnah/hmcl/api/LoaderApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import org.pf4j.PluginManager;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.util.Comparator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -15,6 +17,7 @@

import static java.util.Objects.requireNonNull;

@SuppressWarnings("unused")
public class LoaderApi {

private LoaderApi() {
Expand Down Expand Up @@ -79,7 +82,12 @@ public static void setClassReadFlags(int flags) {

public static File getLoaderFile() {
if (LOADER_FILE == null) {
LOADER_FILE = new File(LoaderApi.class.getProtectionDomain().getCodeSource().getLocation().getFile());
String loaderLocation = LoaderApi.class.getProtectionDomain().getCodeSource().getLocation().getFile();
try {
LOADER_FILE = new File(URLDecoder.decode(loaderLocation, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return LOADER_FILE;
}
Expand Down

0 comments on commit de4088f

Please sign in to comment.