Package net.realdarkstudios.commons.util
Class AutoUpdater
java.lang.Object
net.realdarkstudios.commons.util.AutoUpdater
- Direct Known Subclasses:
RDSCommonsUpdater
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAutoUpdater(org.bukkit.plugin.Plugin plugin, String dataURL, String versionURL, AutoUpdater.Parser parser) Creates an auto-updater for a given Plugin. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprotected abstract voidintReturns the result of the last update checkGets the new version stringGets the parser type of the currentAutoUpdaterGets the map of replacementsbooleanCheck if there is an update that needs to be downloaded/installedstatic voidioExceptionHandler(IOException ioexc) parseMavenMetadata(URL readURL, Map<String, String> replacements) static VersionparseVersion(String versionToParse) voidsetParser(AutoUpdater.Parser parser) Sets the parser.voidsetReplacements(Map<String, String> replacements) Sets the map of replacements.protected abstract voidprotected abstract voidstatusBehind(Version newVer, String newVerInput) protected abstract voidvoidupdateBranch(String newBranch) Updates the branch of the readURL
-
Constructor Details
-
AutoUpdater
public AutoUpdater(org.bukkit.plugin.Plugin plugin, String dataURL, String versionURL, AutoUpdater.Parser parser) Creates an auto-updater for a given Plugin. There is no need to create more than one auto updater, as this may have bad consequences.- Parameters:
plugin- ThePluginthat owns this auto updater.dataURL- The URL to check for updates from. Put '%b%' wherever the branch would go in the URL.versionURL- The URL to grab a version file from. Put '%b%' where the branch would go, and '%v%' where the version would go.parser- TheAutoUpdater.Parserto use, which determines how to parse the URL data. For a CUSTOM parser type, use Parser.CUSTOM.setParser() to set your custom parsing method
-
-
Method Details
-
getParser
Gets the parser type of the currentAutoUpdater- Returns:
- The Parser
-
setParser
Sets the parser. -
getReplacements
Gets the map of replacements- Returns:
- The
Mapwith all replacements
-
setReplacements
Sets the map of replacements. For example, if you have a version that will not be correctly parsed, you can set a replacement for it.
(snapshot-24w13a in this case is something that will not get parsed)
Ex. Putting in("snapshot-24w13a", "1.0.0.0-snapshot-24w13a")will plug in"1.0.0.0-snapshot-24w13a"into theVersion#fromStringcall, which will be parsed.- Parameters:
replacements- The map of replacements
-
updateBranch
Updates the branch of the readURL- Parameters:
newBranch- which branch to use- Since:
- 0.3.0.1
-
hasUpdate
public boolean hasUpdate()Check if there is an update that needs to be downloaded/installed- Returns:
trueif there is a newer version available for download,falseif not- Since:
- 0.3.0.0
-
getNewestVersion
Gets the new version string- Returns:
- The newest version
- Since:
- 0.3.0.0
-
getLastCheckResult
public int getLastCheckResult()Returns the result of the last update check- Returns:
- -1 if plugin version is BEHIND, 0 if it is UP-TO-DATE, 1 if it is AHEAD, and 10000 for ERROR
-
checkForUpdate
public void checkForUpdate() -
applyUpdate
public void applyUpdate() -
statusBehind
-
statusUpToDate
protected abstract void statusUpToDate() -
statusAhead
protected abstract void statusAhead() -
errorChecking
protected abstract void errorChecking() -
ioExceptionHandler
-
parseVersion
-
parseMavenMetadata
-