org.bukkit.Bukkit#getUpdateFolderFile ( )源码实例Demo

下面列出了org.bukkit.Bukkit#getUpdateFolderFile ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SkinsRestorerX   文件: UpdateDownloader.java
public Properties getUpdaterProperties() {
    File file = new File(Bukkit.getUpdateFolderFile(), "spiget.properties");
    Properties properties = new Properties();
    if (!file.exists()) {
        try {
            if (!file.createNewFile()) {
                return null;
            }
            properties.setProperty("externalDownloads", "false");
            properties.store(new FileWriter(file), "Configuration for the Spiget auto-updater. https://spiget.org | https://github.com/InventivetalentDev/SpigetUpdater\n"
                    + "Use 'externalDownloads' if you want to auto-download resources hosted on external sites\n"
                    + "");
        } catch (Exception ignored) {
            return null;
        }
    }
    try {
        properties.load(new FileReader(file));
    } catch (IOException e) {
        return null;
    }
    return properties;
}
 
源代码2 项目: RedProtect   文件: SpigetUpdate.java
public Properties getUpdaterProperties() {
    File file = new File(Bukkit.getUpdateFolderFile(), "spiget.properties");
    Properties properties = new Properties();
    if (!file.exists()) {
        try {
            if (!file.createNewFile()) {
                return null;
            }
            properties.setProperty("externalDownloads", "false");
            properties.store(new FileWriter(file), "Configuration for the Spiget auto-updater. https://spiget.org | https://github.com/InventivetalentDev/SpigetUpdater\n"
                    + "Use 'externalDownloads' if you want to auto-download resources hosted on external sites\n"
                    + "");
        } catch (Exception ignored) {
            return null;
        }
    }
    try {
        properties.load(new FileReader(file));
    } catch (IOException e) {
        return null;
    }
    return properties;
}
 
源代码3 项目: BetonQuest   文件: Updater.java
private void downloadUpdate() throws QuestRuntimeException {
    LogUtils.getLogger().log(Level.INFO, "(Autoupdater) Updater started download of new version...");
    if (!config.enabled) {
        throw new QuestRuntimeException("The updater is disabled in the config! Check config entry 'update.enabled'.");
    }
    if (latest.getValue() == null) {
        throw new QuestRuntimeException("The updater did not find an update! This can depend on your update_strategy, check config entry 'update.update_strategy'.");
    }
    LogUtils.getLogger().log(Level.INFO, "(Autoupdater) The target version is '" + latest.getKey().getVersion() + "'...");
    try {
        URL remoteFile = new URL(latest.getValue());
        try (ReadableByteChannel rbc = Channels.newChannel(remoteFile.openStream())) {
            File folder = Bukkit.getUpdateFolderFile();
            if (!folder.exists()) {
                folder.mkdirs();
            }
            File file = new File(folder, fileName);
            if (!file.exists()) {
                file.createNewFile();
            }
            try (FileOutputStream fos = new FileOutputStream(file)) {
                fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
            }
        }
        latest = Pair.of(new Version(plugin.getDescription().getVersion()), null);
        LogUtils.getLogger().log(Level.INFO, "(Autoupdater) Download finished.");
    } catch (IOException e) {
        throw new QuestRuntimeException("Could not download the file. Try again or update manually.", e);
    }
}
 
源代码4 项目: SkinsRestorerX   文件: UpdateDownloaderGithub.java
@Override
public boolean downloadUpdate() {
    this.releaseInfo = (GitHubReleaseInfo) plugin.getUpdateChecker().getLatestResourceInfo();

    if (releaseInfo == null) {
        failReason = DownloadFailReason.NOT_CHECKED;
        return false;// Update not yet checked
    }
    if (!plugin.getUpdateChecker().isVersionNewer(plugin.getUpdateChecker().currentVersion, releaseInfo.tag_name)) {
        failReason = DownloadFailReason.NO_UPDATE;
        return false;// Version is no update
    }

    File pluginFile = getPluginFile();// /plugins/XXX.jar
    if (pluginFile == null) {
        failReason = DownloadFailReason.NO_PLUGIN_FILE;
        return false;
    }
    File updateFolder = Bukkit.getUpdateFolderFile();
    if (!updateFolder.exists()) {
        if (!updateFolder.mkdirs()) {
            failReason = DownloadFailReason.NO_UPDATE_FOLDER;
            return false;
        }
    }
    final File updateFile = new File(updateFolder, pluginFile.getName());

    plugin.getLogger().info("[GitHubUpdate] Downloading update...");
    Bukkit.getScheduler().runTaskAsynchronously(plugin, GitHubUpdateDownloader.downloadAsync(releaseInfo, updateFile, plugin.getUpdateChecker().getUserAgent(), new DownloadCallback() {
        @Override
        public void finished() {
            plugin.getLogger().info("[GitHubUpdate] Update saved as " + updateFile.getPath());
        }

        @Override
        public void error(Exception exception) {
            plugin.getLogger().log(Level.WARNING, "[GitHubUpdate] Could not download update", exception);
        }
    }));

    return true;
}
 
