Skip to content

Commit 777ef03

Browse files
committed
fix: prevent reloading core DevSystem plugin to avoid system breakage
1 parent 2599f48 commit 777ef03

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/main/java/de/steyon/devSystem/pluginmanager/PluginManagerGUI.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,15 @@ public void openPluginDetailsGUI(Player player, Plugin targetPlugin) {
398398
.click(e -> {
399399
e.setCancelled(true);
400400
if (player.hasPermission("devsystem.pluginmanager.reload")) {
401+
// Prevent reloading the core DevSystem plugin to avoid breaking the system
402+
if (targetPlugin.getName().equalsIgnoreCase(plugin.getName())) {
403+
player.sendMessage(miniMessage.deserialize(
404+
plugin.getConfigManager().getValue("config.yml", "plugin-manager.cannot-reload-core",
405+
"<prefix><red>Cannot reload core system plugin</red><dark_gray>: </dark_gray><aqua>{plugin}</aqua>")
406+
.replace("{plugin}", targetPlugin.getName())
407+
));
408+
return;
409+
}
401410
openConfirmGUI(player,
402411
plugin.getConfigManager().getValue("config.yml", "plugin-manager.confirm-reload", "<yellow>Reload {plugin}?</yellow>").replace("{plugin}", targetPlugin.getName()),
403412
() -> {

src/main/java/de/steyon/devSystem/pluginmanager/PluginManagerService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ public boolean reloadPlugin(Plugin target, Player player) {
337337
}
338338
return false;
339339
}
340+
// Prevent reloading the core DevSystem plugin to avoid breaking the system
341+
if (target.getName().equalsIgnoreCase(plugin.getName())) {
342+
if (player != null) {
343+
player.sendMessage(miniMessage.deserialize(
344+
plugin.getConfigManager().getValue("config.yml", "plugin-manager.cannot-reload-core",
345+
"<prefix><red>Cannot reload core system plugin</red><dark_gray>: </dark_gray><aqua>{plugin}</aqua>")
346+
.replace("{plugin}", target.getName())
347+
));
348+
}
349+
return false;
350+
}
340351
boolean smartReload = plugin.getConfigManager().getValue("config.yml", "plugin-manager.settings.smart-reload", true);
341352
if (!smartReload) {
342353
pluginManager.disablePlugin(target);

src/main/resources/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ plugin-manager:
106106
plugin-not-found: "<prefix><red>Plugin not found<dark_gray>: {plugin}</red>"
107107
cannot-disable-has-dependents: "<prefix><red>Cannot disable {plugin}, dependents<dark_gray>: </dark_gray><aqua>{dependents}</aqua>"
108108
cannot-disable-core: "<prefix><red>Cannot disable core system plugin</red><dark_gray>: </dark_gray><aqua>{plugin}</aqua>"
109+
cannot-reload-core: "<prefix><red>Cannot reload core system plugin</red><dark_gray>: </dark_gray><aqua>{plugin}</aqua>"
109110

110111
# Command help messages
111112
command-help:

0 commit comments

Comments
 (0)