func (this *packetClientLoginEncryptRequestCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientLoginEncryptRequest := new(PacketClientLoginEncryptRequest)
	packetClientLoginEncryptRequest.ServerId, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	publicKeyLength, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.PublicKey = make([]byte, publicKeyLength)
	_, err = reader.Read(packetClientLoginEncryptRequest.PublicKey)
	if err != nil {
		return
	}
	verifyTokenLength, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.VerifyToken = make([]byte, verifyTokenLength)
	_, err = reader.Read(packetClientLoginEncryptRequest.VerifyToken)
	if err != nil {
		return
	}
	decode = packetClientLoginEncryptRequest
	return
}
func (this *packetClientScoreboardObjectiveCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := new(PacketClientScoreboardObjective)
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	switch packetClientScoreboardObjective.Action {
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_ADD:
		fallthrough
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_UPDATE:
		packetClientScoreboardObjective.Value, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientScoreboardObjective.Type, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_REMOVE:
		// no payload
	default:
		err = errors.New(fmt.Sprintf("Decode, PacketClientScoreboardObjective action is not valid: %d", packetClientScoreboardObjective.Action))
	}
	decode = packetClientScoreboardObjective
	return
}
예제 #3
0
func (this *PacketServerEventCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerEvent := &PacketServerEvent{}
	packetServerEvent.Add, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	packetServerEvent.Server, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	if packetServerEvent.Add {
		packetServerEvent.SecurityKey, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetServerEvent.Address, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetServerEvent.Port, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
	}
	return packetServerEvent, nil
}
예제 #4
0
func (this *requestMessageCodec) Decode(reader io.Reader) (request Request, err error) {
	requestMessage := new(RequestMessage)
	recipientsSize, err := packet.ReadUint16(reader)
	if err != nil {
		return
	}
	requestMessage.Recipients = make([]string, recipientsSize)
	var i uint16
	for i = 0; i < recipientsSize; i++ {
		requestMessage.Recipients[i], err = packet.ReadString(reader)
		if err != nil {
			return
		}
	}
	requestMessage.Channel, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	messageSize, err := packet.ReadUint16(reader)
	if err != nil {
		return
	}
	requestMessage.Message = make([]byte, messageSize)
	_, err = reader.Read(requestMessage.Message)
	if err != nil {
		return
	}
	request = requestMessage
	return
}
func (this *requestAsProxyCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestAsProxy := new(RequestAsProxy)
	requestAsProxy.Address, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.Port, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.Motd, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.Version, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.MaxPlayers, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	request = requestAsProxy
	return
}
예제 #6
0
func (this *packetServerEventCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetServerEvent := new(PacketServerEvent)
	packetServerEvent.Add, err = packet.ReadBool(reader)
	if err != nil {
		return
	}
	packetServerEvent.Server, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	if packetServerEvent.Add {
		packetServerEvent.SecurityKey, err = packet.ReadString(reader)
		if err != nil {
			return
		}
		packetServerEvent.Address, err = packet.ReadString(reader)
		if err != nil {
			return
		}
		packetServerEvent.Port, err = packet.ReadUint16(reader)
		if err != nil {
			return
		}
	}
	decode = packetServerEvent
	return
}
예제 #7
0
func (this *RequestAuthenticateCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestAuthenticate := &RequestAuthenticate{}
	requestAuthenticate.Username, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAuthenticate.Password, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return requestAuthenticate, nil
}
예제 #8
0
func (this *PacketClientLoginSuccessCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientLoginSuccess := &PacketClientLoginSuccess{}
	packetClientLoginSuccess.UUID, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientLoginSuccess.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientLoginSuccess, nil
}
예제 #9
0
func (this *PacketRedirectEventCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetRedirectEvent := &PacketRedirectEvent{}
	packetRedirectEvent.Server, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetRedirectEvent.Player, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetRedirectEvent, nil
}
예제 #10
0
func (this *RequestRedirectCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestRedirect := &RequestRedirect{}
	requestRedirect.Server, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestRedirect.Player, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return requestRedirect, nil
}
예제 #11
0
func (this *packetClientLoginSuccessCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetClientLoginSuccess := new(PacketClientLoginSuccess)
	packetClientLoginSuccess.UUID, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetClientLoginSuccess.Name, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	decode = packetClientLoginSuccess
	return
}
예제 #12
0
func (this *packetRedirectEventCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetRedirectEvent := new(PacketRedirectEvent)
	packetRedirectEvent.Server, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetRedirectEvent.Player, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	decode = packetRedirectEvent
	return
}
예제 #13
0
func (this *requestAuthenticateCodec) Decode(reader io.Reader) (request Request, err error) {
	requestAuthenticate := new(RequestAuthenticate)
	requestAuthenticate.Username, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	requestAuthenticate.Password, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	request = requestAuthenticate
	return
}
예제 #14
0
func (this *requestRedirectCodec) Decode(reader io.Reader) (request Request, err error) {
	requestRedirect := new(RequestRedirect)
	requestRedirect.Server, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	requestRedirect.Player, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	request = requestRedirect
	return
}
예제 #15
0
func (this *PacketClientJoinGameCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientJoinGame := &PacketClientJoinGame{}
	packetClientJoinGame.EntityId, err = packet.ReadInt32(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Gamemode, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Dimension, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Difficulty, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.MaxPlayers, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.LevelType, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientJoinGame, nil
}
func (this *PacketClientLoginEncryptRequestCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientLoginEncryptRequest := &PacketClientLoginEncryptRequest{}
	packetClientLoginEncryptRequest.ServerId, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	publicKeySize, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.PublicKey = make([]byte, publicKeySize)
	_, err = reader.Read(packetClientLoginEncryptRequest.PublicKey)
	if err != nil {
		return
	}
	verifyTokenSize, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.VerifyToken = make([]byte, verifyTokenSize)
	_, err = reader.Read(packetClientLoginEncryptRequest.VerifyToken)
	if err != nil {
		return
	}
	return packetClientLoginEncryptRequest, nil
}
예제 #17
0
func (this *PacketServerClientSettingsCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerClientSettings := &PacketServerClientSettings{}
	packetServerClientSettings.Locale, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ViewDistance, err = packet.ReadUint8(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ChatFlags, err = packet.ReadUint8(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.Unused, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.Difficulty, err = packet.ReadUint8(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ShowCape, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	return packetServerClientSettings, nil
}
func (this *PacketClientScoreboardObjectiveCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := &PacketClientScoreboardObjective{}
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Value, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	return packetClientScoreboardObjective, nil
}
func (this *packetServerClientSettingsCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerClientSettings := new(PacketServerClientSettings)
	packetServerClientSettings.Locale, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ViewDistance, err = packet.ReadUint8(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ChatFlags, err = packet.ReadUint8(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ChatColours, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.difficulty17, err = packet.ReadUint8(reader, util)
	if err != nil {
		return
	}
	packetServerClientSettings.ShowCape, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	decode = packetServerClientSettings
	return
}
func (this *packetServerClientSettingsCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetServerClientSettings := new(PacketServerClientSettings)
	packetServerClientSettings.Locale, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetServerClientSettings.ViewDistance, err = packet.ReadUint8(reader)
	if err != nil {
		return
	}
	packetServerClientSettings.ChatFlags, err = packet.ReadUint8(reader)
	if err != nil {
		return
	}
	packetServerClientSettings.ChatColours, err = packet.ReadBool(reader)
	if err != nil {
		return
	}
	packetServerClientSettings.SkinParts, err = packet.ReadUint8(reader)
	if err != nil {
		return
	}
	decode = packetServerClientSettings
	return
}
예제 #21
0
func (this *ResultGetPlayersCodec) Decode(reader io.Reader, util []byte) (result Result, err error) {
	resultGetPlayers := &ResultGetPlayers{}
	resultGetPlayers.List, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	resultGetPlayers.CurrentPlayers, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	resultGetPlayers.MaximumPlayers, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	if resultGetPlayers.List {
		resultGetPlayers.Players = make([]string, resultGetPlayers.CurrentPlayers)
		var i uint16
		for i = 0; i < resultGetPlayers.CurrentPlayers; i++ {
			if err != nil {
				return
			}
			resultGetPlayers.Players[i], err = packet.ReadString(reader, util)
		}
	}
	return resultGetPlayers, nil
}
func (this *packetServerPluginMessageCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerPluginMessage := new(PacketServerPluginMessage)
	packetServerPluginMessage.Channel, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	dataLength, err := packet.ReadVarInt(reader, util)
	if err != nil {
		return
	}
	if dataLength < 0 {
		err = errors.New(fmt.Sprintf("Decode, Data length is below zero: %d", dataLength))
		return
	}
	if dataLength > 65535 {
		err = errors.New(fmt.Sprintf("Decode, Data length is above maximum: %d", dataLength))
		return
	}
	packetServerPluginMessage.Data = make([]byte, dataLength)
	_, err = reader.Read(packetServerPluginMessage.Data)
	if err != nil {
		return
	}
	decode = packetServerPluginMessage
	return
}
예제 #23
0
func (this *resultGetPlayersCodec) Decode(reader io.Reader) (result Result, err error) {
	resultGetPlayers := new(ResultGetPlayers)
	resultGetPlayers.List, err = packet.ReadBool(reader)
	if err != nil {
		return
	}
	resultGetPlayers.CurrentPlayers, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	resultGetPlayers.MaxPlayers, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	if resultGetPlayers.List {
		resultGetPlayers.Players = make([]string, resultGetPlayers.CurrentPlayers)
		var i uint16
		for i = 0; i < resultGetPlayers.CurrentPlayers; i++ {
			if err != nil {
				return
			}
			resultGetPlayers.Players[i], err = packet.ReadString(reader)
		}
	}
	result = resultGetPlayers
	return
}
func (this *packetClientJoinGameCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientJoinGame := new(PacketClientJoinGame)
	packetClientJoinGame.EntityId, err = packet.ReadInt32(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Gamemode, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Dimension, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Difficulty, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.MaxPlayers, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.LevelType, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.ReducedDebugInfo, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	decode = packetClientJoinGame
	return
}
func (this *packetClientTeamsCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientTeams := new(PacketClientTeams)
	packetClientTeams.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientTeams.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 2 {
		packetClientTeams.DisplayName, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Prefix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Suffix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.FriendlyFire, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 3 || packetClientTeams.Action == 4 {
		var playersLength uint16
		playersLength, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Players = make([]string, playersLength)
		var i uint16
		for i = 0; i < playersLength; i++ {
			packetClientTeams.Players[i], err = packet.ReadString(reader, util)
			if err != nil {
				return
			}
		}
	}
	decode = packetClientTeams
	return
}
예제 #26
0
func (this *ResultAsServerCodec) Decode(reader io.Reader, util []byte) (result Result, err error) {
	resultAsServer := &ResultAsServer{}
	resultAsServer.SecurityKey, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return resultAsServer, nil
}
예제 #27
0
func (this *ResultGetSaltCodec) Decode(reader io.Reader, util []byte) (result Result, err error) {
	resultGetSalt := &ResultGetSalt{}
	resultGetSalt.Salt, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return resultGetSalt, nil
}
func (this *packetClientScoreboardObjectiveCodec17) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := new(PacketClientScoreboardObjective)
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Value, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader)
	if err != nil {
		return
	}
	decode = packetClientScoreboardObjective
	return
}
예제 #29
0
func (this *PacketClientDisconnectCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientDisconnect := &PacketClientDisconnect{}
	packetClientDisconnect.Json, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientDisconnect, nil
}
예제 #30
0
func (this *PacketClientStatusResponseCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientStatusResponse := &PacketClientStatusResponse{}
	packetClientStatusResponse.Json, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientStatusResponse, nil
}