源代码5 项目: SkinsRestorerX   文件: UpdateDownloader.java
public boolean downloadUpdate() {
    this.latestResourceInfo = plugin.getUpdateChecker().getLatestResourceInfo();

    if (latestResourceInfo == null) {
        failReason = DownloadFailReason.NOT_CHECKED;
        return false;// Update not yet checked
    }
    if (!plugin.getUpdateChecker().isVersionNewer(plugin.getUpdateChecker().currentVersion, latestResourceInfo.latestVersion.name)) {
        failReason = DownloadFailReason.NO_UPDATE;
        return false;// Version is no update
    }
    if (latestResourceInfo.external) {
        failReason = DownloadFailReason.NO_DOWNLOAD;
        return false;// No download available
    }

    File pluginFile = getPluginFile();// /plugins/XXX.jar
    if (pluginFile == null) {
        failReason = DownloadFailReason.NO_PLUGIN_FILE;
        return false;
    }
    File updateFolder = Bukkit.getUpdateFolderFile();
    if (!updateFolder.exists()) {
        if (!updateFolder.mkdirs()) {
            failReason = DownloadFailReason.NO_UPDATE_FOLDER;
            return false;
        }
    }
    final File updateFile = new File(updateFolder, pluginFile.getName());

    Properties properties = getUpdaterProperties();
    boolean allowExternalDownload = properties != null && properties.containsKey("externalDownloads") && Boolean.valueOf(properties.getProperty("externalDownloads"));

    if (!allowExternalDownload && latestResourceInfo.external) {
        failReason = DownloadFailReason.EXTERNAL_DISALLOWED;
        return false;
    }

    plugin.getSrLogger().logAlways("[SpigetUpdate] Downloading update...");
    Bukkit.getScheduler().runTaskAsynchronously(plugin, org.inventivetalent.update.spiget.download.UpdateDownloader.downloadAsync(latestResourceInfo, updateFile, plugin.getUpdateChecker().getUserAgent(), new DownloadCallback() {
        @Override
        public void finished() {
            plugin.getSrLogger().logAlways("[SpigetUpdate] Update saved as " + updateFile.getPath());
        }

        @Override
        public void error(Exception exception) {
            plugin.getSrLogger().logAlways(Level.WARNING, "[SpigetUpdate] Could not download update", exception);
        }
    }));

    return true;
}
 
源代码6 项目: RedProtect   文件: SpigetUpdate.java
public boolean downloadUpdate() {
    if (latestResourceInfo == null) {
        failReason = DownloadFailReason.NOT_CHECKED;
        return false;// Update not yet checked
    }
    if (!isVersionNewer(currentVersion, latestResourceInfo.latestVersion.name)) {
        failReason = DownloadFailReason.NO_UPDATE;
        return false;// Version is no update
    }
    if (latestResourceInfo.external) {
        failReason = DownloadFailReason.NO_DOWNLOAD;
        return false;// No download available
    }

    File pluginFile = getPluginFile();// /plugins/XXX.jar
    if (pluginFile == null) {
        failReason = DownloadFailReason.NO_PLUGIN_FILE;
        return false;
    }
    File updateFolder = Bukkit.getUpdateFolderFile();
    if (!updateFolder.exists()) {
        if (!updateFolder.mkdirs()) {
            failReason = DownloadFailReason.NO_UPDATE_FOLDER;
            return false;
        }
    }
    final File updateFile = new File(updateFolder, pluginFile.getName());

    Properties properties = getUpdaterProperties();
    boolean allowExternalDownload = properties != null && properties.containsKey("externalDownloads") && Boolean.valueOf(properties.getProperty("externalDownloads"));

    if (!allowExternalDownload && latestResourceInfo.external) {
        failReason = DownloadFailReason.EXTERNAL_DISALLOWED;
        return false;
    }

    log.info("[SpigetUpdate] Downloading update...");
    dispatch(UpdateDownloader.downloadAsync(latestResourceInfo, updateFile, getUserAgent(), new DownloadCallback() {
        @Override
        public void finished() {
            log.info("[SpigetUpdate] Update saved as " + updateFile.getPath());
        }

        @Override
        public void error(Exception exception) {
            log.log(Level.WARNING, "[SpigetUpdate] Could not download update", exception);
        }
    }));

    return true;
}