Save the last update check, even if it was initiated from a command.
Dieser Commit ist enthalten in:
Ursprung
64e3ba7f14
Commit
f5dce019df
@ -21,11 +21,13 @@ class CommandProtocol extends CommandBase {
|
||||
|
||||
private Plugin plugin;
|
||||
private Updater updater;
|
||||
private ProtocolConfig config;
|
||||
|
||||
public CommandProtocol(Plugin plugin, Updater updater) {
|
||||
public CommandProtocol(Plugin plugin, Updater updater, ProtocolConfig config) {
|
||||
super(CommandBase.PERMISSION_ADMIN, NAME, 1);
|
||||
this.plugin = plugin;
|
||||
this.updater = updater;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,9 +52,11 @@ class CommandProtocol extends CommandBase {
|
||||
@Override
|
||||
public void run() {
|
||||
UpdateResult result = updater.update(UpdateType.NO_DOWNLOAD, true);
|
||||
sender.sendMessage(ChatColor.DARK_BLUE + "Version check: " + result.toString());
|
||||
sender.sendMessage(ChatColor.BLUE + "Version check: " + result.toString());
|
||||
}
|
||||
});
|
||||
|
||||
updateFinished();
|
||||
}
|
||||
|
||||
public void updateVersion(final CommandSender sender) {
|
||||
@ -61,14 +65,24 @@ class CommandProtocol extends CommandBase {
|
||||
@Override
|
||||
public void run() {
|
||||
UpdateResult result = updater.update(UpdateType.DEFAULT, true);
|
||||
sender.sendMessage(ChatColor.DARK_BLUE + "Update: " + result.toString());
|
||||
sender.sendMessage(ChatColor.BLUE + "Update: " + result.toString());
|
||||
}
|
||||
});
|
||||
|
||||
updateFinished();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent further automatic updates until the next delay.
|
||||
*/
|
||||
public void updateFinished() {
|
||||
config.setAutoLastTime(System.currentTimeMillis());
|
||||
config.saveAll();
|
||||
}
|
||||
|
||||
public void reloadConfiguration(CommandSender sender) {
|
||||
plugin.saveConfig();
|
||||
plugin.reloadConfig();
|
||||
sender.sendMessage(ChatColor.DARK_BLUE + "Reloaded configuration!");
|
||||
sender.sendMessage(ChatColor.BLUE + "Reloaded configuration!");
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class ProtocolLibrary extends JavaPlugin {
|
||||
reporter.addGlobalParameter("manager", protocolManager);
|
||||
|
||||
// Initialize command handlers
|
||||
commandProtocol = new CommandProtocol(this, updater);
|
||||
commandProtocol = new CommandProtocol(this, updater, config);
|
||||
commandPacket = new CommandPacket(this, logger, reporter, protocolManager);
|
||||
|
||||
// Send logging information to player listeners too
|
||||
@ -238,15 +238,13 @@ public class ProtocolLibrary extends JavaPlugin {
|
||||
|
||||
// Should we update?
|
||||
if (currentTime < config.getAutoLastTime() + config.getAutoDelay()) {
|
||||
// Great. Save this check.
|
||||
config.setAutoLastTime(currentTime);
|
||||
config.saveAll();
|
||||
|
||||
// Initiate the update from the console
|
||||
// Initiate the update as if it came from the console
|
||||
if (config.isAutoDownload())
|
||||
commandProtocol.updateVersion(getServer().getConsoleSender());
|
||||
else if (config.isAutoNotify())
|
||||
commandProtocol.checkVersion(getServer().getConsoleSender());
|
||||
else
|
||||
commandProtocol.updateFinished();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -547,11 +547,13 @@ public class Updater
|
||||
{
|
||||
if (type != UpdateType.NO_VERSION_CHECK)
|
||||
{
|
||||
String[] parts = title.split(" ");
|
||||
String version = plugin.getDescription().getVersion();
|
||||
if(title.split("v").length == 2)
|
||||
|
||||
if(parts.length == 2)
|
||||
{
|
||||
String remoteVersion = title.split("v")[1].split(" ")[0]; // Get the newest file's version number
|
||||
int remVer = -1,curVer=0;
|
||||
String remoteVersion = parts[1].split(" ")[0]; // Get the newest file's version number
|
||||
int remVer = -1, curVer=0;
|
||||
try
|
||||
{
|
||||
remVer = calVer(remoteVersion);
|
||||
@ -561,6 +563,7 @@ public class Updater
|
||||
{
|
||||
remVer=-1;
|
||||
}
|
||||
|
||||
if(hasTag(version)||version.equalsIgnoreCase(remoteVersion)||curVer>=remVer)
|
||||
{
|
||||
// We already have the latest version, or this build is tagged for no-update
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren