Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update notifier #44

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/armamc/plugincontrol/PluginControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,6 +22,7 @@ public void onEnable() {
registerConfig();
registerCommands();
registerTask();
registerUpdateNotifier();
}

@Override
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public List<String> 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) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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: {}
plugins: [ ]
groups: { }