mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 19:35:00 -04:00
rename and refactor more S2C packets
This commit is contained in:
parent
e31fa26617
commit
9055dba6cd
@ -45,7 +45,7 @@ public class EntitySpawnEvent extends PlayConnectionEvent {
|
|||||||
this.entity = pkg.getEntity();
|
this.entity = pkg.getEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySpawnEvent(PlayConnection connection, PacketSpawnObject pkg) {
|
public EntitySpawnEvent(PlayConnection connection, EntityObjectSpawnS2CP pkg) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.entity = pkg.getEntity();
|
this.entity = pkg.getEntity();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.modding.event.events;
|
|||||||
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent;
|
import de.bixilon.minosoft.data.text.ChatComponent;
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.login.PacketLoginDisconnect;
|
import de.bixilon.minosoft.protocol.packets.s2c.login.LoginKickS2CP;
|
||||||
|
|
||||||
public class LoginDisconnectEvent extends PlayConnectionEvent {
|
public class LoginDisconnectEvent extends PlayConnectionEvent {
|
||||||
private final ChatComponent reason;
|
private final ChatComponent reason;
|
||||||
@ -25,7 +25,7 @@ public class LoginDisconnectEvent extends PlayConnectionEvent {
|
|||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginDisconnectEvent(PlayConnection connection, PacketLoginDisconnect pkg) {
|
public LoginDisconnectEvent(PlayConnection connection, LoginKickS2CP pkg) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.reason = pkg.getReason();
|
this.reason = pkg.getReason();
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.modding.event.events;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.login.PacketLoginPluginRequest;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
|
|
||||||
public class LoginPluginMessageRequestEvent extends CancelableEvent {
|
|
||||||
private final int messageId;
|
|
||||||
private final String channel;
|
|
||||||
private final PlayInByteBuffer data;
|
|
||||||
|
|
||||||
public LoginPluginMessageRequestEvent(PlayConnection connection, int messageId, String channel, PlayInByteBuffer data) {
|
|
||||||
super(connection);
|
|
||||||
this.messageId = messageId;
|
|
||||||
this.channel = channel;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoginPluginMessageRequestEvent(PlayConnection connection, PacketLoginPluginRequest pkg) {
|
|
||||||
super(connection);
|
|
||||||
this.messageId = pkg.getMessageId();
|
|
||||||
this.channel = pkg.getChannel();
|
|
||||||
this.data = pkg.getDataAsBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMessageId() {
|
|
||||||
return this.messageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChannel() {
|
|
||||||
return this.channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayInByteBuffer getData() {
|
|
||||||
return this.data;
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.modding.event.events;
|
|||||||
import de.bixilon.minosoft.modding.event.events.annotations.MaximumProtocolVersion;
|
import de.bixilon.minosoft.modding.event.events.annotations.MaximumProtocolVersion;
|
||||||
import de.bixilon.minosoft.modding.event.events.annotations.MinimumProtocolVersion;
|
import de.bixilon.minosoft.modding.event.events.annotations.MinimumProtocolVersion;
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.PacketResourcePackSend;
|
import de.bixilon.minosoft.protocol.packets.s2c.play.ResourcepackRequestS2CP;
|
||||||
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_14W31A;
|
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_14W31A;
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_10_PRE1;
|
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_10_PRE1;
|
||||||
@ -32,7 +32,7 @@ public class ResourcePackChangeEvent extends CancelableEvent {
|
|||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourcePackChangeEvent(PlayConnection connection, PacketResourcePackSend pkg) {
|
public ResourcePackChangeEvent(PlayConnection connection, ResourcepackRequestS2CP pkg) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.url = pkg.getUrl();
|
this.url = pkg.getUrl();
|
||||||
this.hash = pkg.getHash();
|
this.hash = pkg.getHash();
|
||||||
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.protocol.network.connection.Connection;
|
|||||||
import de.bixilon.minosoft.protocol.packets.c2s.C2SPacket;
|
import de.bixilon.minosoft.protocol.packets.c2s.C2SPacket;
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionResponseC2SP;
|
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionResponseC2SP;
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket;
|
import de.bixilon.minosoft.protocol.packets.s2c.S2CPacket;
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.login.PacketEncryptionRequest;
|
import de.bixilon.minosoft.protocol.packets.s2c.login.EncryptionRequestS2CP;
|
||||||
import de.bixilon.minosoft.protocol.protocol.ConnectionStates;
|
import de.bixilon.minosoft.protocol.protocol.ConnectionStates;
|
||||||
import de.bixilon.minosoft.protocol.protocol.CryptManager;
|
import de.bixilon.minosoft.protocol.protocol.CryptManager;
|
||||||
import de.bixilon.minosoft.protocol.protocol.PacketTypes;
|
import de.bixilon.minosoft.protocol.protocol.PacketTypes;
|
||||||
@ -156,7 +156,7 @@ public class BlockingSocketNetwork extends Network {
|
|||||||
@Override
|
@Override
|
||||||
protected void handlePacket(PacketTypes.S2C packetType, S2CPacket packet) {
|
protected void handlePacket(PacketTypes.S2C packetType, S2CPacket packet) {
|
||||||
super.handlePacket(packetType, packet);
|
super.handlePacket(packetType, packet);
|
||||||
if (packet instanceof PacketEncryptionRequest) {
|
if (packet instanceof EncryptionRequestS2CP) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(Integer.MAX_VALUE);
|
Thread.sleep(Integer.MAX_VALUE);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
|
@ -19,7 +19,7 @@ import de.bixilon.minosoft.util.logging.Log
|
|||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class TabCompleteC2SP(
|
class AutocompletionsC2SP(
|
||||||
val text: String,
|
val text: String,
|
||||||
val assumeCommand: Boolean,
|
val assumeCommand: Boolean,
|
||||||
val position: Vec3i? = null,
|
val position: Vec3i? = null,
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.login
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.ErrorHandler
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionResponseC2SP
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.CryptManager
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
import java.math.BigInteger
|
||||||
|
|
||||||
|
class EncryptionRequestS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val serverId: String = buffer.readString()
|
||||||
|
val publicKey: ByteArray = buffer.readByteArray()
|
||||||
|
val verifyToken: ByteArray = buffer.readByteArray()
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
val secretKey = CryptManager.createNewSharedKey()
|
||||||
|
val publicKey = CryptManager.decodePublicKey(publicKey)
|
||||||
|
val serverHash = BigInteger(CryptManager.getServerHash(serverId, publicKey, secretKey)).toString(16)
|
||||||
|
connection.account.join(serverHash)
|
||||||
|
connection.sendPacket(EncryptionResponseC2SP(secretKey, verifyToken, publicKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Encryption request (serverId=$serverId, publicKey=$publicKey, verifyToken=$verifyToken)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : ErrorHandler {
|
||||||
|
override fun onError(connection: Connection) {
|
||||||
|
connection.disconnect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.login
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
import de.bixilon.minosoft.modding.event.events.LoginDisconnectEvent
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
|
class LoginKickS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val reason: ChatComponent = buffer.readChatComponent()
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
connection.fireEvent(LoginDisconnectEvent(connection, this))
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Kicked from: $reason" }
|
||||||
|
connection.disconnect()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Login kick (reason=$reason)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.login
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ConnectionStates
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.util.Util
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class LoginSuccessS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val uuid: UUID = if (buffer.versionId < ProtocolVersions.V_20W12A) {
|
||||||
|
Util.getUUIDFromString(buffer.readString())
|
||||||
|
} else {
|
||||||
|
buffer.readUUID()
|
||||||
|
}
|
||||||
|
val name: String = buffer.readString()
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
connection.connectionState = ConnectionStates.PLAY
|
||||||
|
|
||||||
|
val playerEntity = connection.player.entity
|
||||||
|
playerEntity.tabListItem.name = name
|
||||||
|
playerEntity.tabListItem.displayName = ChatComponent.of(name)
|
||||||
|
|
||||||
|
connection.world.entities.add(null, uuid, playerEntity)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Login success (uuid=$uuid, name=$name)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.login;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.login.EncryptionResponseC2SP;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.CryptManager;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
import de.bixilon.minosoft.util.mojang.api.exceptions.MojangJoinServerErrorException;
|
|
||||||
import de.bixilon.minosoft.util.mojang.api.exceptions.NoNetworkConnectionException;
|
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.PublicKey;
|
|
||||||
|
|
||||||
public class PacketEncryptionRequest extends PlayS2CPacket {
|
|
||||||
private final String serverId; // normally empty
|
|
||||||
private final byte[] publicKey;
|
|
||||||
private final byte[] verifyToken;
|
|
||||||
|
|
||||||
public PacketEncryptionRequest(PlayInByteBuffer buffer) {
|
|
||||||
this.serverId = buffer.readString();
|
|
||||||
this.publicKey = buffer.readByteArray();
|
|
||||||
this.verifyToken = buffer.readByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PlayConnection connection) {
|
|
||||||
SecretKey secretKey = CryptManager.createNewSharedKey();
|
|
||||||
PublicKey publicKey = CryptManager.decodePublicKey(getPublicKey());
|
|
||||||
String serverHash = new BigInteger(CryptManager.getServerHash(getServerId(), publicKey, secretKey)).toString(16);
|
|
||||||
try {
|
|
||||||
connection.getAccount().join(serverHash);
|
|
||||||
} catch (MojangJoinServerErrorException | NoNetworkConnectionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
connection.disconnect();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.sendPacket(new EncryptionResponseC2SP(secretKey, getVerifyToken(), publicKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol("[IN] Receiving encryption request packet");
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getPublicKey() {
|
|
||||||
return this.publicKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getVerifyToken() {
|
|
||||||
return this.verifyToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerId() {
|
|
||||||
return this.serverId;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.login;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent;
|
|
||||||
import de.bixilon.minosoft.modding.event.events.LoginDisconnectEvent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
|
|
||||||
public class PacketLoginDisconnect extends PlayS2CPacket {
|
|
||||||
private final ChatComponent reason;
|
|
||||||
|
|
||||||
public PacketLoginDisconnect(PlayInByteBuffer buffer) {
|
|
||||||
this.reason = buffer.readChatComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PlayConnection connection) {
|
|
||||||
connection.fireEvent(new LoginDisconnectEvent(connection, this));
|
|
||||||
Log.info(String.format("Kicked while logging in to %s (reason=%s)", connection.getAddress(), getReason().getAnsiColoredMessage()));
|
|
||||||
connection.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Receiving login disconnect packet (%s)", this.reason.getAnsiColoredMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatComponent getReason() {
|
|
||||||
return this.reason;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.login;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.modding.event.events.LoginPluginMessageRequestEvent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
|
|
||||||
public class PacketLoginPluginRequest extends PlayS2CPacket {
|
|
||||||
private final int messageId;
|
|
||||||
private final String channel;
|
|
||||||
private final byte[] data;
|
|
||||||
private final PlayConnection connection;
|
|
||||||
|
|
||||||
public PacketLoginPluginRequest(PlayInByteBuffer buffer) {
|
|
||||||
this.connection = buffer.getConnection();
|
|
||||||
this.messageId = buffer.readVarInt();
|
|
||||||
this.channel = buffer.readString();
|
|
||||||
this.data = buffer.readRest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PlayConnection connection) {
|
|
||||||
connection.fireEvent(new LoginPluginMessageRequestEvent(this.connection, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Received login plugin request in channel \"%s\" with %s bytes of data (messageId=%d)", this.channel, this.data.length, this.messageId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMessageId() {
|
|
||||||
return this.messageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChannel() {
|
|
||||||
return this.channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getData() {
|
|
||||||
return this.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayInByteBuffer getDataAsBuffer() {
|
|
||||||
return new PlayInByteBuffer(this.data, this.connection);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.login
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
|
class PacketLoginPluginRequest(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val messageId = buffer.readVarInt()
|
||||||
|
val channel = buffer.readString()
|
||||||
|
val data: PlayInByteBuffer = PlayInByteBuffer(buffer.readRest(), buffer.connection)
|
||||||
|
get() = PlayInByteBuffer(field)
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
// ToDo: connection.fireEvent(LoginPluginMessageRequestEvent(connection, this))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Login plugin request (messageId=$messageId, channel=$channel, data=${data.readRest()})" }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.login;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.ConnectionStates;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.util.Util;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W12A;
|
|
||||||
|
|
||||||
public class PacketLoginSuccess extends PlayS2CPacket {
|
|
||||||
private final UUID uuid;
|
|
||||||
private final String playerName;
|
|
||||||
|
|
||||||
public PacketLoginSuccess(PlayInByteBuffer buffer) {
|
|
||||||
if (buffer.getVersionId() < V_20W12A) {
|
|
||||||
this.uuid = Util.getUUIDFromString(buffer.readString());
|
|
||||||
} else {
|
|
||||||
this.uuid = buffer.readUUID();
|
|
||||||
}
|
|
||||||
this.playerName = buffer.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PlayConnection connection) {
|
|
||||||
connection.setConnectionState(ConnectionStates.PLAY);
|
|
||||||
|
|
||||||
var playerEntity = connection.getPlayer().getEntity();
|
|
||||||
playerEntity.getTabListItem().setName(this.playerName);
|
|
||||||
playerEntity.getTabListItem().setDisplayName(ChatComponent.Companion.of(this.playerName));
|
|
||||||
|
|
||||||
connection.getWorld().getEntities().add(null, this.uuid, playerEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Receiving login success packet (username=%s, uuid=%s)", this.playerName, this.uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUUID() {
|
|
||||||
return this.uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlayerName() {
|
|
||||||
return this.playerName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
|
class AutocompletionsS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
var matches: Array<String> = when {
|
||||||
|
buffer.versionId < ProtocolVersions.V_14W33A -> {
|
||||||
|
buffer.readVarInt() // ToDo: count?
|
||||||
|
arrayOf(buffer.readString())
|
||||||
|
}
|
||||||
|
buffer.versionId < ProtocolVersions.V_17W45A -> {
|
||||||
|
buffer.readStringArray()
|
||||||
|
}
|
||||||
|
else -> TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Autocompletions (matches=$matches)" }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||||
|
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||||
|
import de.bixilon.minosoft.data.mappings.DefaultRegistries.ENTITY_OBJECT_REGISTRY
|
||||||
|
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class EntityObjectSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val entityId: Int = buffer.readEntityId()
|
||||||
|
var entityUUID: UUID? = null
|
||||||
|
private set
|
||||||
|
val entity: Entity
|
||||||
|
var velocity: Vec3? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_15W31A) {
|
||||||
|
entityUUID = buffer.readUUID()
|
||||||
|
}
|
||||||
|
val type: Int = if (buffer.versionId < ProtocolVersions.V_16W32A) {
|
||||||
|
buffer.readByte().toInt()
|
||||||
|
} else {
|
||||||
|
buffer.readVarInt()
|
||||||
|
}
|
||||||
|
val position: Vec3 = if (buffer.versionId < ProtocolVersions.V_16W06A) {
|
||||||
|
Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt())
|
||||||
|
} else {
|
||||||
|
buffer.readPosition()
|
||||||
|
}
|
||||||
|
val rotation = EntityRotation(buffer.readAngle().toFloat(), buffer.readAngle().toFloat(), 0.0f)
|
||||||
|
val data = buffer.readInt()
|
||||||
|
|
||||||
|
if (buffer.versionId < ProtocolVersions.V_15W31A) {
|
||||||
|
if (data != 0) {
|
||||||
|
velocity = Vec3(buffer.readShort(), buffer.readShort(), buffer.readShort()) * ProtocolDefinition.VELOCITY_CONSTANT
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
velocity = Vec3(buffer.readShort(), buffer.readShort(), buffer.readShort()) * ProtocolDefinition.VELOCITY_CONSTANT
|
||||||
|
}
|
||||||
|
entity = if (buffer.versionId < ProtocolVersions.V_19W05A) {
|
||||||
|
val entityResourceLocation = ENTITY_OBJECT_REGISTRY.get(type).resourceLocation
|
||||||
|
buffer.connection.mapping.entityRegistry.get(entityResourceLocation)!!.build(buffer.connection, position, rotation, null, buffer.versionId)!! // ToDo: Entity meta data tweaking
|
||||||
|
} else {
|
||||||
|
buffer.connection.mapping.entityRegistry.get(type).build(buffer.connection, position, rotation, null, buffer.versionId)!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
connection.fireEvent(EntitySpawnEvent(connection, this))
|
||||||
|
connection.world.entities.add(entityId, entityUUID, entity)
|
||||||
|
velocity?.let { entity.velocity = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity object spawn (entityId=$entityId, entityUUID=$entityUUID, entity=$entity, velocity=$velocity)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.SoundCategories
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
class NamedSoundEventS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val sound: String
|
||||||
|
val volume: Float
|
||||||
|
val pitch: Float
|
||||||
|
lateinit var position: Vec3
|
||||||
|
private set
|
||||||
|
lateinit var category: SoundCategories
|
||||||
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_17W15A && buffer.versionId < ProtocolVersions.V_17W18A) {
|
||||||
|
this.category = SoundCategories[buffer.readVarInt()]
|
||||||
|
}
|
||||||
|
sound = buffer.readString()
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_17W15A && buffer.versionId < ProtocolVersions.V_17W18A) {
|
||||||
|
buffer.readString() // parrot entity type
|
||||||
|
}
|
||||||
|
if (buffer.versionId < ProtocolVersions.V_16W02A) {
|
||||||
|
position = Vec3(buffer.readInt() * 8, buffer.readInt() * 8, buffer.readInt() * 8) // ToDo: check if it is not * 4
|
||||||
|
}
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_16W02A && (buffer.versionId < ProtocolVersions.V_17W15A || buffer.versionId >= ProtocolVersions.V_17W18A)) {
|
||||||
|
this.category = SoundCategories[buffer.readVarInt()]
|
||||||
|
}
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_16W02A) {
|
||||||
|
position = Vec3(buffer.readFixedPointNumberInt() * 4, buffer.readFixedPointNumberInt() * 4, buffer.readFixedPointNumberInt() * 4)
|
||||||
|
}
|
||||||
|
volume = buffer.readFloat()
|
||||||
|
pitch = if (buffer.versionId < ProtocolVersions.V_16W20A) {
|
||||||
|
buffer.readByte() * ProtocolDefinition.PITCH_CALCULATION_CONSTANT / 100.0f
|
||||||
|
} else {
|
||||||
|
buffer.readFloat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Named sound event (sound=$sound, volume=$volume, pitch=$pitch,position=$position, category=$category)" }
|
||||||
|
}
|
||||||
|
}
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.play;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.SoundCategories;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
import glm_.vec3.Vec3;
|
|
||||||
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.*;
|
|
||||||
|
|
||||||
public class PacketNamedSoundEffect extends PlayS2CPacket {
|
|
||||||
private final String sound;
|
|
||||||
private final float volume;
|
|
||||||
private final float pitch;
|
|
||||||
private Vec3 position;
|
|
||||||
private SoundCategories category;
|
|
||||||
|
|
||||||
public PacketNamedSoundEffect(PlayInByteBuffer buffer) {
|
|
||||||
if (buffer.getVersionId() >= V_17W15A && buffer.getVersionId() < V_17W18A) {
|
|
||||||
// category was moved to the top
|
|
||||||
this.category = SoundCategories.Companion.get(buffer.readVarInt());
|
|
||||||
}
|
|
||||||
this.sound = buffer.readString();
|
|
||||||
|
|
||||||
if (buffer.getVersionId() >= V_17W15A && buffer.getVersionId() < V_17W18A) {
|
|
||||||
buffer.readString(); // parrot entity type
|
|
||||||
}
|
|
||||||
if (buffer.getVersionId() < V_16W02A) {
|
|
||||||
this.position = new Vec3(buffer.readInt() * 8, buffer.readInt() * 8, buffer.readInt() * 8); // ToDo: check if it is not * 4
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer.getVersionId() >= V_16W02A && (buffer.getVersionId() < V_17W15A || buffer.getVersionId() >= V_17W18A)) {
|
|
||||||
this.category = SoundCategories.Companion.get(buffer.readVarInt());
|
|
||||||
}
|
|
||||||
if (buffer.getVersionId() >= V_16W02A) {
|
|
||||||
this.position = new Vec3(buffer.readFixedPointNumberInt() * 4, buffer.readFixedPointNumberInt() * 4, buffer.readFixedPointNumberInt() * 4);
|
|
||||||
}
|
|
||||||
this.volume = buffer.readFloat();
|
|
||||||
if (buffer.getVersionId() < V_16W20A) {
|
|
||||||
this.pitch = (buffer.readByte() * ProtocolDefinition.PITCH_CALCULATION_CONSTANT) / 100F;
|
|
||||||
} else {
|
|
||||||
this.pitch = buffer.readFloat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Play sound effect (sound=%s, category=%s, volume=%s, pitch=%s, position=%s)", this.sound, this.category, this.volume, this.pitch, this.position));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3 getPosition() {
|
|
||||||
return this.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Pitch in Percent
|
|
||||||
*/
|
|
||||||
public float getPitch() {
|
|
||||||
return this.pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSound() {
|
|
||||||
return this.sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getVolume() {
|
|
||||||
return this.volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoundCategories getCategory() {
|
|
||||||
return this.category;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.play;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent;
|
|
||||||
import de.bixilon.minosoft.modding.event.events.ResourcePackChangeEvent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ResourcePackStatusC2SP;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.util.Util;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W45A;
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_21W15A;
|
|
||||||
|
|
||||||
public class PacketResourcePackSend extends PlayS2CPacket {
|
|
||||||
private final String url;
|
|
||||||
private final String hash;
|
|
||||||
private boolean forced;
|
|
||||||
private ChatComponent promptText;
|
|
||||||
|
|
||||||
public PacketResourcePackSend(PlayInByteBuffer buffer) {
|
|
||||||
this.url = buffer.readString();
|
|
||||||
Util.checkURL(this.url);
|
|
||||||
this.hash = buffer.readString();
|
|
||||||
if (buffer.getVersionId() >= V_20W45A) {
|
|
||||||
this.forced = buffer.readBoolean();
|
|
||||||
}
|
|
||||||
if (buffer.getVersionId() >= V_21W15A) {
|
|
||||||
if (buffer.readBoolean()) {
|
|
||||||
this.promptText = buffer.readChatComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PlayConnection connection) {
|
|
||||||
ResourcePackChangeEvent event = new ResourcePackChangeEvent(connection, this);
|
|
||||||
if (connection.fireEvent(event)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.sendPacket(new ResourcePackStatusC2SP(this.hash, ResourcePackStatusC2SP.ResourcePackStates.SUCCESSFULLY));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Received resource pack send (url=\"%s\", hash=%s)", this.url, this.hash));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHash() {
|
|
||||||
return this.hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isForced() {
|
|
||||||
return this.forced;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatComponent getPromptText() {
|
|
||||||
return this.promptText;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.play;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.entities.EntityRotation;
|
|
||||||
import de.bixilon.minosoft.data.entities.entities.Entity;
|
|
||||||
import de.bixilon.minosoft.data.mappings.DefaultRegistries;
|
|
||||||
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
import glm_.vec3.Vec3;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.*;
|
|
||||||
|
|
||||||
public class PacketSpawnObject extends PlayS2CPacket {
|
|
||||||
private final int entityId;
|
|
||||||
private final Entity entity;
|
|
||||||
private UUID entityUUID;
|
|
||||||
private Vec3 velocity;
|
|
||||||
|
|
||||||
public PacketSpawnObject(PlayInByteBuffer buffer) throws Exception {
|
|
||||||
this.entityId = buffer.readEntityId();
|
|
||||||
if (buffer.getVersionId() >= V_15W31A) {
|
|
||||||
this.entityUUID = buffer.readUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
int type;
|
|
||||||
if (buffer.getVersionId() < V_16W32A) {
|
|
||||||
type = buffer.readByte();
|
|
||||||
} else {
|
|
||||||
type = buffer.readVarInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3 position;
|
|
||||||
if (buffer.getVersionId() < V_16W06A) {
|
|
||||||
position = new Vec3(buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt(), buffer.readFixedPointNumberInt());
|
|
||||||
} else {
|
|
||||||
position = buffer.readPosition();
|
|
||||||
}
|
|
||||||
EntityRotation rotation = new EntityRotation(buffer.readAngle(), buffer.readAngle(), 0);
|
|
||||||
int data = buffer.readInt();
|
|
||||||
|
|
||||||
if (buffer.getVersionId() < V_15W31A) {
|
|
||||||
if (data != 0) {
|
|
||||||
this.velocity = new Vec3(buffer.readShort(), buffer.readShort(), buffer.readShort()).times(ProtocolDefinition.VELOCITY_CONSTANT);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.velocity = new Vec3(buffer.readShort(), buffer.readShort(), buffer.readShort()).times(ProtocolDefinition.VELOCITY_CONSTANT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer.getVersionId() < V_19W05A) {
|
|
||||||
var entityResourceLocation = DefaultRegistries.INSTANCE.getENTITY_OBJECT_REGISTRY().get(type).getResourceLocation();
|
|
||||||
this.entity = buffer.getConnection().getMapping().getEntityRegistry().get(entityResourceLocation).build(buffer.getConnection(), position, rotation, null, buffer.getVersionId()); // ToDo: Entity meta data tweaking
|
|
||||||
} else {
|
|
||||||
this.entity = buffer.getConnection().getMapping().getEntityRegistry().get(type).build(buffer.getConnection(), position, rotation, null, buffer.getVersionId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PlayConnection connection) {
|
|
||||||
connection.fireEvent(new EntitySpawnEvent(connection, this));
|
|
||||||
|
|
||||||
connection.getWorld().getEntities().add(this.entityId, this.entityUUID, getEntity());
|
|
||||||
this.entity.setVelocity(this.velocity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Object spawned at %s (entityId=%d, type=%s)", this.entity.getPosition(), this.entityId, this.entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entity getEntity() {
|
|
||||||
return this.entity;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.play;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer;
|
|
||||||
import de.bixilon.minosoft.util.logging.Log;
|
|
||||||
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_14W33A;
|
|
||||||
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_17W45A;
|
|
||||||
|
|
||||||
public class PacketTabCompleteReceiving extends PlayS2CPacket {
|
|
||||||
private final int count;
|
|
||||||
private final String[] match;
|
|
||||||
|
|
||||||
public PacketTabCompleteReceiving(PlayInByteBuffer buffer) {
|
|
||||||
if (buffer.getVersionId() < V_14W33A) {
|
|
||||||
this.count = buffer.readVarInt();
|
|
||||||
this.match = new String[]{buffer.readString()};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (buffer.getVersionId() < V_17W45A) {
|
|
||||||
this.count = buffer.readVarInt();
|
|
||||||
this.match = new String[this.count];
|
|
||||||
for (int i = 0; i < this.count; i++) {
|
|
||||||
this.match[i] = buffer.readString();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// ToDo
|
|
||||||
throw new IllegalStateException("TODO");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("[IN] Received tab complete for message(count=%d)", this.count));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
|
||||||
return this.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getMatch() {
|
|
||||||
return this.match;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
import de.bixilon.minosoft.modding.event.events.ResourcePackChangeEvent
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.c2s.play.ResourcePackStatusC2SP
|
||||||
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||||
|
import de.bixilon.minosoft.util.Util
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
|
||||||
|
class ResourcepackRequestS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
|
val url: String = Util.checkURL(buffer.readString())
|
||||||
|
val hash: String = buffer.readString()
|
||||||
|
val forced = if (buffer.versionId >= ProtocolVersions.V_20W45A) {
|
||||||
|
buffer.readBoolean()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
var promptText: ChatComponent? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (buffer.versionId >= ProtocolVersions.V_21W15A) {
|
||||||
|
if (buffer.readBoolean()) {
|
||||||
|
promptText = buffer.readChatComponent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handle(connection: PlayConnection) {
|
||||||
|
val event = ResourcePackChangeEvent(connection, this)
|
||||||
|
if (connection.fireEvent(event)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
connection.sendPacket(ResourcePackStatusC2SP(hash, ResourcePackStatusC2SP.ResourcePackStates.SUCCESSFULLY)) // ToDo: This fakes it, to not get kicked on most servers
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Resourcepack request (url=$url, hash=$hash, forced=$forced, promptText=$promptText)" }
|
||||||
|
}
|
||||||
|
}
|
@ -61,7 +61,7 @@ class PacketTypes {
|
|||||||
PLAY_CHAT_MESSAGE(ChatMessageC2SP::class.java),
|
PLAY_CHAT_MESSAGE(ChatMessageC2SP::class.java),
|
||||||
PLAY_CLIENT_ACTION(ClientActionC2SP::class.java),
|
PLAY_CLIENT_ACTION(ClientActionC2SP::class.java),
|
||||||
PLAY_CLIENT_SETTINGS(ClientSettingsC2SP::class.java),
|
PLAY_CLIENT_SETTINGS(ClientSettingsC2SP::class.java),
|
||||||
PLAY_TAB_COMPLETE(TabCompleteC2SP::class.java),
|
PLAY_AUTOCOMPLETIONS(AutocompletionsC2SP::class.java),
|
||||||
PLAY_CONTAINER_ACTION_STATUS(ContainerActionStatusC2SP::class.java),
|
PLAY_CONTAINER_ACTION_STATUS(ContainerActionStatusC2SP::class.java),
|
||||||
PLAY_CONTAINER_CLICK_BUTTON(ContainerClickButtonC2SP::class.java),
|
PLAY_CONTAINER_CLICK_BUTTON(ContainerClickButtonC2SP::class.java),
|
||||||
PLAY_CONTAINER_SLOT_CLICK(ContainerSlotClickC2SP::class.java),
|
PLAY_CONTAINER_SLOT_CLICK(ContainerSlotClickC2SP::class.java),
|
||||||
@ -148,9 +148,9 @@ class PacketTypes {
|
|||||||
) {
|
) {
|
||||||
STATUS_RESPONSE(statusFactory = { PacketStatusResponse(it) }, isThreadSafe = false),
|
STATUS_RESPONSE(statusFactory = { PacketStatusResponse(it) }, isThreadSafe = false),
|
||||||
STATUS_PONG(statusFactory = { StatusPongS2CP(it) }, isThreadSafe = false),
|
STATUS_PONG(statusFactory = { StatusPongS2CP(it) }, isThreadSafe = false),
|
||||||
LOGIN_DISCONNECT({ PacketLoginDisconnect(it) }, isThreadSafe = false),
|
LOGIN_KICK({ LoginKickS2CP(it) }, isThreadSafe = false),
|
||||||
LOGIN_ENCRYPTION_REQUEST({ PacketEncryptionRequest(it) }, isThreadSafe = false),
|
LOGIN_ENCRYPTION_REQUEST({ EncryptionRequestS2CP(it) }, isThreadSafe = false, errorHandler = EncryptionRequestS2CP),
|
||||||
LOGIN_LOGIN_SUCCESS({ PacketLoginSuccess(it) }, isThreadSafe = false),
|
LOGIN_LOGIN_SUCCESS({ LoginSuccessS2CP(it) }, isThreadSafe = false),
|
||||||
LOGIN_COMPRESSION_SET({ CompressionSetS2CP(it) }, isThreadSafe = false),
|
LOGIN_COMPRESSION_SET({ CompressionSetS2CP(it) }, isThreadSafe = false),
|
||||||
LOGIN_PLUGIN_REQUEST({ PacketLoginPluginRequest(it) }),
|
LOGIN_PLUGIN_REQUEST({ PacketLoginPluginRequest(it) }),
|
||||||
PLAY_MOB_SPAWN({ MobSpawnS2CP(it) }, isThreadSafe = false),
|
PLAY_MOB_SPAWN({ MobSpawnS2CP(it) }, isThreadSafe = false),
|
||||||
@ -169,7 +169,7 @@ class PacketTypes {
|
|||||||
PLAY_SERVER_DIFFICULTY({ ServerDifficultyS2CP(it) }),
|
PLAY_SERVER_DIFFICULTY({ ServerDifficultyS2CP(it) }),
|
||||||
PLAY_CHAT_MESSAGE({ ChatMessageS2CP(it) }),
|
PLAY_CHAT_MESSAGE({ ChatMessageS2CP(it) }),
|
||||||
PLAY_MASS_BLOCK_SET({ MassBlockSetS2CP(it) }),
|
PLAY_MASS_BLOCK_SET({ MassBlockSetS2CP(it) }),
|
||||||
PLAY_TAB_COMPLETE({ PacketTabCompleteReceiving(it) }),
|
PLAY_AUTOCOMPLETIONS({ AutocompletionsS2CP(it) }),
|
||||||
PLAY_DECLARE_COMMANDS({ PacketDeclareCommands(it) }),
|
PLAY_DECLARE_COMMANDS({ PacketDeclareCommands(it) }),
|
||||||
PLAY_CONTAINER_ACTION_STATUS({ ContainerActionStatusS2CP(it) }),
|
PLAY_CONTAINER_ACTION_STATUS({ ContainerActionStatusS2CP(it) }),
|
||||||
PLAY_CONTAINER_CLOSE({ ContainerCloseS2CP(it) }),
|
PLAY_CONTAINER_CLOSE({ ContainerCloseS2CP(it) }),
|
||||||
@ -178,7 +178,7 @@ class PacketTypes {
|
|||||||
PLAY_CONTAINER_ITEM_SET({ ContainerItemSetS2CP(it) }),
|
PLAY_CONTAINER_ITEM_SET({ ContainerItemSetS2CP(it) }),
|
||||||
PLAY_ITEM_COOLDOWN_SET({ ItemCooldownSetS2CP(it) }),
|
PLAY_ITEM_COOLDOWN_SET({ ItemCooldownSetS2CP(it) }),
|
||||||
PLAY_PLUGIN_MESSAGE({ PluginMessageS2CP(it) }),
|
PLAY_PLUGIN_MESSAGE({ PluginMessageS2CP(it) }),
|
||||||
PLAY_NAMED_SOUND_EFFECT({ PacketNamedSoundEffect(it) }),
|
PLAY_NAMED_SOUND_EVENT({ NamedSoundEventS2CP(it) }),
|
||||||
PLAY_KICK({ KickS2CP(it) }, isThreadSafe = false),
|
PLAY_KICK({ KickS2CP(it) }, isThreadSafe = false),
|
||||||
PLAY_ENTITY_STATUS({ EntityStatusS2CP(it) }),
|
PLAY_ENTITY_STATUS({ EntityStatusS2CP(it) }),
|
||||||
PLAY_EXPLOSION({ ExplosionS2CP(it) }),
|
PLAY_EXPLOSION({ ExplosionS2CP(it) }),
|
||||||
@ -212,7 +212,7 @@ class PacketTypes {
|
|||||||
PLAY_UNLOCK_RECIPES({ PacketUnlockRecipes(it) }),
|
PLAY_UNLOCK_RECIPES({ PacketUnlockRecipes(it) }),
|
||||||
PLAY_ENTITY_DESTROY({ EntityDestroyS2CP(it) }),
|
PLAY_ENTITY_DESTROY({ EntityDestroyS2CP(it) }),
|
||||||
PLAY_REMOVE_ENTITY_EFFECT({ PacketRemoveEntityStatusEffect(it) }),
|
PLAY_REMOVE_ENTITY_EFFECT({ PacketRemoveEntityStatusEffect(it) }),
|
||||||
PLAY_RESOURCE_PACK_SEND({ PacketResourcePackSend(it) }),
|
PLAY_RESOURCEPACK_REQUEST({ ResourcepackRequestS2CP(it) }),
|
||||||
PLAY_RESPAWN({ RespawnS2CP(it) }, isThreadSafe = false),
|
PLAY_RESPAWN({ RespawnS2CP(it) }, isThreadSafe = false),
|
||||||
PLAY_ENTITY_HEAD_ROTATION({ EntityHeadRotationS2CP(it) }),
|
PLAY_ENTITY_HEAD_ROTATION({ EntityHeadRotationS2CP(it) }),
|
||||||
PLAY_SELECT_ADVANCEMENT_TAB({ PacketSelectAdvancementTab(it) }),
|
PLAY_SELECT_ADVANCEMENT_TAB({ PacketSelectAdvancementTab(it) }),
|
||||||
@ -256,7 +256,7 @@ class PacketTypes {
|
|||||||
PLAY_MASS_CHUNK_DATA({ MassChunkDataS2CP(it) }),
|
PLAY_MASS_CHUNK_DATA({ MassChunkDataS2CP(it) }),
|
||||||
PLAY_SIGN_TEXT_SET({ SignTextSetS2CP(it) }),
|
PLAY_SIGN_TEXT_SET({ SignTextSetS2CP(it) }),
|
||||||
PLAY_STATISTICS({ PacketStatistics(it) }),
|
PLAY_STATISTICS({ PacketStatistics(it) }),
|
||||||
PLAY_SPAWN_ENTITY({ PacketSpawnObject(it) }, isThreadSafe = false),
|
PLAY_ENTITY_OBJECT_SPAWN({ EntityObjectSpawnS2CP(it) }, isThreadSafe = false),
|
||||||
PLAY_TITLE({ TitleS2CF.createPacket(it) }),
|
PLAY_TITLE({ TitleS2CF.createPacket(it) }),
|
||||||
PLAY_TITLE_CLEAR({ TitleS2CF.createClearTitlePacket(it) }),
|
PLAY_TITLE_CLEAR({ TitleS2CF.createClearTitlePacket(it) }),
|
||||||
PLAY_HOTBAR_TEXT_SET({ HotbarTextSetS2CP(it) }),
|
PLAY_HOTBAR_TEXT_SET({ HotbarTextSetS2CP(it) }),
|
||||||
|
@ -59,7 +59,7 @@ object Protocol {
|
|||||||
)
|
)
|
||||||
S2C_PACKET_MAPPING[ConnectionStates.LOGIN] = HashBiMap.create(
|
S2C_PACKET_MAPPING[ConnectionStates.LOGIN] = HashBiMap.create(
|
||||||
mapOf(
|
mapOf(
|
||||||
S2C.LOGIN_DISCONNECT to 0x00,
|
S2C.LOGIN_KICK to 0x00,
|
||||||
S2C.LOGIN_ENCRYPTION_REQUEST to 0x01,
|
S2C.LOGIN_ENCRYPTION_REQUEST to 0x01,
|
||||||
S2C.LOGIN_LOGIN_SUCCESS to 0x02,
|
S2C.LOGIN_LOGIN_SUCCESS to 0x02,
|
||||||
S2C.LOGIN_COMPRESSION_SET to 0x03,
|
S2C.LOGIN_COMPRESSION_SET to 0x03,
|
||||||
|
@ -270,10 +270,11 @@ public final class Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkURL(String url) {
|
public static String checkURL(String url) {
|
||||||
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
||||||
throw new IllegalArgumentException("Not a valid url:" + url);
|
throw new IllegalArgumentException("Not a valid url:" + url);
|
||||||
}
|
}
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void forceClassInit(Class<T> clazz) {
|
public static <T> void forceClassInit(Class<T> clazz) {
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user