Use static instances of EntityMap
This commit is contained in:
parent
5cff0b2171
commit
83e27f07e6
@ -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" );
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user