File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
bridge-common/src/main/java/com/luminiadev/bridge/network/codec Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public static Builder builder() {
6161 public <T extends BridgePacket > void registerPacket (BridgePacketDefinition <T > definition ) {
6262 if (!packetsById .containsKey (definition .getId ())) {
6363 packetsById .put (definition .getId (), definition );
64- packetsByClass .put (definition .getFactory ().getClass (), definition );
64+ packetsByClass .put (definition .getFactory ().getPacketClass (), definition );
6565 } else {
6666 throw new BridgeCodecException ("Packet with id " + definition .getId () + " is already registered" );
6767 }
Original file line number Diff line number Diff line change @@ -14,4 +14,14 @@ public interface BridgePacketFactory<T extends BridgePacket> {
1414 * @return A new bridge packet instance
1515 */
1616 T create ();
17+
18+ /**
19+ * Gets the class of the packet.
20+ *
21+ * @return Class<T>
22+ */
23+ @ SuppressWarnings ("unchecked" )
24+ default Class <T > getPacketClass () {
25+ return (Class <T >) this .create ().getClass ();
26+ }
1727}
Original file line number Diff line number Diff line change 1111
1212allprojects {
1313 group = " com.luminia"
14- version = " 1.0.5 -SNAPSHOT"
14+ version = " 1.0.6 -SNAPSHOT"
1515}
1616
1717subprojects {
You can’t perform that action at this time.
0 commit comments