Skip to content

Commit b17af68

Browse files
committed
Clean up some less-than-conventional code
1 parent 3e69dd6 commit b17af68

File tree

23 files changed

+41
-61
lines changed

23 files changed

+41
-61
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected boolean handleCommand(CommandSender sender, String[] args) {
7575
} else if (subCommand.equalsIgnoreCase("timings")) {
7676
toggleTimings(sender, args);
7777
} else if (subCommand.equalsIgnoreCase("listeners")) {
78-
printListeners(sender, args);
78+
printListeners(sender);
7979
} else if (subCommand.equalsIgnoreCase("version")) {
8080
printVersion(sender);
8181
} else if (subCommand.equalsIgnoreCase("dump")) {
@@ -96,7 +96,7 @@ public void updateVersion(final CommandSender sender) {
9696
}
9797

9898
// Display every listener on the server
99-
private void printListeners(final CommandSender sender, String[] args) {
99+
private void printListeners(final CommandSender sender) {
100100
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
101101

102102
sender.sendMessage(ChatColor.GOLD + "Packet listeners:");

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ public class ProtocolConfig {
7777
private int modCount;
7878

7979
public ProtocolConfig(Plugin plugin) {
80-
this(plugin, plugin.getConfig());
81-
}
82-
83-
public ProtocolConfig(Plugin plugin, Configuration config) {
8480
this.plugin = plugin;
8581
reloadConfig();
8682
}

ProtocolLib/src/main/java/com/comphenix/protocol/compat/netty/independent/NettyChannelInjector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ protected PacketEvent handleScheduled(Object instance, FieldAccessor accessor) {
388388
* @return TRUE if it is, FALSE if not or unknown.
389389
*/
390390
private boolean guessCompression(ChannelHandler handler) {
391-
String className = handler != null ? handler.getClass().getCanonicalName() : null;
391+
String className = handler != null ? handler.getClass().getCanonicalName() : "";
392392
return className.contains("Compressor") || className.contains("Decompressor");
393393
}
394394

ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/SortedCopyOnWriteArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* An implicitly sorted array list that preserves insertion order and maintains duplicates.
3131
* @param <T> - type of the elements in the list.
3232
*/
33-
public class SortedCopyOnWriteArray<T extends Comparable<T>> implements Iterable<T>, Collection<T> {
33+
public class SortedCopyOnWriteArray<T extends Comparable<T>> implements Collection<T> {
3434
// Prevent reordering
3535
private volatile List<T> list;
3636

ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketAdapter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,11 @@ public static String getPluginName(PacketListener listener) {
346346
* @return Name of the given plugin.
347347
*/
348348
public static String getPluginName(Plugin plugin) {
349-
// Try to get the plugin name
349+
if (plugin == null)
350+
return "UNKNOWN";
351+
350352
try {
351-
if (plugin == null)
352-
return "UNKNOWN";
353-
else
354-
return plugin.getName();
355-
353+
return plugin.getName();
356354
} catch (NoSuchMethodError e) {
357355
return plugin.toString();
358356
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.comphenix.protocol.AsynchronousManager;
1919
import com.comphenix.protocol.PacketType;
2020
import com.comphenix.protocol.PacketType.Sender;
21-
import com.comphenix.protocol.ProtocolManager;
2221
import com.comphenix.protocol.error.ErrorReporter;
2322
import com.comphenix.protocol.error.Report;
2423
import com.comphenix.protocol.error.ReportType;
@@ -43,7 +42,7 @@
4342
*
4443
* @author Kristian
4544
*/
46-
public class DelayedPacketManager implements ProtocolManager, InternalManager {
45+
public class DelayedPacketManager implements InternalManager {
4746
// Registering packet IDs that are not supported
4847
public static final ReportType REPORT_CANNOT_SEND_QUEUED_PACKET = new ReportType("Cannot send queued packet %s.");
4948
public static final ReportType REPORT_CANNOT_SEND_QUEUED_WIRE_PACKET = new ReportType("Cannot send queued wire packet %s.");

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import com.comphenix.protocol.AsynchronousManager;
5252
import com.comphenix.protocol.PacketType;
5353
import com.comphenix.protocol.PacketType.Sender;
54-
import com.comphenix.protocol.ProtocolManager;
5554
import com.comphenix.protocol.async.AsyncFilterManager;
5655
import com.comphenix.protocol.async.AsyncMarker;
5756
import com.comphenix.protocol.compat.netty.Netty;
@@ -91,7 +90,7 @@
9190
import com.google.common.collect.ImmutableSet;
9291
import com.google.common.collect.Sets;
9392

94-
public final class PacketFilterManager implements ProtocolManager, ListenerInvoker, InternalManager {
93+
public final class PacketFilterManager implements ListenerInvoker, InternalManager {
9594

9695
public static final ReportType REPORT_CANNOT_LOAD_PACKET_LIST = new ReportType("Cannot load server and client packet list.");
9796
public static final ReportType REPORT_CANNOT_INITIALIZE_PACKET_INJECTOR = new ReportType("Unable to initialize packet injector");

ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/InterceptWritePacket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public InterceptWritePacket(ErrorReporter reporter) {
5454
}
5555

5656
// TODO: PacketId should probably do something...
57-
private Class<?> createProxyClass(int packetId) {
57+
private Class<?> createProxyClass() {
5858
// Construct the proxy object
5959
Enhancer ex = EnhancerFactory.getInstance().createEnhancer();
6060

@@ -102,7 +102,7 @@ private Class<?> getProxyClass(int packetId) {
102102

103103
// Concurrent pattern
104104
if (stored == null) {
105-
final Class<?> created = createProxyClass(packetId);
105+
final Class<?> created = createProxyClass();
106106
stored = proxyClasses.putIfAbsent(packetId, created);
107107

108108
// We won!

ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/ProxyPacketInjector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public PacketEvent packetRecieved(PacketContainer packet, InputStream input, byt
348348
@Override
349349
public PacketEvent packetRecieved(PacketContainer packet, Player client, byte[] buffered) {
350350
NetworkMarker marker = buffered != null ? new LegacyNetworkMarker(ConnectionSide.CLIENT_SIDE, buffered, packet.getType()) : null;
351-
PacketEvent event = PacketEvent.fromClient((Object) manager, packet, marker, client);
351+
PacketEvent event = PacketEvent.fromClient(manager, packet, marker, client);
352352

353353
manager.invokePacketRecieving(event);
354354
return event;

ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/DummyPacketInjector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
import com.comphenix.protocol.concurrency.PacketTypeSet;
99
import com.comphenix.protocol.events.PacketContainer;
1010
import com.comphenix.protocol.events.PacketEvent;
11-
import com.comphenix.protocol.injector.packet.PacketInjector;
1211
import com.google.common.collect.Sets;
1312

1413
/**
1514
* Dummy packet injector that simply delegates to its parent Spigot packet injector or receiving filters.
1615
*
1716
* @author Kristian
1817
*/
19-
class DummyPacketInjector extends AbstractPacketInjector implements PacketInjector {
18+
class DummyPacketInjector extends AbstractPacketInjector {
2019
private SpigotPacketInjector injector;
2120
private PacketTypeSet lastBufferedPackets = new PacketTypeSet();
2221

0 commit comments

Comments
 (0)