@@ -27,7 +27,7 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
2727
2828 if (args .length >= 1 ) {
2929
30- if (!arg0 .hasPermission ("pluginmanager." + args [0 ])) {
30+ if (!arg0 .hasPermission ("pluginmanager." + args [0 ]) && ! arg0 . hasPermission ( "pluginmanager.admin" ) ) {
3131
3232 arg0 .sendMessage (prefix + "§cYou are lacking the permission 'pluginmanager." + args [0 ] + "'." );
3333 return false ;
@@ -39,8 +39,28 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
3939 if (args .length == 2 ) {
4040
4141 File file = new File (Server .getInstance ().getPluginPath (), (args [1 ].contains (".jar" ) ? args [1 ] : args [1 ] + ".jar" ));
42+
43+ if (!file .exists ()) {
44+
45+ for (File f : new File (Server .getInstance ().getPluginPath ()).listFiles ()) {
46+ if (f .getName ().startsWith (args [1 ])) {
47+ file = f ;
48+ break ;
49+ }
50+ }
51+
52+ }
53+
4254 if (file .exists ()) {
4355
56+ for (Plugin plugin : Server .getInstance ().getPluginManager ().getPlugins ().values ()) {
57+ File pluginfile = new File (plugin .getClass ().getProtectionDomain ().getCodeSource ().getLocation ().getPath ());
58+ if (file .getName ().equals (pluginfile .getName ())) {
59+ arg0 .sendMessage (prefix + "§c " + plugin .getName () + " is already loaded. Use /pluginmanager reload instead." );
60+ return false ;
61+ }
62+ }
63+
4464 Plugin plugin = Server .getInstance ().getPluginManager ().loadPlugin (file );
4565
4666 if (plugin != null ) {
@@ -79,7 +99,7 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
7999 }
80100
81101 if (plugin == PluginManagerInstance .plugin ) {
82- arg0 .sendMessage (prefix + "§cYou can not disable PluginManager." );
102+ arg0 .sendMessage (prefix + "§cYou can not unload PluginManager." );
83103 return false ;
84104 }
85105
@@ -143,11 +163,6 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
143163
144164 Plugin plugin = Server .getInstance ().getPluginManager ().getPlugin (args [1 ]);
145165
146- if (plugin == PluginManagerInstance .plugin ) {
147- arg0 .sendMessage (prefix + "§cYou can not disable PluginManager." );
148- return false ;
149- }
150-
151166 if (plugin == null ) {
152167 for (Plugin pl : Server .getInstance ().getPluginManager ().getPlugins ().values ()) {
153168 if (pl .getName ().toLowerCase ().startsWith (args [1 ].toLowerCase ())) {
@@ -156,6 +171,11 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
156171 }
157172 }
158173
174+ if (plugin == PluginManagerInstance .plugin ) {
175+ arg0 .sendMessage (prefix + "§cYou can not disable PluginManager." );
176+ return false ;
177+ }
178+
159179 if (plugin != null ) {
160180
161181 if (!plugin .isEnabled ()) {
@@ -180,23 +200,22 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
180200
181201 Plugin plugin = Server .getInstance ().getPluginManager ().getPlugin (args [1 ]);
182202
183- if (plugin == PluginManagerInstance .plugin ) {
184- arg0 .sendMessage (prefix + "§cYou can not disable PluginManager." );
185- return false ;
186- }
187-
188203 if (plugin == null ) {
189204 for (Plugin pl : Server .getInstance ().getPluginManager ().getPlugins ().values ()) {
190205 if (pl .getName ().toLowerCase ().startsWith (args [1 ].toLowerCase ())) {
191206 plugin = pl ;
192207 }
193208 }
194209 }
210+
211+ if (plugin == PluginManagerInstance .plugin ) {
212+ arg0 .sendMessage (prefix + "§cYou can not reload PluginManager." );
213+ return false ;
214+ }
215+
195216
196217 if (plugin != null ) {
197-
198-
199-
218+
200219 File file = new File (plugin .getClass ().getProtectionDomain ().getCodeSource ().getLocation ().getPath ());
201220
202221 long millis = System .currentTimeMillis ();
@@ -214,7 +233,6 @@ public boolean execute(CommandSender arg0, String arg1, String[] args) {
214233 try {
215234 Server .getInstance ().enablePlugin (Server .getInstance ().getPluginManager ().loadPlugin (file ));
216235 } catch (Exception e ) {
217- arg0 .sendMessage (prefix + "§cCouldn't load Plugin " + plugin .getName () + ". File renamed or deleted?" );
218236 }
219237
220238
@@ -255,7 +273,28 @@ public void run() {
255273 break ;
256274
257275 default :
258- arg0 .sendMessage (prefix + "§cDo /pluginmanager help" );
276+ if (arg0 instanceof Player ) {
277+ Player p = (Player ) arg0 ;
278+
279+ if (p .hasPermission ("pluginmanager.ui" )|| p .hasPermission ("pluginmanager.admin" )) {
280+
281+ Plugin plugin = Server .getInstance ().getPluginManager ().getPlugin (args [0 ]);
282+
283+ if (plugin == null ) {
284+ for (Plugin pl : Server .getInstance ().getPluginManager ().getPlugins ().values ()) {
285+ if (pl .getName ().toLowerCase ().startsWith (args [0 ].toLowerCase ())) {
286+ plugin = pl ;
287+ }
288+ }
289+ }
290+ if (plugin != null ) {
291+
292+ WindowFactory .openPluginWindow (p , plugin );
293+
294+ } else arg0 .sendMessage (prefix + "§cCould not find a plugin called " + args [0 ]+ ". Do /pluginmanager help" );
295+ } else p .sendMessage (prefix + "§cYou are lacking the permission 'pluginmanager.ui'" );
296+ } else arg0 .sendMessage (prefix + "§cDo /pluginmanager help" );
297+
259298 break ;
260299 }
261300
@@ -264,7 +303,7 @@ public void run() {
264303
265304 Player p = (Player ) arg0 ;
266305
267- if (p .hasPermission ("pluginmanager.ui" ))
306+ if (p .hasPermission ("pluginmanager.ui" ) || p . hasPermission ( "pluginmanager.admin" ) )
268307
269308 WindowFactory .openPluginListWindow (p );
270309
0 commit comments