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.netty.packet;
019
020import io.netty.buffer.ByteBuf;
021import net.tridentsdk.util.TridentLogger;
022
023/**
024 * Provides the basis for a packet that is being received by the server
025 *
026 * @author The TridentSDK Team
027 */
028public abstract class InPacket implements Packet {
029
030    /**
031     * {@inheritDoc}
032     *
033     * <p>Packets coming into the server cannot be encoded, as that is not practical under any circumstances</p>
034     */
035    @Override
036    public void encode(ByteBuf buf) {
037        TridentLogger.get().error(new UnsupportedOperationException(this.getClass().getName() + " cannot be encoded!"));
038    }
039
040    @Override
041    public PacketDirection direction() {
042        return PacketDirection.IN;
043    }
044}