Last active
December 20, 2015 15:09
-
-
Save kitskub/6151864 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (dynamicPacketMap.getKeys().contains(clazz.getName())) { | |
| // Already bound, just return | |
| return dynamicPacketMap.register(clazz.getName()); | |
| } | |
| if (dynamicId) { | |
| int id; | |
| do { | |
| id = nextId.getAndIncrement(); | |
| } while (find(prevNewId) != null); | |
| codec = constructor.newInstance(id); | |
| codec.setDynamic(true); | |
| } else { | |
| //Codec is static | |
| final MessageCodec<?> prevCodec = find(codec.getOpcode()); | |
| if (prevCodec != null) { | |
| throw new IllegalStateException("Trying to register a static opcode where one already exists. Static:" + clazz.getSimpleName() + " Other:" + prevCodec.getClass().getSimpleName()); | |
| } | |
| codec = constructor.newInstance(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment