mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-06 06:41:41 +01:00
Only save back config if loading was successful (Ticket 179). Adapt
messages on config failures, log on severe level.
This commit is contained in:
parent
fa8f1cc4cb
commit
ad1e1b2cd9
@ -14,6 +14,8 @@ import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
|
||||
@ -138,18 +140,27 @@ public class ConfigManager {
|
||||
if (globalFile.exists())
|
||||
try {
|
||||
globalConfig.load(globalFile);
|
||||
// Quick shallow ugly fix: only save back if loading was successful.
|
||||
try {
|
||||
globalConfig.save(globalFile);
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Could not save back config.yml (see exception below).");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Could not load config.yml (see exception below). Continue with default settings...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
else {
|
||||
globalConfig.options().header(
|
||||
"Configuration generated by NoCheatPlus " + plugin.getDescription().getVersion() + ".");
|
||||
globalConfig.options().copyHeader(true);
|
||||
}
|
||||
try {
|
||||
globalConfig.save(globalFile);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
globalConfig.save(globalFile);
|
||||
} catch (final Exception e) {
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Could not save default config.yml (see exception below).");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
globalConfig.regenerateActionLists();
|
||||
worldsMap.put(null, globalConfig);
|
||||
@ -199,10 +210,16 @@ public class ConfigManager {
|
||||
try {
|
||||
worldConfig.load(worldFile);
|
||||
worldsMap.put(worldEntry.getKey(), worldConfig);
|
||||
worldConfig.save(worldFile);
|
||||
try{
|
||||
worldConfig.save(worldFile);
|
||||
} catch (final Exception e){
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Couldn't save back world-specific configuration for "
|
||||
+ worldEntry.getKey() + " (see exception below).");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
System.out.println("[NoCheatPlus] Couldn't load world-specific configuration for "
|
||||
+ worldEntry.getKey() + "!");
|
||||
Bukkit.getLogger().severe("[NoCheatPlus] Couldn't load world-specific configuration for "
|
||||
+ worldEntry.getKey() + " (see exception below). Continue with global default settings...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
worldConfig.regenerateActionLists();
|
||||
|
Loading…
Reference in New Issue
Block a user