Cut down on static calls to the main class

This commit is contained in:
Dan Mulloy 2016-01-29 23:41:26 -05:00
parent de8bb2bd66
commit 7630007833
8 changed files with 11 additions and 13 deletions

View File

@ -256,7 +256,7 @@ class CommandProtocol extends CommandBase {
sender.sendMessage("Data dump written to " + file.getAbsolutePath());
} catch (IOException ex) {
ProtocolLibrary.getStaticLogger().log(Level.SEVERE, "Failed to create dump:", ex);
ProtocolLibrary.log(Level.SEVERE, "Failed to create dump:", ex);
sender.sendMessage(ChatColor.RED + "Failed to create dump! Check console!");
} finally {
closer.close();

View File

@ -170,7 +170,7 @@ public class ProtocolConfig {
loadingSections = false;
// Inform the user
ProtocolLibrary.log("Created default configuration.");
plugin.getLogger().info("Created default configuration.");
}
}

View File

@ -751,11 +751,11 @@ public class ProtocolLibrary extends JavaPlugin {
log(Level.INFO, message, args);
}
public static Logger getStaticLogger() {
return logger;
public static void log(Level level, String message, Throwable ex) {
logger.log(level, message, ex);
}
public static void disableUpdates() {
public void disableUpdates() {
UPDATES_DISABLED = true;
}
}

View File

@ -437,13 +437,12 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
return false;
}
} else {
ProtocolLibrary.log(Level.INFO, "Could not determine asynchronous state of packets.");
ProtocolLibrary.log(Level.INFO, "This can probably be ignored.");
ProtocolLibrary.log(Level.INFO, "Could not determine asynchronous state of packets (this can probably be ignored)");
alwaysSync = true;
}
}
}
if (alwaysSync) {
return false;
} else {

View File

@ -40,7 +40,7 @@ public class Guava {
Class<?> clazz = Class.forName("com.comphenix.protocol.compat.guava.Guava10");
compat = (GuavaCompat) clazz.newInstance();
} catch (Throwable ex1) {
ProtocolLibrary.getStaticLogger().log(Level.SEVERE, "Failed to create Guava 10 compat:", ex1);
ProtocolLibrary.log(Level.SEVERE, "Failed to create Guava 10 compat:", ex1);
}
}
}

View File

@ -44,7 +44,7 @@ public class Netty {
Class<?> clazz = Class.forName("com.comphenix.protocol.compat.netty.shaded.ShadedNetty");
compat = (NettyCompat) clazz.newInstance();
} catch (Exception ex1) {
ProtocolLibrary.getStaticLogger().log(Level.SEVERE, "Failed to create legacy netty compat:", ex1);
ProtocolLibrary.log(Level.SEVERE, "Failed to create legacy netty compat:", ex1);
}
}
}

View File

@ -9,7 +9,6 @@ import java.util.logging.Level;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginLoadOrder;
import com.comphenix.protocol.ProtocolLibrary;
import com.google.common.collect.Sets;
/**
@ -82,7 +81,7 @@ class PluginVerifier {
throw new IllegalArgumentException("dependency cannot have a load directives.");
} catch (LinkageError e) {
// They're probably using an ancient version of Bukkit
ProtocolLibrary.log(Level.WARNING, "Failed to determine loadBefore: " + e);
dependency.getLogger().log(Level.WARNING, "Failed to determine loadBefore: " + e);
}
this.dependency = dependency;

View File

@ -76,7 +76,7 @@ public final class SpigotUpdater extends Updater {
plugin.getLogger().log(Level.WARNING, "Failed to check for updates: " + ex);
}
ProtocolLibrary.disableUpdates();
plugin.disableUpdates();
} finally {
// Invoke the listeners on the main thread
for (Runnable listener : listeners) {