001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package net.tridentsdk.server.packets.login;
019
020import io.netty.buffer.ByteBuf;
021import net.tridentsdk.server.netty.ClientConnection;
022import net.tridentsdk.server.netty.Codec;
023import net.tridentsdk.server.netty.packet.OutPacket;
024import net.tridentsdk.server.netty.packet.PacketDirection;
025
026/**
027 * Indicates a successful login
028 *
029 * @author The TridentSDK Team
030 */
031public class PacketLoginOutSuccess extends OutPacket {
032    /**
033     * UUID of the client, represented as a String and contains dashes
034     */
035    protected String uuid;
036    /**
037     * Username of the client
038     */
039    protected String username;
040    /**
041     * Connection of the client, currently not used
042     */
043    protected ClientConnection connection;
044
045    @Override
046    public int id() {
047        return 0x02;
048    }
049
050    @Override
051    public PacketDirection direction() {
052        return PacketDirection.OUT;
053    }
054
055    public ClientConnection connection() {
056        return this.connection;
057    }
058
059    public String uniqueId() {
060        return this.uuid;
061    }
062
063    public String username() {
064        return this.username;
065    }
066
067    @Override
068    public void encode(ByteBuf buf) {
069        Codec.writeString(buf, this.uuid);
070        Codec.writeString(buf, this.username);
071    }
072}