Coder Social home page Coder Social logo

spiget-update's Introduction

Build Status GitHub release

Spigot & Bungeecord updater API which uses spiget.org to check for new versions

Usage

Check for new versions

SpigetUpdate updater = new SpigetUpdate(this, 12345);

// This compares versions just by checking if they are equal
// This means that older versions will also be treated as updates
updater.setVersionComparator(VersionComparator.EQUAL);

// This converts a semantic version to an integer and checks if the updated version is greater
updater.setVersionComparator(VersionComparator.SEM_VER);

updater.checkForUpdate(new UpdateCallback() {
	@Override
	public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) {
		//// A new version is available
		// newVersion - the latest version
		// downloadUrl - URL to the download
		// hasDirectDownload - whether the update is available for a direct download on spiget.org
	}

	@Override
	public void upToDate() {
		//// Plugin is up-to-date
	}
});

Download updates (Bukkit/Spigot)

final SpigetUpdate updater = new SpigetUpdate(this, 12345);
updater.checkForUpdate(new UpdateCallback() {
	@Override
	public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) {
		// First check if there is a direct download available
		// (Either the resources is hosted on spigotmc.org, or Spiget has a cached version to download)
		// external downloads won't work if they are disabled (by default) in spiget.properties
		if (hasDirectDownload) {
			if (updater.downloadUpdate()) {
				// Update downloaded, will be loaded when the server restarts
			} else {
				// Update failed
				getLogger().warning("Update download failed, reason is " + updater.getFailReason());
			}
		}
	}

	@Override
	public void upToDate() {
	}
});

Maven

<repositories>
    <repository>
        <id>inventive-repo</id>
        <url>https://repo.inventivetalent.org/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>org.inventivetalent.spiget-update</groupId>
        <artifactId>bukkit|bungee</artifactId>
        <version>VERSION</version>
    </dependency>
</dependencies>

spiget-update's People

Contributors

alexprogrammerde avatar derkades avatar inventivetalentdev avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

spiget-update's Issues

support for 1.11.2 & 1.12 ?

I've been using the SpigotUpdater1.0..1.jar file for all my worlds and it works when I type in /version on each of the worlds to check for the latest build. However, when I try to use the bungee-1.3.0.jar in the BungeeCord server plugin, it fails to startup. The same is true for bukkit-1.3.0.jar file.

My assumption since it isn't spelled out here, is the bukkit-1.3.0.jar goes in the world\plugins folder and the bungee-1.3.0.jar goes in the bungeecord server plugins folder. The only problem with both is there is no plugin.yml file included like the SpigotUpdater.jar file has, so how is this used?

Feature suggestions

  • Option to disable logging
  • callback on fail checking for updating (Not fail on downloading)
  • get update info (Update description etc.)
    I will make a pull request if you are interested in accepting these changes.

Error logs

Hello,

I have a small problem with the updater :

java.io.FileNotFoundException: http://api.spiget.org/v2/resources/38865?ut=1496861000391
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) ~[?:1.8.0_131]
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) ~[?:1.8.0_131]
        at be.flynrod.featherspawn.utils.Updater$1.run(Updater.java:63) [FeatherSpawn.jar:?]
        at be.flynrod.featherspawn.utils.CheckUpdate$1.dispatch(CheckUpdate.java:13) [FeatherSpawn.jar:?]
        at be.flynrod.featherspawn.utils.Updater.checkForUpdate(Updater.java:57) [FeatherSpawn.jar:?]
        at be.flynrod.featherspawn.utils.CheckUpdate.check(CheckUpdate.java:16) [FeatherSpawn.jar:?]
        at be.flynrod.featherspawn.Manager.initialize(Manager.java:43) [FeatherSpawn.jar:?]
        at be.flynrod.featherspawn.FeatherSpawn.onEnable(FeatherSpawn.java:68) [FeatherSpawn.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot.jar:git-Spigot-21fe707-e1ebe52]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]

Screenshot: https://image.prntscr.com/image/a90a6ebb3d314e08804cb5bbbd67ff9f.png

Downloads becomes corrupt and the plugin cannot be loaded

The downloaded jar cannot be loaded by bukkit, is there any way to fix this?
Here is a stacktrace of the exception thrown at runtime

