forked from openrs2/openrs2
parent
f31b2519f9
commit
fa41b48f1a
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class CannotCreateAtThisTimeCodec : EmptyPacketCodec<CreateResponse.CannotCreateAtThisTime>( |
||||
packet = CreateResponse.CannotCreateAtThisTime, |
||||
opcode = 38 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class CountryInvalidCodec : EmptyPacketCodec<CreateResponse.CountryInvalid>( |
||||
packet = CreateResponse.CountryInvalid, |
||||
opcode = 14 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class CreateClientOutOfDateCodec : EmptyPacketCodec<CreateResponse.ClientOutOfDate>( |
||||
packet = CreateResponse.ClientOutOfDate, |
||||
opcode = 37 |
||||
) |
@ -0,0 +1,8 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import javax.inject.Qualifier |
||||
|
||||
@Qualifier |
||||
@Retention(AnnotationRetention.RUNTIME) |
||||
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) |
||||
public annotation class CreateDownstream |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class CreateIpLimitCodec : EmptyPacketCodec<CreateResponse.IpLimit>( |
||||
packet = CreateResponse.IpLimit, |
||||
opcode = 9 |
||||
) |
@ -0,0 +1,8 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
|
||||
public class CreateOkCodec : EmptyPacketCodec<CreateResponse.Ok>( |
||||
packet = CreateResponse.Ok, |
||||
opcode = 2 |
||||
) |
@ -0,0 +1,30 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.Packet |
||||
|
||||
public sealed class CreateResponse : Packet { |
||||
public object Ok : CreateResponse() |
||||
public object CreateServerOffline : CreateResponse() |
||||
public object ServerFull : CreateResponse() |
||||
public object IpLimit : CreateResponse() |
||||
public object DateOfBirthInvalid : CreateResponse() |
||||
public object DateOfBirthFuture : CreateResponse() |
||||
public object DateOfBirthThisYear : CreateResponse() |
||||
public object DateOfBirthLastYear : CreateResponse() |
||||
public object CountryInvalid : CreateResponse() |
||||
public object NameUnavailable : CreateResponse() |
||||
public data class NameSuggestions(val names: List<String>) : CreateResponse() |
||||
public object NameInvalid : CreateResponse() |
||||
public object PasswordInvalidLength : CreateResponse() |
||||
public object PasswordInvalidChars : CreateResponse() |
||||
public object PasswordGuessable : CreateResponse() |
||||
public object PasswordGuessable1 : CreateResponse() |
||||
public object PasswordSimilarToName : CreateResponse() |
||||
public object PasswordSimilarToName1 : CreateResponse() |
||||
public object PasswordSimilarToName2 : CreateResponse() |
||||
public object ClientOutOfDate : CreateResponse() |
||||
public object CannotCreateAtThisTime : CreateResponse() |
||||
public object EmailInvalid : CreateResponse() |
||||
public object EmailInvalid1 : CreateResponse() |
||||
public object EmailInvalid2 : CreateResponse() |
||||
} |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class CreateServerFullCodec : EmptyPacketCodec<CreateResponse.ServerFull>( |
||||
packet = CreateResponse.ServerFull, |
||||
opcode = 7 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class CreateServerOfflineCodec : EmptyPacketCodec<CreateResponse.CreateServerOffline>( |
||||
packet = CreateResponse.CreateServerOffline, |
||||
opcode = 3 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class DateOfBirthFutureCodec : EmptyPacketCodec<CreateResponse.DateOfBirthFuture>( |
||||
packet = CreateResponse.DateOfBirthFuture, |
||||
opcode = 11 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class DateOfBirthInvalidCodec : EmptyPacketCodec<CreateResponse.DateOfBirthInvalid>( |
||||
packet = CreateResponse.DateOfBirthInvalid, |
||||
opcode = 10 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class DateOfBirthLastYearCodec : EmptyPacketCodec<CreateResponse.DateOfBirthLastYear>( |
||||
packet = CreateResponse.DateOfBirthLastYear, |
||||
opcode = 13 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class DateOfBirthThisYearCodec : EmptyPacketCodec<CreateResponse.DateOfBirthThisYear>( |
||||
packet = CreateResponse.DateOfBirthThisYear, |
||||
opcode = 12 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class EmailInvalid1Codec : EmptyPacketCodec<CreateResponse.EmailInvalid1>( |
||||
packet = CreateResponse.EmailInvalid1, |
||||
opcode = 42 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class EmailInvalid2Codec : EmptyPacketCodec<CreateResponse.EmailInvalid2>( |
||||
packet = CreateResponse.EmailInvalid2, |
||||
opcode = 43 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class EmailInvalidCodec : EmptyPacketCodec<CreateResponse.EmailInvalid>( |
||||
packet = CreateResponse.EmailInvalid, |
||||
opcode = 41 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class NameInvalidCodec : EmptyPacketCodec<CreateResponse.NameInvalid>( |
||||
packet = CreateResponse.NameInvalid, |
||||
opcode = 22 |
||||
) |
@ -0,0 +1,45 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import io.netty.buffer.ByteBuf |
||||
import org.openrs2.crypto.StreamCipher |
||||
import org.openrs2.protocol.PacketCodec |
||||
import org.openrs2.util.Base37 |
||||
|
||||
public class NameSuggestionsCodec : PacketCodec<CreateResponse.NameSuggestions>( |
||||
type = CreateResponse.NameSuggestions::class.java, |
||||
opcode = 21 |
||||
) { |
||||
override fun decode(input: ByteBuf, cipher: StreamCipher): CreateResponse.NameSuggestions { |
||||
val names = mutableListOf<String>() |
||||
while (input.readableBytes() >= 8) { |
||||
names += Base37.decodeLowerCase(input.readLong()) |
||||
} |
||||
return CreateResponse.NameSuggestions(names) |
||||
} |
||||
|
||||
override fun encode(input: CreateResponse.NameSuggestions, output: ByteBuf, cipher: StreamCipher) { |
||||
for (name in input.names) { |
||||
output.writeLong(Base37.encode(name)) |
||||
} |
||||
} |
||||
|
||||
override fun isLengthReadable(input: ByteBuf): Boolean { |
||||
return input.isReadable |
||||
} |
||||
|
||||
override fun readLength(input: ByteBuf): Int { |
||||
return input.readUnsignedByte().toInt() * 8 |
||||
} |
||||
|
||||
override fun writeLengthPlaceholder(output: ByteBuf) { |
||||
output.writeZero(1) |
||||
} |
||||
|
||||
override fun setLength(output: ByteBuf, index: Int, written: Int) { |
||||
require(written % 8 != 0) { |
||||
"Name suggestions payload length must be a multiple of 8" |
||||
} |
||||
|
||||
output.setByte(index, written / 8) |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class NameUnavailableCodec : EmptyPacketCodec<CreateResponse.NameUnavailable>( |
||||
packet = CreateResponse.NameUnavailable, |
||||
opcode = 20 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordGuessable1Codec : EmptyPacketCodec<CreateResponse.PasswordGuessable1>( |
||||
packet = CreateResponse.PasswordGuessable1, |
||||
opcode = 33 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordGuessableCodec : EmptyPacketCodec<CreateResponse.PasswordGuessable>( |
||||
packet = CreateResponse.PasswordGuessable, |
||||
opcode = 32 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordInvalidCharsCodec : EmptyPacketCodec<CreateResponse.PasswordInvalidChars>( |
||||
packet = CreateResponse.PasswordInvalidChars, |
||||
opcode = 31 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordInvalidLengthCodec : EmptyPacketCodec<CreateResponse.PasswordInvalidLength>( |
||||
packet = CreateResponse.PasswordInvalidLength, |
||||
opcode = 30 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordSimilarToName1Codec : EmptyPacketCodec<CreateResponse.PasswordSimilarToName1>( |
||||
packet = CreateResponse.PasswordSimilarToName1, |
||||
opcode = 35 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordSimilarToName2Codec : EmptyPacketCodec<CreateResponse.PasswordSimilarToName2>( |
||||
packet = CreateResponse.PasswordSimilarToName2, |
||||
opcode = 36 |
||||
) |
@ -0,0 +1,10 @@ |
||||
package org.openrs2.protocol.create.downstream |
||||
|
||||
import org.openrs2.protocol.EmptyPacketCodec |
||||
import javax.inject.Singleton |
||||
|
||||
@Singleton |
||||
public class PasswordSimilarToNameCodec : EmptyPacketCodec<CreateResponse.PasswordSimilarToName>( |
||||
packet = CreateResponse.PasswordSimilarToName, |
||||
opcode = 34 |
||||
) |
Loading…
Reference in new issue