001/*
002 * Forge Mod Loader
003 * Copyright (c) 2012-2013 cpw.
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser Public License v2.1
006 * which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
008 * 
009 * Contributors:
010 *     cpw - implementation
011 */
012
013package cpw.mods.fml.common.network;
014
015import java.lang.annotation.ElementType;
016import java.lang.annotation.Retention;
017import java.lang.annotation.RetentionPolicy;
018import java.lang.annotation.Target;
019
020@Retention(RetentionPolicy.RUNTIME)
021@Target(ElementType.TYPE)
022public @interface NetworkMod
023{
024    /**
025     * Does this mod require the client side to be present when installed on a server?
026     */
027    boolean clientSideRequired() default false;
028    /**
029     * Does this mod require the server side to be present when installed on a client?
030     */
031    boolean serverSideRequired() default false;
032    /**
033     * A list of Packet250 network channels to register for this mod - these channels
034     * will be universal and will require a universal packethandler to handle them
035     */
036    String[] channels() default {};
037    /**
038     * An optional range check for client to server communication version compatibility
039     */
040    String versionBounds() default "";
041
042    /**
043     * A packet handler implementation for channels registered through this annotation
044     * - this packet handler will be universal and handle both client and server
045     * requests.
046     */
047    Class<? extends IPacketHandler> packetHandler() default NULL.class;
048
049    /**
050     * A tiny packet handler implementation based on {@link net.minecraft.network.packet.Packet131MapData} for "small"
051     * data packet loads.
052     */
053    Class<? extends ITinyPacketHandler> tinyPacketHandler() default NULL.class;
054    /**
055     * A connection handler implementation for this network mod
056     */
057    Class<? extends IConnectionHandler> connectionHandler() default NULL.class;
058    /**
059     * A packet handler and channels to register for the client side
060     */
061    SidedPacketHandler clientPacketHandlerSpec() default @SidedPacketHandler(channels = {}, packetHandler = NULL.class );
062
063    /**
064     * A packet handler and channels to register for the server side
065     */
066    SidedPacketHandler serverPacketHandlerSpec() default @SidedPacketHandler(channels = {}, packetHandler = NULL.class );
067
068    /**
069     * Special dummy class for handling stupid annotation default values
070     * @author cpw
071     *
072     */
073    static interface NULL extends IPacketHandler, IConnectionHandler, ITinyPacketHandler {};
074
075    /**
076     * A marker for a method that will be offered the client's version string
077     * if more sophisticated version rejection handling is required:
078     * The method should accept a "String", a "NetworkManager" and return a boolean true
079     * if the version can be accepted.
080     * @author cpw
081     *
082     */
083    @Retention(RetentionPolicy.RUNTIME)
084    @Target(ElementType.METHOD)
085    public @interface VersionCheckHandler { }
086
087    /**
088     * Bundles together a packet handler and it's associated channels for the sided packet handlers
089     * @author cpw
090     *
091     */
092    public @interface SidedPacketHandler {
093        String[] channels();
094        Class<? extends IPacketHandler> packetHandler();
095    }
096
097}