Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 13:22:54 +02:00
Ursprung
07078b21f1
Commit
87afb84a4d
@ -10,19 +10,59 @@
|
|||||||
|
|
||||||
package nl.matsv.viabackwards;
|
package nl.matsv.viabackwards;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||||
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||||
|
|
||||||
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform, Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||||
|
getProxy().getPluginManager().registerListener(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Why is this not a thing in Bungee? O_o
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = -110) // Slightly later than VV
|
||||||
|
public void serverConnected(ServerConnectedEvent event) {
|
||||||
|
ProxiedPlayer player = event.getPlayer();
|
||||||
|
if (player.getServer() == null) return;
|
||||||
|
|
||||||
|
UserConnection connection = Via.getManager().getConnection(player.getUniqueId());
|
||||||
|
if (connection == null) return;
|
||||||
|
|
||||||
|
ProtocolInfo info = connection.getProtocolInfo();
|
||||||
|
if (info == null || !info.getPipeline().contains(Protocol1_15_2To1_16.class)) return;
|
||||||
|
|
||||||
|
// Need to send a dummy respawn with a different dimension before the actual respawn
|
||||||
|
// We also don't know what dimension it's sent to, so just send 2 dummies :>
|
||||||
|
sendRespawn(connection, -1);
|
||||||
|
sendRespawn(connection, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendRespawn(UserConnection connection, int dimension) {
|
||||||
|
PacketWrapper packet = new PacketWrapper(ClientboundPackets1_15.RESPAWN.ordinal(), null, connection);
|
||||||
|
packet.write(Type.INT, dimension);
|
||||||
|
packet.write(Type.LONG, 0L);
|
||||||
|
packet.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||||
|
packet.write(Type.STRING, "default");
|
||||||
|
try {
|
||||||
|
packet.send(Protocol1_15_2To1_16.class, true, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren