mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-04-08 20:45:39 +02: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.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
import fr.neatmonster.nocheatplus.NoCheatPlus;
|
||||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||||
|
|
||||||
@ -138,18 +140,27 @@ public class ConfigManager {
|
|||||||
if (globalFile.exists())
|
if (globalFile.exists())
|
||||||
try {
|
try {
|
||||||
globalConfig.load(globalFile);
|
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) {
|
} catch (final Exception e) {
|
||||||
|
Bukkit.getLogger().severe("[NoCheatPlus] Could not load config.yml (see exception below). Continue with default settings...");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
globalConfig.options().header(
|
globalConfig.options().header(
|
||||||
"Configuration generated by NoCheatPlus " + plugin.getDescription().getVersion() + ".");
|
"Configuration generated by NoCheatPlus " + plugin.getDescription().getVersion() + ".");
|
||||||
globalConfig.options().copyHeader(true);
|
globalConfig.options().copyHeader(true);
|
||||||
}
|
try {
|
||||||
try {
|
globalConfig.save(globalFile);
|
||||||
globalConfig.save(globalFile);
|
} catch (final Exception e) {
|
||||||
} catch (final Exception e) {
|
Bukkit.getLogger().severe("[NoCheatPlus] Could not save default config.yml (see exception below).");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
globalConfig.regenerateActionLists();
|
globalConfig.regenerateActionLists();
|
||||||
worldsMap.put(null, globalConfig);
|
worldsMap.put(null, globalConfig);
|
||||||
@ -199,10 +210,16 @@ public class ConfigManager {
|
|||||||
try {
|
try {
|
||||||
worldConfig.load(worldFile);
|
worldConfig.load(worldFile);
|
||||||
worldsMap.put(worldEntry.getKey(), worldConfig);
|
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) {
|
} catch (final Exception e) {
|
||||||
System.out.println("[NoCheatPlus] Couldn't load world-specific configuration for "
|
Bukkit.getLogger().severe("[NoCheatPlus] Couldn't load world-specific configuration for "
|
||||||
+ worldEntry.getKey() + "!");
|
+ worldEntry.getKey() + " (see exception below). Continue with global default settings...");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
worldConfig.regenerateActionLists();
|
worldConfig.regenerateActionLists();
|
||||||
|
Loading…
Reference in New Issue
Block a user