mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-12-23 05:08:47 +00:00
chore: 调整ext更新部分
This commit is contained in:
parent
c7e10a88b6
commit
530f79d11b
@ -27,9 +27,6 @@ import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.error.Report;
|
||||
|
||||
/**
|
||||
* Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
|
||||
* <p/>
|
||||
@ -60,8 +57,13 @@ public class BukkitUpdater extends Updater {
|
||||
|
||||
private static final int BYTE_SIZE = 1024; // Used for downloading files
|
||||
|
||||
// Update information
|
||||
// private static final String BUKKIT_DEV_SLUG = "protocollib";
|
||||
// private static final int BUKKIT_DEV_ID = 45564;
|
||||
|
||||
private URL url; // Connecting to RSS
|
||||
private File file; // The plugin's file
|
||||
|
||||
private Thread thread; // Updater thread
|
||||
private int id = -1; // Project's Curse ID
|
||||
|
||||
@ -322,22 +324,21 @@ public class BukkitUpdater extends Updater {
|
||||
destinationFilePath.getParentFile().mkdirs();
|
||||
if (entry.isDirectory()) {
|
||||
continue;
|
||||
} else {
|
||||
final BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
|
||||
int b;
|
||||
final byte buffer[] = new byte[BukkitUpdater.BYTE_SIZE];
|
||||
final FileOutputStream fos = new FileOutputStream(destinationFilePath);
|
||||
final BufferedOutputStream bos = new BufferedOutputStream(fos, BukkitUpdater.BYTE_SIZE);
|
||||
while ((b = bis.read(buffer, 0, BukkitUpdater.BYTE_SIZE)) != -1) {
|
||||
bos.write(buffer, 0, b);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
final String name = destinationFilePath.getName();
|
||||
if (name.endsWith(".jar") && this.pluginFile(name)) {
|
||||
destinationFilePath.renameTo(new File(this.plugin.getDataFolder().getParent(), this.updateFolder + "/" + name));
|
||||
}
|
||||
}
|
||||
final BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
|
||||
int b;
|
||||
final byte buffer[] = new byte[BukkitUpdater.BYTE_SIZE];
|
||||
final FileOutputStream fos = new FileOutputStream(destinationFilePath);
|
||||
final BufferedOutputStream bos = new BufferedOutputStream(fos, BukkitUpdater.BYTE_SIZE);
|
||||
while ((b = bis.read(buffer, 0, BukkitUpdater.BYTE_SIZE)) != -1) {
|
||||
bos.write(buffer, 0, b);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
bis.close();
|
||||
final String name = destinationFilePath.getName();
|
||||
if (name.endsWith(".jar") && this.pluginFile(name)) {
|
||||
destinationFilePath.renameTo(new File(this.plugin.getDataFolder().getParent(), this.updateFolder + "/" + name));
|
||||
}
|
||||
entry = null;
|
||||
destinationFilePath = null;
|
||||
@ -399,8 +400,6 @@ public class BukkitUpdater extends Updater {
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
// Any generic error will be handled here
|
||||
ProtocolLibrary.getErrorReporter().reportDetailed(BukkitUpdater.this, Report.newBuilder(REPORT_CANNOT_UPDATE_PLUGIN).error(e).callerParam(this));
|
||||
|
||||
} finally {
|
||||
// Invoke the listeners on the main thread
|
||||
for (final Runnable listener : listeners) {
|
||||
|
@ -24,8 +24,6 @@ import java.net.URL;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.error.Report;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Closer;
|
||||
|
||||
@ -83,7 +81,6 @@ public final class SpigotUpdater extends Updater {
|
||||
@Override
|
||||
public void start(final UpdateType type) {
|
||||
waitForThread();
|
||||
|
||||
this.type = type;
|
||||
this.thread = new Thread(new SpigotUpdateRunnable());
|
||||
this.thread.start();
|
||||
@ -95,19 +92,12 @@ public final class SpigotUpdater extends Updater {
|
||||
try {
|
||||
final String version = getSpigotVersion();
|
||||
remoteVersion = version;
|
||||
|
||||
if (versionCheck(version)) {
|
||||
result = UpdateResult.SPIGOT_UPDATE_AVAILABLE;
|
||||
} else {
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
}
|
||||
} catch (final Throwable ex) {
|
||||
// if (ProtocolLibrary.getConfig().isDebug()) {
|
||||
ProtocolLibrary.getErrorReporter().reportDetailed(SpigotUpdater.this, Report.newBuilder(REPORT_CANNOT_UPDATE_PLUGIN).error(ex).callerParam(this));
|
||||
// } else {
|
||||
// plugin.getLogger().log(Level.WARNING, "Failed to check for updates: " + ex);
|
||||
// }
|
||||
// ProtocolLibrary.disableUpdates();
|
||||
} finally {
|
||||
// Invoke the listeners on the main thread
|
||||
for (final Runnable listener : listeners) {
|
||||
|
@ -22,8 +22,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.comphenix.protocol.error.ReportType;
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
@ -31,7 +29,6 @@ import com.google.common.base.Preconditions;
|
||||
*/
|
||||
|
||||
public abstract class Updater {
|
||||
public static final ReportType REPORT_CANNOT_UPDATE_PLUGIN = new ReportType("Cannot update ProtocolLib.");
|
||||
|
||||
protected Plugin plugin;
|
||||
protected String versionName;
|
||||
@ -181,20 +178,12 @@ public abstract class Updater {
|
||||
remoteVersion = remoteVersion.substring(1);
|
||||
}
|
||||
|
||||
final MinecraftVersion parsedRemote = new MinecraftVersion(remoteVersion);
|
||||
final MinecraftVersion parsedCurrent = new MinecraftVersion(plugin.getDescription().getVersion());
|
||||
final String localVersion = plugin.getDescription().getVersion();
|
||||
|
||||
if (devBuild && parsedRemote.equals(parsedCurrent)) {
|
||||
if (devBuild && remoteVersion.equals(localVersion)) {
|
||||
// They're using a dev build and this version has been released
|
||||
return !remoteVersion.contains("-BETA") && !remoteVersion.contains("-SNAPSHOT");
|
||||
}
|
||||
|
||||
// The remote version has to be greater
|
||||
if (parsedRemote.compareTo(parsedCurrent) <= 0) {
|
||||
// We already have the latest version, or this build is tagged for no-update
|
||||
this.result = BukkitUpdater.UpdateResult.NO_UPDATE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user