File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
src/main/java/org/hydev/mcpm/client/injector Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 16
16
import java .io .File ;
17
17
import java .io .IOException ;
18
18
import java .net .URLClassLoader ;
19
- import java .util .*;
19
+ import java .util .Arrays ;
20
+ import java .util .List ;
21
+ import java .util .Map ;
22
+ import java .util .SortedSet ;
20
23
21
24
import static org .hydev .mcpm .utils .ReflectionUtils .getPrivateField ;
22
25
import static org .hydev .mcpm .utils .ReflectionUtils .setPrivateField ;
@@ -74,13 +77,14 @@ public boolean loadPlugin(File jar)
74
77
}
75
78
76
79
@ Override
77
- public void unloadPlugin (String name ) throws PluginNotFoundException
80
+ public File unloadPlugin (String name ) throws PluginNotFoundException
78
81
{
79
82
var pm = Bukkit .getPluginManager ();
80
83
81
84
// 1. Find plugin by name
82
85
var plugin = Arrays .stream (pm .getPlugins ()).filter (p -> p .getName ().equalsIgnoreCase (name )).findFirst ()
83
86
.orElseThrow (() -> new PluginNotFoundException (name ));
87
+ var jar = new File (plugin .getClass ().getProtectionDomain ().getCodeSource ().getLocation ().getPath ());
84
88
85
89
// 2. Unload plugin
86
90
pm .disablePlugin (plugin );
@@ -127,6 +131,8 @@ public void unloadPlugin(String name) throws PluginNotFoundException
127
131
e .printStackTrace ();
128
132
}
129
133
}
134
+
135
+ return jar ;
130
136
}
131
137
132
138
@ Override
Original file line number Diff line number Diff line change 1
1
package org .hydev .mcpm .client .injector ;
2
2
3
+ import java .io .File ;
4
+
3
5
/**
4
6
* Interface for unloading a locally installed plugin.
5
7
*
@@ -12,6 +14,8 @@ public interface UnloadBoundary
12
14
* Dynamically unload a local plugin through JVM reflections and classloader hacks
13
15
*
14
16
* @param name Loaded plugin name
17
+ * @return Jar file
18
+ * @throws PluginNotFoundException If a loaded plugin of the name isn't found
15
19
*/
16
- void unloadPlugin (String name ) throws PluginNotFoundException ;
20
+ File unloadPlugin (String name ) throws PluginNotFoundException ;
17
21
}
You can’t perform that action at this time.
0 commit comments