Skip to content

Commit 7630007

Browse files
committed
Cut down on static calls to the main class
1 parent de8bb2b commit 7630007

File tree

8 files changed

+11
-13
lines changed

8 files changed

+11
-13
lines changed

ProtocolLib/src/main/java/com/comphenix/protocol/CommandProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private void dump(CommandSender sender) {
256256

257257
sender.sendMessage("Data dump written to " + file.getAbsolutePath());
258258
} catch (IOException ex) {
259-
ProtocolLibrary.getStaticLogger().log(Level.SEVERE, "Failed to create dump:", ex);
259+
ProtocolLibrary.log(Level.SEVERE, "Failed to create dump:", ex);
260260
sender.sendMessage(ChatColor.RED + "Failed to create dump! Check console!");
261261
} finally {
262262
closer.close();

ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private void loadSections(boolean copyDefaults) {
170170
loadingSections = false;
171171

172172
// Inform the user
173-
ProtocolLibrary.log("Created default configuration.");
173+
plugin.getLogger().info("Created default configuration.");
174174
}
175175
}
176176

ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,11 @@ public static void log(String message, Object... args) {
751751
log(Level.INFO, message, args);
752752
}
753753

754-
public static Logger getStaticLogger() {
755-
return logger;
754+
public static void log(Level level, String message, Throwable ex) {
755+
logger.log(level, message, ex);
756756
}
757757

758-
public static void disableUpdates() {
758+
public void disableUpdates() {
759759
UPDATES_DISABLED = true;
760760
}
761761
}

ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,12 @@ public boolean isMinecraftAsync(PacketEvent event) throws FieldAccessException {
437437
return false;
438438
}
439439
} else {
440-
ProtocolLibrary.log(Level.INFO, "Could not determine asynchronous state of packets.");
441-
ProtocolLibrary.log(Level.INFO, "This can probably be ignored.");
440+
ProtocolLibrary.log(Level.INFO, "Could not determine asynchronous state of packets (this can probably be ignored)");
442441
alwaysSync = true;
443442
}
444443
}
445444
}
446-
445+
447446
if (alwaysSync) {
448447
return false;
449448
} else {

ProtocolLib/src/main/java/com/comphenix/protocol/compat/guava/Guava.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Guava {
4040
Class<?> clazz = Class.forName("com.comphenix.protocol.compat.guava.Guava10");
4141
compat = (GuavaCompat) clazz.newInstance();
4242
} catch (Throwable ex1) {
43-
ProtocolLibrary.getStaticLogger().log(Level.SEVERE, "Failed to create Guava 10 compat:", ex1);
43+
ProtocolLibrary.log(Level.SEVERE, "Failed to create Guava 10 compat:", ex1);
4444
}
4545
}
4646
}

ProtocolLib/src/main/java/com/comphenix/protocol/compat/netty/Netty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class Netty {
4444
Class<?> clazz = Class.forName("com.comphenix.protocol.compat.netty.shaded.ShadedNetty");
4545
compat = (NettyCompat) clazz.newInstance();
4646
} catch (Exception ex1) {
47-
ProtocolLibrary.getStaticLogger().log(Level.SEVERE, "Failed to create legacy netty compat:", ex1);
47+
ProtocolLibrary.log(Level.SEVERE, "Failed to create legacy netty compat:", ex1);
4848
}
4949
}
5050
}

ProtocolLib/src/main/java/com/comphenix/protocol/injector/PluginVerifier.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.bukkit.plugin.Plugin;
1010
import org.bukkit.plugin.PluginLoadOrder;
1111

12-
import com.comphenix.protocol.ProtocolLibrary;
1312
import com.google.common.collect.Sets;
1413

1514
/**
@@ -82,7 +81,7 @@ public PluginVerifier(Plugin dependency) {
8281
throw new IllegalArgumentException("dependency cannot have a load directives.");
8382
} catch (LinkageError e) {
8483
// They're probably using an ancient version of Bukkit
85-
ProtocolLibrary.log(Level.WARNING, "Failed to determine loadBefore: " + e);
84+
dependency.getLogger().log(Level.WARNING, "Failed to determine loadBefore: " + e);
8685
}
8786

8887
this.dependency = dependency;

ProtocolLib/src/main/java/com/comphenix/protocol/updater/SpigotUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void run() {
7676
plugin.getLogger().log(Level.WARNING, "Failed to check for updates: " + ex);
7777
}
7878

79-
ProtocolLibrary.disableUpdates();
79+
plugin.disableUpdates();
8080
} finally {
8181
// Invoke the listeners on the main thread
8282
for (Runnable listener : listeners) {

0 commit comments

Comments
 (0)