[12:07:05 ERROR]: Could not load 'plugins\CombatActionBar.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.jaime29010.combatactionbar.Main'
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:297) [spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:202) [spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:540) [spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
Caused by: java.lang.ClassNotFoundException: me.jaime29010.combatactionbar.Main
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_101]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_101]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_101]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_101]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_101]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_101]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        ... 7 more
Caused by: java.io.IOException: invalid header field name: Manifest*Version
        at java.util.jar.Attributes.read(Unknown Source) ~[?:1.8.0_101]
        at java.util.jar.Manifest.read(Unknown Source) ~[?:1.8.0_101]
        at java.util.jar.Manifest.<init>(Unknown Source) ~[?:1.8.0_101]
        at java.util.jar.JarFile.getManifestFromReference(Unknown Source) ~[?:1.8.0_101]
        at java.util.jar.JarFile.getManifest(Unknown Source) ~[?:1.8.0_101]
        at sun.misc.URLClassPath$JarLoader$2.getManifest(Unknown Source) ~[?:1.8.0_101]
        at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.8.0_101]
        at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.8.0_101]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_101]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_101]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_101]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_101]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_101]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_101]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot_server.jar:git-Spigot-cf6dea3-ca1bb1c]
        ... 7 more

downloadUpdate() seems to be broken.

Im using Spiget Update in my plugins, but downloading new versions using downloadUpdate() seems to be broken. I have updated to your 1.4.5-SNAPSHOT but it still doesnt work.

Each time I call spiget.downloadUpdate() it fails with error 503 no service. hasDirectDownload is true although the link I get actually not is a direct download link ?

downloadUrl = https://spigotmc.org/resources/mobhunting.3582/download?version=449285

I have tried to make my own downloader but has not been able to solve the problem. I get either error 302 or 503 no matter how I try to download. I would be nice if you could take a look at this problem?

Failed to collect dependencies

Describe the bug
I tried to use PacketListenerAPI v3.9.5-SNAPSHOT as a dependency in my project. But, there was no jar in the Jitpack sadly due to an error in this project.

To Reproduce
Steps to reproduce the behavior:

  1. Clone PacketListenerAPI.
  2. Run mvn clean install -DskipTests
  3. Module api fails to build due to spiget-update not having a jar in the artifacts.

Expected behavior
Including this dependency with a jar in the artifacts.

Screenshots
image

Additional context

[ERROR] Failed to execute goal on project api: Could not resolve dependencies for project org.inventivetalent.packetlistenerapi:api:jar:3.9.5-SNAPSHOT: Failed to collect dependencies at org.inventivetalent.spiget-update:bukkit:jar:1.4.2-SNAPSHOT: Failed to read artifact descriptor for org.inventivetalent.spiget-update:bukkit:jar:1.4.2-SNAPSHOT: Could not transfer artifact org.inventivetalent.spiget-update:parent:pom:parent from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [md_5-repo (http://repo.md-5.net/content/repositories/public/, default, releases+snapshots)] -> [Help 1]

I think releasing a new version of this library would fix the issue of building PacketListenerAPI by Jitpack ๐Ÿค“

Download returned status #302

SpigetUpdate found an update. After calling the spigetUpdate.downloadUpdate() method I've got this error. The link to the update is: https://spigotmc.org/resources/kitpvp-ffa-1vs1.1583/download?version=455960.

java.lang.RuntimeException: Download returned status #302 at org.inventivetalent.update.spiget.download.UpdateDownloader.download(UpdateDownloader.java:64) ~[?:?] at org.inventivetalent.update.spiget.download.UpdateDownloader.lambda$downloadAsync$0(UpdateDownloader.java:48) ~[?:?] at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:82) [spigot-1.19-R0.1-SNAPSHOT.jar:3523-Spigot-1dffefb-effea36] at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:54) [spigot-1.19-R0.1-SNAPSHOT.jar:3523-Spigot-1dffefb-effea36] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?] at java.lang.Thread.run(Thread.java:833) [?:?]

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

maven
Bukkit/pom.xml
  • org.bukkit:bukkit 1.9-R0.1-SNAPSHOT
Bungee/pom.xml
  • net.md-5:bungeecord-api 1.16-R0.4
Core/pom.xml
  • com.google.code.gson:gson 2.9.0
  • junit:junit 4.13.2
pom.xml
  • org.inventivetalent.spiget-update:core 1.4.6-SNAPSHOT
  • org.inventivetalent.spiget-update:core 1.4.6-SNAPSHOT
  • org.apache.maven.plugins:maven-compiler-plugin 3.3
  • org.apache.maven.plugins:maven-shade-plugin 3.2.4

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.