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