org.inventivetalent.update.spiget.UpdateCallback Java Examples
The following examples show how to use
org.inventivetalent.update.spiget.UpdateCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateCheckerGitHub.java From SkinsRestorerX with GNU General Public License v3.0 | 6 votes |
@Override public void checkForUpdate(final UpdateCallback callback) { try { HttpURLConnection connection = (HttpURLConnection) new URL(String.format(RELEASES_URL, this.resourceId)).openConnection(); connection.setRequestProperty("User-Agent", this.userAgent); JsonObject apiResponse = new JsonParser().parse(new InputStreamReader(connection.getInputStream())).getAsJsonObject(); this.releaseInfo = new Gson().fromJson(apiResponse, GitHubReleaseInfo.class); releaseInfo.assets.forEach(gitHubAssetInfo -> { releaseInfo.latestDownloadURL = gitHubAssetInfo.browser_download_url; if (this.isVersionNewer(this.currentVersion, releaseInfo.tag_name)) { callback.updateAvailable(releaseInfo.tag_name, gitHubAssetInfo.browser_download_url, true); } else { callback.upToDate(); } }); } catch (Exception e) { // this.log.log(Level.WARNING, "Failed to get release info from api.github.com."); } }
Example #2
Source File: SkinsRestorer.java From SkinsRestorerX with GNU General Public License v3.0 | 6 votes |
private void checkUpdate(boolean showUpToDate) { ProxyServer.getInstance().getScheduler().runAsync(this, () -> { updateChecker.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) { outdated = true; updateChecker.getUpdateAvailableMessages(newVersion, downloadUrl, hasDirectDownload, getVersion(), false).forEach(msg -> { console.sendMessage(new TextComponent(msg)); }); } @Override public void upToDate() { if (!showUpToDate) return; updateChecker.getUpToDateMessages(getVersion(), false).forEach(msg -> { console.sendMessage(new TextComponent(msg)); }); } }); }); }
Example #3
Source File: SkinsRestorer.java From SkinsRestorerX with GNU General Public License v3.0 | 6 votes |
private void checkUpdate(boolean bungeeMode, boolean showUpToDate) { Sponge.getScheduler().createAsyncExecutor(this).execute(() -> { updateChecker.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) { updateChecker.getUpdateAvailableMessages(newVersion, downloadUrl, hasDirectDownload, getVersion(), bungeeMode).forEach(msg -> { console.sendMessage(parseMessage(msg)); }); } @Override public void upToDate() { if (!showUpToDate) return; updateChecker.getUpToDateMessages(getVersion(), bungeeMode).forEach(msg -> { console.sendMessage(parseMessage(msg)); }); } }); }); }
Example #4
Source File: SkinsRestorer.java From SkinsRestorerX with GNU General Public License v3.0 | 6 votes |
private void checkUpdate(boolean showUpToDate) { getService().execute(() -> { updateChecker.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) { outdated = true; updateChecker.getUpdateAvailableMessages(newVersion, downloadUrl, hasDirectDownload, getVersion(), false).forEach(msg -> { console.sendMessage(deserialize(msg)); }); } @Override public void upToDate() { if (!showUpToDate) return; updateChecker.getUpToDateMessages(getVersion(), false).forEach(msg -> { console.sendMessage(deserialize(msg)); }); } }); }); }
Example #5
Source File: Wild.java From WildernessTp with MIT License | 6 votes |
private void checkUpdate(){ SpigetUpdate updater = new SpigetUpdate(this,18431); updater.setVersionComparator(VersionComparator.SEM_VER); updater.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) { if(instance.getConfig().getBoolean("AutoUpdate")) { if (hasDirectDownload) { if (updater.downloadUpdate()) { getLogger().info("New version of the plugin downloaded and will be loaded on restart"); } else { getLogger().warning("Update download failed, reason is " + updater.getFailReason()); } } }else{ getLogger().info("There is an update available please go download it"); } } @Override public void upToDate() { getLogger().info("You are using the latest version thanks"); } }); }
Example #6
Source File: PlayerListener.java From AnimatedFrames with MIT License | 6 votes |
@EventHandler public void on(final PlayerJoinEvent event) { Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { @Override public void run() { for (AnimatedFrame frame : plugin.frameManager.getFrames()) { frame.addViewer(event.getPlayer()); } } }, 20); if (event.getPlayer().hasPermission("animatedframes.updatecheck")) { plugin.spigetUpdate.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String s, String s1, boolean b) { plugin.updateAvailable = true; event.getPlayer().sendMessage("§aA new version for §6AnimatedFrames §ais available (§7v" + s + "§a). Download it from https://r.spiget.org/5583"); } @Override public void upToDate() { } }); } }
Example #7
Source File: SkinsRestorer.java From SkinsRestorerX with GNU General Public License v3.0 | 5 votes |
private void checkUpdate(boolean bungeeMode, boolean showUpToDate) { Bukkit.getScheduler().runTaskAsynchronously(this, () -> { updateChecker.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) { if (updateDownloaded) return; String failReason = null; if (hasDirectDownload) { if (updateDownloader.downloadUpdate()) { updateDownloaded = true; } else { failReason = updateDownloader.getFailReason().toString(); } } updateChecker.getUpdateAvailableMessages(newVersion, downloadUrl, hasDirectDownload, getVersion(), bungeeMode, true, failReason).forEach(msg -> { console.sendMessage(msg); }); } @Override public void upToDate() { if (!showUpToDate) return; updateChecker.getUpToDateMessages(getVersion(), bungeeMode).forEach(msg -> { console.sendMessage(msg); }); } }); }); }
Example #8
Source File: PacketListenerPlugin.java From PacketListenerAPI with MIT License | 5 votes |
@Override public void onEnable() { if (!packetListenerAPI.injected) { getLogger().warning("Injection failed. Disabling..."); Bukkit.getPluginManager().disablePlugin(this); return; } try { SpigetUpdate updater = new SpigetUpdate(this, 2930); updater.setUserAgent("PacketListenerAPI/" + getDescription().getVersion()).setVersionComparator(VersionComparator.SEM_VER_SNAPSHOT); updater.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String s, String s1, boolean b) { getLogger().info("There is a new version available: https://r.spiget.org/2930"); } @Override public void upToDate() { getLogger().info("Plugin is up-to-date"); } }); } catch (Exception e) { e.printStackTrace(); } new Metrics(this, 225); //Initialize this API if the plugin got enabled APIManager.initAPI(PacketListenerAPI.class); }
Example #9
Source File: SpigetUpdater.java From RedProtect with GNU General Public License v3.0 | 5 votes |
/** * Check is a new version is available * * @param sender * @param silent - if true the player will not get the status in Game */ public void checkForUpdate(final CommandSender sender, final boolean silent) { if (!silent) sender.sendMessage("[RedProtect] Checking for updates ..."); if (updateAvailable != UpdateStatus.RESTART_NEEDED) { spigetUpdate = new SpigetUpdate(plugin, 15841); spigetUpdate.setVersionComparator(VersionComparator.EQUAL); spigetUpdate.setUserAgent("RedProtect-" + plugin.getDescription().getVersion()); spigetUpdate.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String newVersion, String downloadUrl, boolean hasDirectDownload) { //// VersionComparator.EQUAL handles all updates as new, so I have to check the //// version number manually updateAvailable = isUpdateNewerVersion(newVersion); if (updateAvailable == UpdateStatus.AVAILABLE) { newDownloadVersion = newVersion; sender.sendMessage(ChatColor.GOLD + "[RedProtect] New update found: " + ChatColor.GREEN + newVersion); if (plugin.config.configRoot().update.auto_update) { downloadAndUpdateJar(sender); sender.sendMessage(ChatColor.GOLD + "[RedProtect] " + ChatColor.GREEN + "Plugin updated. Restart server to complete the update."); } else sender.sendMessage(ChatColor.GOLD + "[RedProtect] " + ChatColor.GREEN + "Please use '/rp update' to update to " + newDownloadVersion); } } @Override public void upToDate() { //// Plugin is up-to-date if (!silent) sender.sendMessage("[RedProtect] " + ChatColor.RESET + "No update available."); } }); } }
Example #10
Source File: NickNamerPlugin.java From NickNamer with MIT License | 4 votes |
@Override public void onEnable() { instance = this; APIManager.initAPI(PacketListenerAPI.class); APIManager.initAPI(NickNamerAPI.class); Bukkit.getPluginManager().registerEvents(this, this); saveDefaultConfig(); reload(); if (featureCommandGeneral) { PluginAnnotations.COMMAND.registerCommands(this, generalCommands = new GeneralCommands(this)); } else { getLogger().info("General commands disabled"); } if (featureCommandNick) { PluginAnnotations.COMMAND.registerCommands(this, nickCommands = new NickCommands(this)); } else { getLogger().info("Nick commands disabled"); } if (featureCommandSkin) { PluginAnnotations.COMMAND.registerCommands(this, skinCommands = new SkinCommands(this)); } else { getLogger().info("Skin commands disabled"); } if (bungeecord) { if (Bukkit.getOnlineMode()) { getLogger().warning("Bungeecord is enabled, but server is in online mode!"); } Bukkit.getMessenger().registerIncomingPluginChannel(this, channelIdentifier, this); Bukkit.getMessenger().registerOutgoingPluginChannel(this, channelIdentifier); } //Replace the default NickManager new PluginNickManager(this); switch (storageType.toLowerCase()) { case "temporary": getLogger().info("Using temporary storage"); break; case "local": initStorageLocal(); break; case "sql": getLogger().info("Using SQL storage (" + sqlUser + "@" + sqlAddress + ")"); initStorageSQL(); break; case "redis": throw new RuntimeException("Redis storage is currently not supported."); // getLogger().info("Using Redis storage (" + redisHost + ":" + redisPort + ")"); // initStorageRedis(); // break; } new Metrics(this); spigetUpdate = new SpigetUpdate(this, 5341).setUserAgent("NickNamer/" + getDescription().getVersion()).setVersionComparator(VersionComparator.SEM_VER_SNAPSHOT); spigetUpdate.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String s, String s1, boolean b) { getLogger().info("A new version is available (" + s + "). Download it from https://r.spiget.org/5341"); } @Override public void upToDate() { getLogger().info("The plugin is up-to-date."); } }); if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) { getLogger().info("Registering placeholders."); new NickNamerPlaceholders().register(); } ; }
Example #11
Source File: AnimatedFramesPlugin.java From AnimatedFrames with MIT License | 4 votes |
@Override public void onEnable() { if (!Bukkit.getPluginManager().isPluginEnabled("MapManager")) { getLogger().warning("**************************************************"); getLogger().warning(" "); getLogger().warning(" This plugin depends on MapManager "); getLogger().warning(" https://r.spiget.org/19198 "); getLogger().warning(" "); getLogger().warning("**************************************************"); Bukkit.getPluginManager().disablePlugin(this); return; } saveDefaultConfig(); PluginAnnotations.CONFIG.load(this, this); PluginAnnotations.COMMAND.load(this, new Commands(this)); maxAnimateDistanceSquared = maxAnimateDistance * maxAnimateDistance; frameManager = new FrameManager(this); frameExecutor = Executors.newCachedThreadPool(); Bukkit.getPluginManager().registerEvents(interactListener = new InteractListener(this), this); Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this); Bukkit.getPluginManager().registerEvents(new ClickListener(this), this); File cacheDir = new File(getDataFolder(), "cache"); if (!cacheDir.exists()) { cacheDir.mkdirs(); } getLogger().fine("Waiting 2 seconds before loading data..."); Bukkit.getScheduler().runTaskLaterAsynchronously(this, new Runnable() { @Override public void run() { getLogger().info("Loading data..."); frameExecutor.execute(new Runnable() { @Override public void run() { frameManager.readFramesFromFile(); getLogger().info("Loaded " + frameManager.size() + " frames."); } }); } }, 40); new Metrics(this); spigetUpdate = new SpigetUpdate(this, 5583).setUserAgent("AnimatedFrames/" + getDescription().getVersion()).setVersionComparator(VersionComparator.SEM_VER_SNAPSHOT); spigetUpdate.checkForUpdate(new UpdateCallback() { @Override public void updateAvailable(String s, String s1, boolean b) { updateAvailable = true; getLogger().info("A new version is available (" + s + "). Download it from https://r.spiget.org/5583"); // getLogger().info("(If the above version is lower than the installed version, you are probably up-to-date)"); } @Override public void upToDate() { getLogger().info("The plugin is up-to-date."); } }); }