Skip to content

Commit

Permalink
fix set agent args
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Jan 23, 2024
1 parent 77338ae commit 6d01e2a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/org/cubewhy/celestial/game/addon/JavaAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static List<JavaAgent> findEnabled() {
if (javaAgentFolder.isDirectory()) {
for (File file : Objects.requireNonNull(javaAgentFolder.listFiles())) {
if (file.getName().endsWith(".jar") && file.isFile()) {
list.add(new JavaAgent(file));
list.add(new JavaAgent(file, JavaAgent.findAgentArg(file.getName())));
}
}
}
Expand All @@ -109,7 +109,7 @@ public static List<JavaAgent> findEnabled() {
if (javaAgentFolder.isDirectory()) {
for (File file : Objects.requireNonNull(javaAgentFolder.listFiles())) {
if (file.getName().endsWith(".jar.disabled") && file.isFile()) {
list.add(new JavaAgent(file));
list.add(new JavaAgent(file, JavaAgent.findAgentArg(file.getName())));
}
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public static void setArgFor(@NotNull JavaAgent agent, String arg) {
*/
public static void setArgFor(String name, String arg) {
JsonObject ja = config.getValue("javaagents").getAsJsonObject();
ja.addProperty(name, arg); // leave empty
ja.addProperty(name, arg);
config.setValue("javaagents", ja); // dump
}

Expand Down Expand Up @@ -215,6 +215,11 @@ public boolean isEnabled() {

@Override
public boolean toggle() {
if (isEnabled()) {
migrate(file.getName(), file.getName() + ".disabled");
} else {
migrate(file.getName(), file.getName().substring(0, file.getName().length() - 9));
}
return toggle0(file);
}
}

0 comments on commit 6d01e2a

Please sign in to comment.