diff --git a/build.gradle.kts b/build.gradle.kts index 918681b..b0ff700 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,10 +11,12 @@ version = "1.2.0-SNAPSHOT" repositories { mavenCentral() + maven("https://jitpack.io") maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") } dependencies { + implementation("com.github.TechnicJelle:UpdateCheckerJava:2.2") compileOnly(dependencyNotation = "org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") compileOnly(dependencyNotation = "net.kyori:adventure-api:4.14.0") compileOnly(dependencyNotation = "net.kyori:adventure-platform-bukkit:4.3.1") diff --git a/src/main/java/com/armamc/plugincontrol/PluginControl.java b/src/main/java/com/armamc/plugincontrol/PluginControl.java index 6ceb134..a8a6716 100644 --- a/src/main/java/com/armamc/plugincontrol/PluginControl.java +++ b/src/main/java/com/armamc/plugincontrol/PluginControl.java @@ -4,6 +4,7 @@ import com.armamc.plugincontrol.managers.ConfigManager; import com.armamc.plugincontrol.managers.MessageManager; import com.armamc.plugincontrol.managers.PluginsManager; +import com.technicjelle.UpdateChecker; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -21,6 +22,7 @@ public void onEnable() { registerConfig(); registerCommands(); registerTask(); + registerUpdateNotifier(); } @Override @@ -55,6 +57,14 @@ private void registerTask() { Bukkit.getScheduler().runTaskLater(this, pluginsManager::checkPlugins, 20L); } + private void registerUpdateNotifier() { + if (configManager.isUpdateNotifierEnabled()) { + UpdateChecker updateChecker = new UpdateChecker("SrBedrock", "PluginControl", "1.1.1"); + updateChecker.checkAsync(); + updateChecker.logUpdateMessage(getLogger()); + } + } + @Contract(pure = true) public ConfigManager getConfigManager() { return configManager; diff --git a/src/main/java/com/armamc/plugincontrol/managers/ConfigManager.java b/src/main/java/com/armamc/plugincontrol/managers/ConfigManager.java index a7be3c2..e819f46 100644 --- a/src/main/java/com/armamc/plugincontrol/managers/ConfigManager.java +++ b/src/main/java/com/armamc/plugincontrol/managers/ConfigManager.java @@ -46,6 +46,11 @@ public List getServerPlugins() { return Arrays.stream(Bukkit.getPluginManager().getPlugins()).toList().stream().map(Plugin::getName).toList(); } + // update + public boolean isUpdateNotifierEnabled() { + return config.getBoolean("update-notifier", false); + } + // enabled public boolean isEnabled() { if (config.getString(ENABLED) == null) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 81a5945..f130866 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,8 +1,9 @@ +update-notifier: false enabled: false # Action to take if all listed plugins are not enabled. # log-to-console # disallow-player-login # shutdown-server action: log-to-console -plugins: [] -groups: {} \ No newline at end of file +plugins: [ ] +groups: { }