package dev.marcospaulo.curiosidades; import org.bukkit.configuration.ConfigurationSection; import java.util.LinkedHashMap; import java.util.Map; /** * Typed view over config.yml. * *
Every setter writes through to disk immediately, so a command that changes
* behaviour survives a restart without anyone having to remember to save.
*/
final class Settings {
private final Curiosidades plugin;
Settings(Curiosidades plugin) {
this.plugin = plugin;
}
// --- triggering ---------------------------------------------------------
Mode mode() {
Mode mode = Mode.byKey(plugin.getConfig().getString("modo", "ENTRADA"));
return mode == null ? Mode.ENTRADA : mode;
}
void mode(Mode mode) {
set("modo", mode.name());
}
int intervalMinutes() {
return Math.max(1, plugin.getConfig().getInt("intervalo-minutos", 20));
}
void intervalMinutes(int minutes) {
set("intervalo-minutos", Math.max(1, minutes));
}
/** Seconds to wait after a join before announcing, so it lands after the join message. */
int joinDelaySeconds() {
return Math.max(0, plugin.getConfig().getInt("atraso-entrada-segundos", 6));
}
void joinDelaySeconds(int seconds) {
set("atraso-entrada-segundos", Math.max(0, seconds));
}
/** Minutes before the same player can be the subject again. */
int cooldownMinutes() {
return Math.max(0, plugin.getConfig().getInt("cooldown-minutos", 30));
}
void cooldownMinutes(int minutes) {
set("cooldown-minutos", Math.max(0, minutes));
}
/** How many recent facts to remember and avoid repeating. */
int noRepeat() {
return Math.max(0, plugin.getConfig().getInt("evitar-repetir", 15));
}
void noRepeat(int count) {
set("evitar-repetir", Math.max(0, count));
}
// --- presentation -------------------------------------------------------
boolean reactionsEnabled() {
return plugin.getConfig().getBoolean("reacoes-ativas", true);
}
void reactionsEnabled(boolean enabled) {
set("reacoes-ativas", enabled);
}
int reactionWindowSeconds() {
return Math.max(5, plugin.getConfig().getInt("janela-reacao-segundos", 90));
}
void reactionWindowSeconds(int seconds) {
set("janela-reacao-segundos", Math.max(5, seconds));
}
Map