From 003bc927a444ab74b6fbd1a55fe1da8bc8d184a7 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Tue, 6 Nov 2012 18:07:06 +0100 Subject: [PATCH] Set default update rate to 43200 seconds instead. --- .../java/com/comphenix/protocol/CommandProtocol.java | 2 +- .../java/com/comphenix/protocol/ProtocolConfig.java | 11 +++-------- .../java/com/comphenix/protocol/ProtocolLibrary.java | 5 ++++- .../comphenix/protocol/async/PacketSendingQueue.java | 1 - 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java index 8d6f62d5..fa20d46d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java @@ -86,7 +86,7 @@ class CommandProtocol extends CommandBase { */ public void updateFinished() { long currentTime = System.currentTimeMillis() / ProtocolLibrary.MILLI_PER_SECOND; - + config.setAutoLastTime(currentTime); config.saveAll(); } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java index 09e5313d..078262c7 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java @@ -24,7 +24,7 @@ class ProtocolConfig { private static final String UPDATER_LAST_TIME = "last"; // Defaults - private static final long DEFAULT_UPDATER_DELAY = 60; + private static final long DEFAULT_UPDATER_DELAY = 43200; private Plugin plugin; private Configuration config; @@ -47,7 +47,7 @@ class ProtocolConfig { */ public void reloadConfig() { this.config = plugin.getConfig(); - loadSections(true); + loadSections(!loadingSections); } /** @@ -55,9 +55,6 @@ class ProtocolConfig { * @param copyDefaults - whether or not to copy configuration defaults. */ private void loadSections(boolean copyDefaults) { - if (loadingSections) - return; - if (config != null) { global = config.getConfigurationSection(SECTION_GLOBAL); } @@ -72,10 +69,8 @@ class ProtocolConfig { if (config != null) config.options().copyDefaults(true); plugin.saveDefaultConfig(); - config = plugin.getConfig(); - + plugin.reloadConfig(); loadingSections = false; - loadSections(false); // Inform the user System.out.println("[ProtocolLib] Created default configuration."); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index aa32d4be..b97b35f9 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -128,6 +128,7 @@ public class ProtocolLibrary extends JavaPlugin { @Override public void reloadConfig() { super.reloadConfig(); + // Reload configuration if (config != null) { config.reloadConfig(); @@ -242,8 +243,10 @@ public class ProtocolLibrary extends JavaPlugin { long currentTime = System.currentTimeMillis() / MILLI_PER_SECOND; try { + long updateTime = config.getAutoLastTime() + config.getAutoDelay(); + // Should we update? - if (currentTime > config.getAutoLastTime() + config.getAutoDelay()) { + if (currentTime > updateTime) { // Initiate the update as if it came from the console if (config.isAutoDownload()) commandProtocol.updateVersion(getServer().getConsoleSender()); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketSendingQueue.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketSendingQueue.java index 698c2def..3b1a7426 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketSendingQueue.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketSendingQueue.java @@ -27,7 +27,6 @@ import org.bukkit.entity.Player; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.injector.PlayerLoggedOutException; -import com.comphenix.protocol.injector.SortedPacketListenerList; import com.comphenix.protocol.reflect.FieldAccessException; /**