diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 56067db8..819ba3f4 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -2,12 +2,15 @@ package net.md_5.bungee.entitymap; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.ProtocolConstants; /** * Class to rewrite integers within packets. */ +@NoArgsConstructor(access = AccessLevel.PACKAGE) public abstract class EntityMap { @@ -17,21 +20,17 @@ public abstract class EntityMap private final boolean[] serverboundInts = new boolean[ 256 ]; private final boolean[] serverboundVarInts = new boolean[ 256 ]; - EntityMap() - { - } - // Returns the correct entity map for the protocol version public static EntityMap getEntityMap(int version) { switch ( version ) { case ProtocolConstants.MINECRAFT_1_7_2: - return new EntityMap_1_7_2(); + return EntityMap_1_7_2.INSTANCE; case ProtocolConstants.MINECRAFT_1_7_6: - return new EntityMap_1_7_6(); + return EntityMap_1_7_6.INSTANCE; case ProtocolConstants.MINECRAFT_1_8: - return new EntityMap_1_8(); + return EntityMap_1_8.INSTANCE; } throw new RuntimeException( "Version " + version + " has no entity map" ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java index 59433bc4..05097bba 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java @@ -7,6 +7,8 @@ import net.md_5.bungee.protocol.ProtocolConstants; class EntityMap_1_7_2 extends EntityMap { + static final EntityMap INSTANCE = new EntityMap_1_7_2(); + EntityMap_1_7_2() { addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Equipment diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java index 1a765c84..67091434 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java @@ -10,6 +10,8 @@ import net.md_5.bungee.protocol.DefinedPacket; class EntityMap_1_7_6 extends EntityMap_1_7_2 { + static final EntityMap_1_7_6 INSTANCE = new EntityMap_1_7_6(); + @Override @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") public void rewriteClientbound(ByteBuf packet, int oldId, int newId) diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java index 9d020d32..b713d4dd 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java @@ -12,6 +12,8 @@ import java.util.UUID; class EntityMap_1_8 extends EntityMap { + static final EntityMap_1_8 INSTANCE = new EntityMap_1_8(); + EntityMap_1_8() { addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment @@ -161,7 +163,7 @@ class EntityMap_1_8 extends EntityMap int packetId = DefinedPacket.readVarInt( packet ); int packetIdLength = packet.readerIndex() - readerIndex; - if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward()) + if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player;