mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-19 15:09:24 +00:00
register channel
This commit is contained in:
@@ -69,11 +69,5 @@
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.zimzaza4</groupId>
|
||||
<artifactId>geyserutils-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.zimzaza4.geyserutils.bungee;
|
||||
|
||||
import me.zimzaza4.geyserutils.common.channel.GeyserUtilsChannels;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
@@ -9,7 +8,7 @@ public final class GeyserUtils extends Plugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
ProxyServer.getInstance()
|
||||
.registerChannel(GeyserUtilsChannels.MAIN);
|
||||
.registerChannel("geyserutils:main");
|
||||
// Plugin startup logic
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ package me.zimzaza4.geyserutils.geyser;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundDamageEventPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.PacketSendingEvent;
|
||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -46,6 +49,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
@@ -116,6 +120,19 @@ public class GeyserUtils implements Extension {
|
||||
public void onSessionJoin(SessionJoinEvent event) {
|
||||
if (event.connection() instanceof GeyserSession session) {
|
||||
session.getDownstream().getSession().addListener(new SessionAdapter() {
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent event) {
|
||||
Packet packet = event.getPacket();
|
||||
if (packet instanceof ServerboundCustomPayloadPacket payloadPacket) {
|
||||
if (payloadPacket.getChannel().equals("minecraft:register")) {
|
||||
String channels = new String(payloadPacket.getData(), StandardCharsets.UTF_8);
|
||||
channels = channels + "\0" + GeyserUtilsChannels.MAIN;
|
||||
event.setPacket(new ServerboundCustomPayloadPacket("minecraft:register", channels.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void packetReceived(Session tcpSession, Packet packet) {
|
||||
|
||||
|
||||
@@ -93,11 +93,5 @@
|
||||
<version>3.2.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.zimzaza4</groupId>
|
||||
<artifactId>geyserutils-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package me.zimzaza4.geyserutils.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import me.zimzaza4.geyserutils.common.channel.GeyserUtilsChannels;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -29,6 +28,6 @@ public class GeyserUtils {
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
|
||||
server.getChannelRegistrar().register(MinecraftChannelIdentifier.from(GeyserUtilsChannels.MAIN));
|
||||
server.getChannelRegistrar().register(MinecraftChannelIdentifier.from("geyserutils:main"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user