Skip to content

Commit

Permalink
Fixed commands missing after loading a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenni0451 committed Jan 22, 2023
1 parent 0d5d251 commit 29f4f80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ org.gradle.configureondemand=true
#Maven settings
maven_name=SpigotPluginManager
maven_group=net.lenni0451
maven_version=2.7.2
maven_version=2.7.3
updatable=true
12 changes: 12 additions & 0 deletions src/main/java/net/lenni0451/spm/utils/PluginUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ public Plugin loadPlugin(final String name) {
// throw new IllegalStateException("Unable to add to plugin list");
throw new IllegalStateException(I18n.t("pm.pluginutils.loadPlugin.notAdded"));
}
try { //Synchronize the commands between client/server on newer versions
Method syncCommands = Bukkit.getServer().getClass().getDeclaredMethod("syncCommands");
syncCommands.setAccessible(true);
syncCommands.invoke(Bukkit.getServer());
} catch (Throwable ignored) {
}
return targetPlugin;
}

Expand Down Expand Up @@ -363,6 +369,12 @@ public void unloadPlugin(final Plugin plugin) {
for (String s : I18n.mt("pm.pluginutils.unloadPlugin.unknownClassLoader")) Logger.sendConsole(s);
}

try { //Synchronize the commands between client/server on newer versions
Method syncCommands = Bukkit.getServer().getClass().getDeclaredMethod("syncCommands");
syncCommands.setAccessible(true);
syncCommands.invoke(Bukkit.getServer());
} catch (Throwable ignored) {
}
System.gc(); //Hopefully remove all leftover plugin classes and references
}

Expand Down

0 comments on commit 29f4f80

Please sign in to comment.