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