public class UpdateChecker extends Object
| Constructor and Description |
|---|
UpdateChecker(org.bukkit.plugin.java.JavaPlugin plugin,
UpdateCheckSource updateCheckSource,
String parameter)
Initializes an UpdateChecker instance.
|
UpdateChecker(org.bukkit.plugin.java.JavaPlugin plugin,
VersionSupplier supplier)
Initializes an UpdateChecker instance with a custom
VersionSupplier. |
| Modifier and Type | Method and Description |
|---|---|
UpdateChecker |
checkEveryXHours(double hours)
Starts to check every X hours for updates.
|
UpdateChecker |
checkNow()
Checks for updates now and sends the result to the console when
notifyRequesters is set to true (default)
|
UpdateChecker |
checkNow(org.bukkit.command.CommandSender... requesters)
Checks for updates now and sends the result to the given list of
CommandSenders.
|
List<String> |
getAppropriateDownloadLinks()
Returns a list of applicable Download links.
|
String |
getChangelogLink()
Returns the changelog link
|
String |
getDonationLink()
Returns the donation link
|
static UpdateChecker |
getInstance()
Deprecated.
As of SpigotUpdateChecker 1.4.0, more than one instance can exist at the same time. Keep track of the instances you created yourself.
|
UpdateCheckResult |
getLastCheckResult()
Returns the last successful UpdateCheckResult
|
String |
getLatestVersion()
Returns the latest version string found by the UpdateChecker, or null if all
checks until yet have failed.
|
String |
getNameFreeVersion()
Returns the name/suffix of the free plugin version
|
String |
getNamePaidVersion()
Returns the name/suffix of the paid plugin version
|
String |
getNotifyPermission()
Returns the permission required to receive UpdateChecker messages on join
|
BiConsumer<org.bukkit.command.CommandSender[],Exception> |
getOnFail()
Gets the task that will run when/after the update check fails.
|
BiConsumer<org.bukkit.command.CommandSender[],String> |
getOnSuccess()
Gets the task that will run when/after the update check succeeds.
|
protected org.bukkit.plugin.Plugin |
getPlugin()
Gets the plugin that instantiated this UpdateChecker instance
|
static com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler |
getScheduler()
Gets the TaskScheduler instance used by the UpdateChecker
|
String |
getSpigotUserId()
Gets the Spigot User ID of the user who downloaded the plugin if it's a premium plugin, otherwise "%%__USER__%%"
|
String |
getSupportLink()
Returns the support link
|
String |
getUsedVersion()
Gets the version string of the currently used plugin version
|
static UpdateChecker |
init(org.bukkit.plugin.java.JavaPlugin plugin,
int spigotResourceId)
Deprecated.
Use
UpdateChecker(JavaPlugin, UpdateCheckSource, String) instead. |
static UpdateChecker |
init(org.bukkit.plugin.java.JavaPlugin plugin,
String apiLink)
Deprecated.
Use
UpdateChecker(JavaPlugin, UpdateCheckSource, String) instead. |
boolean |
isCheckedAtLeastOnce()
Checks whether the update checker already ran.
|
boolean |
isColoredConsoleOutput()
Returns whether colored console output is enabled
|
boolean |
isNotifyOpsOnJoin()
Returns whether OPs will be notified on join when a new version is available
|
boolean |
isNotifyRequesters()
Gets whether the given CommandSenders will be informed about UpdateChecker results
|
static boolean |
isOtherVersionNewer(String myVersion,
String otherVersion)
Checks whether one version is really newer than another according to the semantic versioning scheme, including letters.
|
boolean |
isSuppressUpToDateMessage()
Returns whether the message "You are using the latest version of
|
boolean |
isUsingLatestVersion()
Checks whether the latest found version of the plugin is being used.
|
boolean |
isUsingPaidVersion()
Returns whether the paid version of the plugin is installed.
|
UpdateChecker |
onFail(BiConsumer<org.bukkit.command.CommandSender[],Exception> onFail)
Sets a task that will run when/after the update check has failed.
|
UpdateChecker |
onSuccess(BiConsumer<org.bukkit.command.CommandSender[],String> onSuccess)
Sets a task that will run when/after the update check has succeeded.
|
UpdateChecker |
setChangelogLink(int resourceId)
Sets a link to your plugin's changelog generated from your plugin's SpigotMC/Polymart
Resource ID
|
UpdateChecker |
setChangelogLink(String link)
Sets a link to your plugin's changelog.
|
UpdateChecker |
setColoredConsoleOutput(boolean coloredConsoleOutput)
Sets whether or not the used and latest version will be displayed in color in the console
|
UpdateChecker |
setDonationLink(String donationLink)
Sets a link to your plugin's donation website
|
UpdateChecker |
setDownloadLink(int resourceId)
Sets the download link for your plugin generated from your plugin's SpigotMC/Polymart
Resource ID.
|
UpdateChecker |
setDownloadLink(String downloadLink)
Sets the download link for your plugin.
|
UpdateChecker |
setFreeDownloadLink(int resourceId)
Sets the download link for the free version of your plugin generated from
your plugin's SpigotMC/Polymart Resource ID.
|
UpdateChecker |
setFreeDownloadLink(String freeDownloadLink)
Sets the download link for the free version of your plugin.
|
UpdateChecker |
setNameFreeVersion(String nameFreeVersion)
Sets the name/suffix for the free version's name.
|
UpdateChecker |
setNamePaidVersion(String namePaidVersion)
Sets the name/suffix for the paid version's name.
|
UpdateChecker |
setNotifyByPermissionOnJoin(String permission)
Sets the permission needed to be informed about UpdateChecker results on join.
|
UpdateChecker |
setNotifyOpsOnJoin(boolean notifyOpsOnJoin)
Whether or not to inform OPs on join when there is a new version available.
|
UpdateChecker |
setNotifyRequesters(boolean notify)
Whether or not CommandSenders who request an update check will be notified of the result.
|
UpdateChecker |
setPaidDownloadLink(int resourceId)
Sets the download link for the paid version of your plugin generated from
your plugin's SpigotMC/Polymart Resource ID.
|
UpdateChecker |
setPaidDownloadLink(String link)
Sets the download link for the paid version of your plugin.
|
UpdateChecker |
setSupportLink(String link)
Sets a link to your plugin's support channel.
|
UpdateChecker |
setTimeout(int timeout)
Sets the timeout for the HTTP(S) connection in milliseconds. 0 = use Java's
default value
|
UpdateChecker |
setUsedVersion(String usedVersion)
Sets the version string of the currently used plugin version.
|
UpdateChecker |
setUserAgent(String userAgent)
Sets the UserAgent string using plain text
|
UpdateChecker |
setUserAgent(UserAgentBuilder userAgentBuilder)
Sets the UserAgent string using a UserAgentBuilder
|
UpdateChecker |
setUsingPaidVersion(boolean paidVersion)
Tells the UpdateChecker whether the server already uses the paid version of
your plugin.
|
UpdateChecker |
stop()
Stops the scheduled update checks.
|
UpdateChecker |
suppressUpToDateMessage(boolean suppress)
Sets whether the message "You are using the latest version of
|
public UpdateChecker(@NotNull
org.bukkit.plugin.java.JavaPlugin plugin,
@NotNull
VersionSupplier supplier)
VersionSupplier.plugin - Instance of your pluginsupplier - VersionSupplier that supplies the latest version of your pluginpublic UpdateChecker(@NotNull
org.bukkit.plugin.java.JavaPlugin plugin,
@NotNull
UpdateCheckSource updateCheckSource,
@NotNull
String parameter)
plugin - Instance of your pluginupdateCheckSource - Source where to check for updates. To use a custom source, see UpdateChecker(JavaPlugin, VersionSupplier)parameter - Parameter for the update checker source. See UpdateCheckSource for more informatino@Deprecated public static UpdateChecker getInstance()
UpdateChecker(JavaPlugin, UpdateCheckSource, String) wasn't called yet.@Deprecated public static UpdateChecker init(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, int spigotResourceId)
UpdateChecker(JavaPlugin, UpdateCheckSource, String) instead.plugin - Main class of your pluginspigotResourceId - SpigotMC Resource ID to get the latest version String
from the SpigotMC Web API@Deprecated public static UpdateChecker init(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull String apiLink)
UpdateChecker(JavaPlugin, UpdateCheckSource, String) instead.plugin - Main class of your pluginapiLink - HTTP(S) link to a file containing a string with the latest
version of your plugin.public boolean isSuppressUpToDateMessage()
public UpdateChecker checkEveryXHours(double hours)
hours - Amount of hours in between checkspublic UpdateChecker stop()
public UpdateChecker checkNow(@Nullable org.bukkit.command.CommandSender... requesters)
requesters - CommandSenders to send the result to, or nullpublic boolean isUsingLatestVersion()
public static boolean isOtherVersionNewer(String myVersion, String otherVersion)
myVersion - One version stringotherVersion - Another version stringpublic BiConsumer<org.bukkit.command.CommandSender[],Exception> getOnFail()
public BiConsumer<org.bukkit.command.CommandSender[],String> getOnSuccess()
public UpdateChecker checkNow()
public List<String> getAppropriateDownloadLinks()
If using the free version and there are links for the free and paid version, element 0 will be the link to the paid version and element will be the link to the free version
If using the paid version, there will be only one element containing the link to the paid version, or, if that is not set, the link to the free version.
If there is no paid version, there will be only one element containing the link to the free version, or, if that is not set, the link to the plus version.
If no download links are set, returns an empty list.
public String getChangelogLink()
public UpdateChecker setChangelogLink(int resourceId)
resourceId - Spigot/Polymart Resource IDpublic UpdateChecker setChangelogLink(@Nullable String link)
link - Changelog link@Nullable public String getSupportLink()
@NotNull public UpdateChecker setSupportLink(@Nullable String link)
link - Support linkpublic String getDonationLink()
public UpdateChecker setDonationLink(@Nullable String donationLink)
donationLink - Donation linkpublic UpdateCheckResult getLastCheckResult()
public String getLatestVersion()
public String getNameFreeVersion()
public UpdateChecker setNameFreeVersion(String nameFreeVersion)
nameFreeVersion - Name/suffix of the free plugin versionpublic String getNamePaidVersion()
public UpdateChecker setNamePaidVersion(String namePaidVersion)
namePaidVersion - Name/suffix of the paid plugin version@Nullable public String getNotifyPermission()
protected org.bukkit.plugin.Plugin getPlugin()
public static com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler getScheduler()
public String getSpigotUserId()
public String getUsedVersion()
public UpdateChecker setUsedVersion(String usedVersion)
usedVersion - new version stringpublic boolean isCheckedAtLeastOnce()
public boolean isColoredConsoleOutput()
public UpdateChecker setColoredConsoleOutput(boolean coloredConsoleOutput)
coloredConsoleOutput - Whether to use color in the console outputpublic boolean isNotifyOpsOnJoin()
public UpdateChecker setNotifyOpsOnJoin(boolean notifyOpsOnJoin)
notifyOpsOnJoin - Whether to inform on OPs on join when there is a new version availablepublic boolean isNotifyRequesters()
public UpdateChecker setNotifyRequesters(boolean notify)
notify - Whether or not to notify given CommandSenders about UpdateChecker resultspublic boolean isUsingPaidVersion()
public UpdateChecker setUsingPaidVersion(boolean paidVersion)
paidVersion - Whether or not the user is using the paid version of your pluginpublic UpdateChecker onFail(BiConsumer<org.bukkit.command.CommandSender[],Exception> onFail)
onFail - Task that will run when/after the update check has failed.public UpdateChecker onSuccess(BiConsumer<org.bukkit.command.CommandSender[],String> onSuccess)
onSuccess - Task that will run when/after the update check has succeeded.public UpdateChecker setDownloadLink(int resourceId)
resourceId - Spigot/Polymart Resource IDpublic UpdateChecker setDownloadLink(@Nullable String downloadLink)
downloadLink - Download linkpublic UpdateChecker suppressUpToDateMessage(boolean suppress)
suppress - Whether to suppress the message "You are using the latest version of public UpdateChecker setFreeDownloadLink(int resourceId)
resourceId - Spigot/Polymart Resource ID of the free versionpublic UpdateChecker setFreeDownloadLink(@Nullable String freeDownloadLink)
freeDownloadLink - Download link of the free versionpublic UpdateChecker setNotifyByPermissionOnJoin(@Nullable String permission)
permission - Permission needed to be informed about UpdateChecker results on joinpublic UpdateChecker setPaidDownloadLink(int resourceId)
resourceId - Spigot/Polymart Resource ID of the paid versionpublic UpdateChecker setPaidDownloadLink(@NotNull String link)
link - Download link of the paid versionpublic UpdateChecker setTimeout(int timeout)
timeout - Timeout in milliseconds, or 0 to use Java's default valuepublic UpdateChecker setUserAgent(@NotNull UserAgentBuilder userAgentBuilder)
userAgentBuilder - UserAgentBuilder instancepublic UpdateChecker setUserAgent(@Nullable String userAgent)
userAgent - UserAgent stringCopyright © 2021–2025 JEFF Media GbR. All rights reserved.