diff --git a/src/main/java/cc/happyareabean/sjm/SimpleJoinMessage.java b/src/main/java/cc/happyareabean/sjm/SimpleJoinMessage.java index 8b911c8..296e74e 100644 --- a/src/main/java/cc/happyareabean/sjm/SimpleJoinMessage.java +++ b/src/main/java/cc/happyareabean/sjm/SimpleJoinMessage.java @@ -2,6 +2,7 @@ import cc.happyareabean.sjm.commands.SJMCommand; import cc.happyareabean.sjm.config.SJMConfig; +import cc.happyareabean.sjm.config.SJMMisc; import cc.happyareabean.sjm.listener.PlayerJoinListener; import cc.happyareabean.sjm.listener.UpdateNotifyListener; import cc.happyareabean.sjm.utils.AdventureWebEditorAPI; @@ -38,6 +39,7 @@ public class SimpleJoinMessage extends JavaPlugin { @Getter private AdventureWebEditorAPI adventureWebEditorAPI; @Getter private BukkitCommandHandler commandHandler; @Getter private SJMConfig SJMConfig; + @Getter private SJMMisc miscConfig; @Override public void onEnable() { @@ -46,6 +48,7 @@ public void onEnable() { getLogger().info("Loading settings..."); SJMConfig = new SJMConfig(new File(getDataFolder(), "settings.yml").toPath()); + miscConfig = new SJMMisc(new File(getDataFolder(), "misc.yml").toPath()); getLogger().info("Registering listener..."); getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this); @@ -78,7 +81,7 @@ public void onEnable() { getLogger().info("SimpleJoinMessage version " + getDescription().getVersion() + " has been successfully enabled!"); - checkUpdate(); + if (miscConfig.isUpdateChecker()) checkUpdate(); } public void checkUpdate() { diff --git a/src/main/java/cc/happyareabean/sjm/config/SJMMisc.java b/src/main/java/cc/happyareabean/sjm/config/SJMMisc.java new file mode 100644 index 0000000..e533ece --- /dev/null +++ b/src/main/java/cc/happyareabean/sjm/config/SJMMisc.java @@ -0,0 +1,58 @@ +package cc.happyareabean.sjm.config; + +import de.exlll.configlib.annotation.Comment; +import de.exlll.configlib.configs.yaml.YamlConfiguration; +import de.exlll.configlib.format.FieldNameFormatters; +import lombok.Getter; +import lombok.Setter; + +import java.nio.file.Path; +import java.util.Arrays; + +@Getter @Setter +@SuppressWarnings("FieldMayBeFinal") +public class SJMMisc extends YamlConfiguration { + + public final Path path; + + @Comment({ + "Enable updater checker?", + " ", + "Depends on your need, but we generally recommend to keep it enable.", + "So you won't miss any update! :)" + }) + private boolean updateChecker = true; + + public SJMMisc(Path path) { + super(path, YamlProperties.builder() + .setFormatter(FieldNameFormatters.IDENTITY) + .setPrependedComments(Arrays.asList( + "------------------------------------------------------------------------", + " ", + " _____ _ _ _ _ __ __ ", + " / ____(_) | | | | (_) | \\/ | ", + " | (___ _ _ __ ___ _ __ | | ___ | | ___ _ _ __ | \\ / | ___ ___ ___ __ _ __ _ ___ ", + " \\___ \\| | '_ ` _ \\| '_ \\| |/ _ \\_ | |/ _ \\| | '_ \\| |\\/| |/ _ \\/ __/ __|/ _` |/ _` |/ _ \\", + " ____) | | | | | | | |_) | | __/ |__| | (_) | | | | | | | | __/\\__ \\__ \\ (_| | (_| | __/", + " |_____/|_|_| |_| |_| .__/|_|\\___|\\____/ \\___/|_|_| |_|_| |_|\\___||___/___/\\__,_|\\__, |\\___|", + " | | __/ | ", + " |_| |___/ ", + " ", + " SimpleJoinMessage misc configuration - misc.yml", + " ", + "------------------------------------------------------------------------", + " ", + "https://go.happyareabean.cc/sjm", + " ", + "------------------------------------------------------------------------" + )).build()); + this.path = path; + + this.loadAndSave(); + } + + public void reloadAndSave() { + load(); + save(); + } +}