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