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