1
mirror of https://github.com/Shiewk/SModeration.git synced 2026-04-28 05:54:16 +02:00

(1.8.0) Allow disabling plugin features from the config (#10)

This commit is contained in:
Shy
2025-09-19 18:09:52 +02:00
parent 4ef2700d6b
commit 4b52f74fc5
4 changed files with 53 additions and 26 deletions
+9 -1
View File
@@ -1,7 +1,15 @@
# SModeration config # SModeration config
| Key | What it does | | Key | What it does |
|--------------------------|--------------------------------------------------------------------| |--------------------------|------------------------------------------------------------------------------------------------------------------------|
| socialspy-commands | The commands that `/socialspy` will listen to. | | socialspy-commands | The commands that `/socialspy` will listen to. |
| force-reason | Whether a reason is required for every punishment. | | force-reason | Whether a reason is required for every punishment. |
| muted-forbidden-commands | Commands that players are not allowed to run while they are muted. | | muted-forbidden-commands | Commands that players are not allowed to run while they are muted. |
| features | Controls which plugin features are enabled. |
| features.punishments | Whether the plugin provides punishing features (kick, ban, mute) |
| features.smodmenu | If punishments are enabled, controls whether the SMod Menu can be opened. Has no effect when punishments are disabled. |
| features.invsee | Whether the plugin provides invsee feature |
| features.enderchestsee | Whether the plugin provides enderchestsee feature |
| features.offlinetp | Whether the plugin provides the offlinetp feature |
| features.socialspy | Whether the plugin provides the SocialSpy feature |
| features.vanish | Whether the plugin provides the vanish feature |
+1 -1
View File
@@ -1 +1 @@
pluginVersion = 1.7.1 pluginVersion = 1.8.0
@@ -72,31 +72,44 @@ public final class SModerationPaper extends JavaPlugin {
updateConfig(); updateConfig();
} }
public boolean isFeatureEnabled(String feature){
return getConfig().getBoolean("features."+feature, true);
}
@Override @Override
public void onEnable() { public void onEnable() {
listen(new PunishmentListener()); LOGGER.info("Folia: {}", SchedulerUtil.isFolia ? "yes" : "no");
if (isFeatureEnabled("punishments")) listen(new PunishmentListener());
if (isFeatureEnabled("invsee")) listen(new InvSeeListener());
if (isFeatureEnabled("enderchestsee")) listen(new EnderchestSeeListener());
if (isFeatureEnabled("socialspy")) listen(new SocialSpyListener());
if (isFeatureEnabled("vanish")) listen(new VanishListener());
listen(new CustomInventoryListener()); listen(new CustomInventoryListener());
listen(new InvSeeListener());
listen(new EnderchestSeeListener());
listen(new VanishListener());
listen(new ChatInputListener()); listen(new ChatInputListener());
listen(new SocialSpyListener());
getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> { getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> {
Commands commands = event.registrar(); Commands commands = event.registrar();
if (isFeatureEnabled("punishments")){
registerCommand(commands, new KickCommand()); registerCommand(commands, new KickCommand());
registerCommand(commands, new ModLogsCommand()); registerCommand(commands, new ModLogsCommand());
registerCommand(commands, new SModCommand());
registerCommand(commands, new InvseeCommand());
registerCommand(commands, new EnderchestSeeCommand());
registerCommand(commands, new SocialSpyCommand());
registerCommand(commands, new VanishCommand());
registerCommand(commands, new UnmuteCommand()); registerCommand(commands, new UnmuteCommand());
registerCommand(commands, new UnbanCommand()); registerCommand(commands, new UnbanCommand());
registerCommand(commands, new MuteCommand()); registerCommand(commands, new MuteCommand());
registerCommand(commands, new BanCommand()); registerCommand(commands, new BanCommand());
registerCommand(commands, new OfflineTPCommand());
if (isFeatureEnabled("smodmenu")){
registerCommand(commands, new SModCommand());
}
}
if (isFeatureEnabled("invsee")) registerCommand(commands, new InvseeCommand());
if (isFeatureEnabled("enderchestsee")) registerCommand(commands, new EnderchestSeeCommand());
if (isFeatureEnabled("socialspy")) registerCommand(commands, new SocialSpyCommand());
if (isFeatureEnabled("vanish")) registerCommand(commands, new VanishCommand());
if (isFeatureEnabled("offlinetp")) registerCommand(commands, new OfflineTPCommand());
}); });
if (SchedulerUtil.isFolia){ if (SchedulerUtil.isFolia){
@@ -109,8 +122,6 @@ public final class SModerationPaper extends JavaPlugin {
SchedulerUtil.scheduleGlobalRepeating(PLUGIN, ChatInput::tickAll, 1, 1); SchedulerUtil.scheduleGlobalRepeating(PLUGIN, ChatInput::tickAll, 1, 1);
container.load(SAVE_FILE); container.load(SAVE_FILE);
LOGGER.info("Folia: {}", SchedulerUtil.isFolia ? "yes" : "no");
} }
private void listen(Listener listener) { private void listen(Listener listener) {
+8
View File
@@ -23,3 +23,11 @@ muted-forbidden-commands:
- minecraft:teammsg - minecraft:teammsg
- minecraft:tm - minecraft:tm
- minecraft:me - minecraft:me
features:
punishments: true
smodmenu: true
invsee: true
enderchestsee: true
offlinetp: true
socialspy: true
vanish: true