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 Plugin plugin;
|
||||||
private Updater updater;
|
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);
|
super(CommandBase.PERMISSION_ADMIN, NAME, 1);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.updater = updater;
|
this.updater = updater;
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,9 +52,11 @@ class CommandProtocol extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
UpdateResult result = updater.update(UpdateType.NO_DOWNLOAD, true);
|
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) {
|
public void updateVersion(final CommandSender sender) {
|
||||||
@ -61,14 +65,24 @@ class CommandProtocol extends CommandBase {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
UpdateResult result = updater.update(UpdateType.DEFAULT, true);
|
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) {
|
public void reloadConfiguration(CommandSender sender) {
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
plugin.reloadConfig();
|
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);
|
reporter.addGlobalParameter("manager", protocolManager);
|
||||||
|
|
||||||
// Initialize command handlers
|
// Initialize command handlers
|
||||||
commandProtocol = new CommandProtocol(this, updater);
|
commandProtocol = new CommandProtocol(this, updater, config);
|
||||||
commandPacket = new CommandPacket(this, logger, reporter, protocolManager);
|
commandPacket = new CommandPacket(this, logger, reporter, protocolManager);
|
||||||
|
|
||||||
// Send logging information to player listeners too
|
// Send logging information to player listeners too
|
||||||
@ -238,15 +238,13 @@ public class ProtocolLibrary extends JavaPlugin {
|
|||||||
|
|
||||||
// Should we update?
|
// Should we update?
|
||||||
if (currentTime < config.getAutoLastTime() + config.getAutoDelay()) {
|
if (currentTime < config.getAutoLastTime() + config.getAutoDelay()) {
|
||||||
// Great. Save this check.
|
// Initiate the update as if it came from the console
|
||||||
config.setAutoLastTime(currentTime);
|
|
||||||
config.saveAll();
|
|
||||||
|
|
||||||
// Initiate the update from the console
|
|
||||||
if (config.isAutoDownload())
|
if (config.isAutoDownload())
|
||||||
commandProtocol.updateVersion(getServer().getConsoleSender());
|
commandProtocol.updateVersion(getServer().getConsoleSender());
|
||||||
else if (config.isAutoNotify())
|
else if (config.isAutoNotify())
|
||||||
commandProtocol.checkVersion(getServer().getConsoleSender());
|
commandProtocol.checkVersion(getServer().getConsoleSender());
|
||||||
|
else
|
||||||
|
commandProtocol.updateFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,11 +547,13 @@ public class Updater
|
|||||||
{
|
{
|
||||||
if (type != UpdateType.NO_VERSION_CHECK)
|
if (type != UpdateType.NO_VERSION_CHECK)
|
||||||
{
|
{
|
||||||
|
String[] parts = title.split(" ");
|
||||||
String version = plugin.getDescription().getVersion();
|
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
|
String remoteVersion = parts[1].split(" ")[0]; // Get the newest file's version number
|
||||||
int remVer = -1,curVer=0;
|
int remVer = -1, curVer=0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
remVer = calVer(remoteVersion);
|
remVer = calVer(remoteVersion);
|
||||||
@ -559,8 +561,9 @@ public class Updater
|
|||||||
}
|
}
|
||||||
catch(NumberFormatException nfe)
|
catch(NumberFormatException nfe)
|
||||||
{
|
{
|
||||||
remVer=-1;
|
remVer=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasTag(version)||version.equalsIgnoreCase(remoteVersion)||curVer>=remVer)
|
if(hasTag(version)||version.equalsIgnoreCase(remoteVersion)||curVer>=remVer)
|
||||||
{
|
{
|
||||||
// We already have the latest version, or this build is tagged for no-update
|
// We already have the latest version, or this build is tagged for no-update
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren