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

Add comments to config file

This commit is contained in:
Shy
2026-04-02 19:57:27 +02:00
parent 7907ee87f6
commit c4e1aedeca
3 changed files with 48 additions and 13 deletions
@@ -28,7 +28,10 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import static de.shiewk.smoderation.paper.command.VanishCommand.isVanished;
import static de.shiewk.smoderation.paper.command.VanishCommand.toggleVanish;
@@ -181,14 +184,29 @@ public final class SModerationPaper extends JavaPlugin {
boolean changedSomething = false;
for (String key : defaultConfig.getKeys(true)) {
if (!config.contains(key)) { // There's a new key in the default config
if (!config.contains(key)) {
// There's a new key in the default config
config.set(key, defaultConfig.get(key));
changedSomething = true;
}
List<String> defaultComments = new ArrayList<>(defaultConfig.getComments(key));
List<String> comments = new ArrayList<>(config.getComments(key));
defaultComments.removeIf(Objects::isNull);
comments.removeIf(Objects::isNull);
if (!defaultComments.equals(comments)) {
// Comments changed
config.setComments(key, defaultConfig.getComments(key));
changedSomething = true;
}
}
// Save the updated configuration file
if (changedSomething) saveConfig();
if (changedSomething){
LOGGER.info("Changing config file to add new options/documentation");
saveConfig();
}
} catch (Exception e) {
throw new RuntimeException("Could not update config", e);
+27 -10
View File
@@ -1,3 +1,27 @@
# If enabled, punishments can no longer be issued without providing a reason.
force-reason: false
# Allows you to toggle specific plugin features.
features:
# Should punishments be tracked and executed?
# Note that disabling this will also disable the SMod menu and
# /modlogs command since their only use is viewing punishments
punishments: true
# Should commands for opening the SMod menu be registered?
smodmenu: true
# Should commands for viewing player inventories be registered?
invsee: true
# Should commands for viewing player ender chests be registered?
enderchestsee: true
# Should commands for teleporting to offline players be registered?
offlinetp: true
# Should commands for viewing other players' messaging commands be registered?
socialspy: true
# Should players be able to enable vanish mode?
vanish: true
# A list of commands which will be captured and broadcast
# to players which have SocialSpy enabled (/socialspy).
socialspy-commands:
- w
- tell
@@ -9,7 +33,8 @@ socialspy-commands:
- minecraft:msg
- minecraft:teammsg
- minecraft:tm
force-reason: false
# A list of commands which muted players will not be able to run.
muted-forbidden-commands:
- w
- tell
@@ -22,12 +47,4 @@ muted-forbidden-commands:
- minecraft:msg
- minecraft:teammsg
- minecraft:tm
- minecraft:me
features:
punishments: true
smodmenu: true
invsee: true
enderchestsee: true
offlinetp: true
socialspy: true
vanish: true
- minecraft:me