-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete signature & Automatic detect the packet ID
- Loading branch information
1 parent
e315cb5
commit 4cdd60b
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
api/src/main/java/moe/caa/multilogin/api/MapperConfigAPI.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package moe.caa.multilogin.api; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public interface MapperConfigAPI { | ||
Map<Integer,Integer> getPacketMapping(); | ||
void save(); | ||
void reload(); | ||
} |
37 changes: 37 additions & 0 deletions
37
velocity/src/main/java/fun/ksnb/multilogin/velocity/impl/ChatSessionHandler.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package fun.ksnb.multilogin.velocity.impl; | ||
|
||
import com.velocitypowered.api.event.EventManager; | ||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.proxy.protocol.ProtocolUtils; | ||
import io.netty.buffer.ByteBuf; | ||
import io.netty.channel.ChannelDuplexHandler; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ChatSessionHandler extends ChannelDuplexHandler { | ||
private final Player player; | ||
private final EventManager eventManager; | ||
public ChatSessionHandler(Player player, EventManager eventManager) { | ||
this.player = player; | ||
this.eventManager = eventManager; | ||
} | ||
|
||
@Override | ||
public void channelRead( | ||
final @NotNull ChannelHandlerContext ctx, | ||
final @NotNull Object packet | ||
) throws Exception { | ||
if (packet instanceof ByteBuf buffer) { | ||
ByteBuf c = buffer.copy(); | ||
try { | ||
int packetId = c.readByte(); | ||
ProtocolUtils.readUuid(c); | ||
ProtocolUtils.readPlayerKey(player.getProtocolVersion(), c); | ||
eventManager.fire(new NewChatSessionPacketIDEvent(packetId,player.getProtocolVersion())); | ||
} catch (Exception ignore) { } finally { | ||
c.resetReaderIndex(); | ||
} | ||
} | ||
super.channelRead(ctx, packet); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
velocity/src/main/java/fun/ksnb/multilogin/velocity/impl/NewChatSessionPacketIDEvent.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package fun.ksnb.multilogin.velocity.impl; | ||
|
||
import com.velocitypowered.api.network.ProtocolVersion; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PUBLIC) | ||
@Getter | ||
public class NewChatSessionPacketIDEvent { | ||
private final int packetID; | ||
private final ProtocolVersion version; | ||
} |