mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Update notifications.
This commit is contained in:
@ -137,6 +137,33 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
|
||||
new PlotSquared(this, "Bukkit");
|
||||
|
||||
// Check for updates
|
||||
if (PlotSquared.get().getUpdateUtility() != null) {
|
||||
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
|
||||
updateUtility.checkForUpdate(this.getPluginVersionString(), ((updateDescription, throwable) -> {
|
||||
Bukkit.getScheduler().runTask(BukkitMain.this, () -> {
|
||||
getLogger().info("-------- PlotSquared Update Check --------");
|
||||
if (throwable != null) {
|
||||
getLogger().severe(String.format("Could not check for update. Reason: %s",
|
||||
throwable.getMessage()));
|
||||
} else {
|
||||
if (updateDescription == null) {
|
||||
getLogger().info("You appear to be running the latest version of PlotSquared. Congratulations!");
|
||||
} else {
|
||||
getLogger().info("There appears to be a PlotSquared update available!");
|
||||
getLogger().info(String.format("You are running version %s,"
|
||||
+ " the newest available version is %s", getPluginVersionString(), updateDescription.getVersion()));
|
||||
getLogger().info(String.format("Update URL: %s", updateDescription.getUrl()));
|
||||
}
|
||||
}
|
||||
getLogger().info("-------- PlotSquared Update Check --------");
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
getLogger().warning("Update checking disabled. Skipping.");
|
||||
}
|
||||
|
||||
if (Settings.Enabled_Components.METRICS) {
|
||||
this.startMetrics();
|
||||
} else {
|
||||
|
@ -631,6 +631,29 @@ import java.util.regex.Pattern;
|
||||
}
|
||||
EventUtil.manager.doJoinTask(pp);
|
||||
}, 20);
|
||||
|
||||
if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.s()) &&
|
||||
PlotSquared.get().getUpdateUtility() != null) {
|
||||
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
|
||||
final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class);
|
||||
updateUtility.checkForUpdate(bukkitMain.getPluginVersionString(), ((updateDescription, throwable) -> {
|
||||
if (throwable != null) {
|
||||
bukkitMain.getLogger().severe(String.format("Could not check for update. Reason: %s",
|
||||
throwable.getMessage()));
|
||||
} else {
|
||||
if (updateDescription != null) {
|
||||
new PlotMessage("-------- ").color("$2").text("PlotSquared Update Notification").color("$1").text(" --------").color("$2")
|
||||
.send(pp);
|
||||
new PlotMessage("There appears to be a PlotSquared update available!").color("$1").send(pp);
|
||||
new PlotMessage(String.format("You are running version %s,"
|
||||
+ " the newest available version is %s", bukkitMain.getPluginVersionString(), updateDescription.getVersion())).color("$1").send(pp);
|
||||
new PlotMessage("Update URL").color("$1").text(": ").color("$2").text(updateDescription.getUrl()).tooltip("Download update").send(pp);
|
||||
new PlotMessage("-------- ").color("$2").text("PlotSquared Update Notification").color("$1").text(" --------").color("$2")
|
||||
.send(pp);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
Reference in New Issue
Block a user