Skip to content

Commit

Permalink
Add general.check-for-updates option to config.yml
Browse files Browse the repository at this point in the history
Allows users to disable the update check if they want to
  • Loading branch information
Tofpu committed Aug 15, 2024
1 parent 3135755 commit 36adcf0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
36 changes: 20 additions & 16 deletions spigot/src/main/java/io/tofpu/speedbridge2/SpeedBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,26 @@ public void enable() {
log("Loading the messages...");
Message.load(javaPlugin.getDataFolder());

log("Checking for an update...");
UpdateChecker.init(javaPlugin, 100619)
.requestUpdateCheck()
.whenComplete((updateResult, throwable) -> {
if (throwable != null) {
log("Couldn't check for an update...");
return;
}

if (updateResult.requiresUpdate()) {
log("You're using an outdated version of SpeedBridge!");
log("You can download the latest version at https://www.spigotmc.org/resources/.100619/");
} else {
log("You're using the latest version!");
}
});
if (ConfigurationManager.INSTANCE.getGeneralCategory().shouldCheckForUpdates()) {
log("Checking for an update...");
UpdateChecker.init(javaPlugin, 100619)
.requestUpdateCheck()
.whenComplete((updateResult, throwable) -> {
if (throwable != null) {
log("Couldn't check for an update...");
return;
}

if (updateResult.requiresUpdate()) {
log("You're using an outdated version of SpeedBridge!");
log("You can download the latest version at https://www.spigotmc.org/resources/.100619/");
} else {
log("You're using the latest version!");
}
});
} else {
log("Not checking for an update as it was explicitly disabled in the config.");
}
}

public void shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public final class GeneralCategory {
@Comment("The space gap between islands")
private int islandSpaceGap = 10;

@Setting("check-for-updates")
@Comment("Checks for an available update on startup. (default: true)")
private boolean checkForUpdates = true;

public boolean isDebugEnabled() {
return showDebugMessage;
}
Expand All @@ -28,4 +32,8 @@ public String getDefaultIslandCategory() {
public int getIslandSpaceGap() {
return islandSpaceGap;
}

public boolean shouldCheckForUpdates() {
return checkForUpdates;
}
}

0 comments on commit 36adcf0

Please sign in to comment.