Archiviert
13
0

Automatically delete empty JAR-files left over from upgrades.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-01-27 16:42:30 +01:00
Ursprung eb996e73d8
Commit d109506cf2

Datei anzeigen

@ -19,6 +19,7 @@ package com.comphenix.protocol;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
@ -41,6 +42,7 @@ import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
import com.comphenix.protocol.metrics.Statistics; import com.comphenix.protocol.metrics.Statistics;
import com.comphenix.protocol.metrics.Updater; import com.comphenix.protocol.metrics.Updater;
import com.comphenix.protocol.reflect.compiler.BackgroundCompiler; import com.comphenix.protocol.reflect.compiler.BackgroundCompiler;
import com.google.common.collect.Lists;
/** /**
* The main entry point for ProtocolLib. * The main entry point for ProtocolLib.
@ -282,7 +284,7 @@ public class ProtocolLibrary extends JavaPlugin {
Pattern ourPlugin = Pattern.compile("ProtocolLib-(.*)\\.jar"); Pattern ourPlugin = Pattern.compile("ProtocolLib-(.*)\\.jar");
MinecraftVersion currentVersion = new MinecraftVersion(this.getDescription().getVersion()); MinecraftVersion currentVersion = new MinecraftVersion(this.getDescription().getVersion());
MinecraftVersion newestVersion = null; MinecraftVersion newestVersion = null;
// Skip the file that contains this current instance however // Skip the file that contains this current instance however
File loadedFile = getFile(); File loadedFile = getFile();
@ -297,7 +299,10 @@ public class ProtocolLibrary extends JavaPlugin {
if (match.matches()) { if (match.matches()) {
MinecraftVersion version = new MinecraftVersion(match.group(1)); MinecraftVersion version = new MinecraftVersion(match.group(1));
if (newestVersion == null || newestVersion.compareTo(version) < 0) { if (candidate.length() == 0) {
// Delete and inform the user
logger.info((candidate.delete() ? "Deleted " : "Could not delete ") + candidate);
} else if (newestVersion == null || newestVersion.compareTo(version) < 0) {
newestVersion = version; newestVersion = version;
} }
} }