001    /*
002     * The FML Forge Mod Loader suite.
003     * Copyright (C) 2012 cpw
004     *
005     * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or any later version.
007     *
008     * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
009     * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
010     *
011     * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
012     * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
013     */
014    package cpw.mods.fml.common;
015    
016    import java.lang.annotation.ElementType;
017    import java.lang.annotation.Retention;
018    import java.lang.annotation.RetentionPolicy;
019    import java.lang.annotation.Target;
020    
021    import cpw.mods.fml.common.event.FMLInterModComms;
022    import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
023    
024    import net.minecraft.src.ItemBlock;
025    
026    /**
027     * The new mod style in FML 1.3
028     *
029     * @author cpw
030     *
031     */
032    @Retention(RetentionPolicy.RUNTIME)
033    @Target(ElementType.TYPE)
034    public @interface Mod
035    {
036        /**
037         * The unique mod identifier for this mod
038         */
039        String modid();
040        /**
041         * A user friendly name for the mod
042         */
043        String name() default "";
044        /**
045         * A version string for this mod
046         */
047        String version() default "";
048        /**
049         * A simple dependency string for this mod (see modloader's "priorities" string specification)
050         */
051        String dependencies() default "";
052        /**
053         * Whether to use the mcmod.info metadata by default for this mod.
054         * If true, settings in the mcmod.info file will override settings in these annotations.
055         */
056        boolean useMetadata() default false;
057    
058        /**
059         * The acceptable range of minecraft versions that this mod will load and run in
060         * The default ("empty string") indicates that only the current minecraft version is acceptable.
061         * FML will refuse to run with an error if the minecraft version is not in this range across all mods.
062         * @return A version range as specified by the maven version range specification or the empty string
063         */
064        String acceptedMinecraftVersions() default "";
065        /**
066         * An optional bukkit plugin that will be injected into the bukkit plugin framework if
067         * this mod is loaded into the FML framework and the bukkit coremod is present.
068         * Instances of the bukkit plugin can be obtained via the {@link BukkitPluginRef} annotation on fields.
069         * @return The name of the plugin to load for this mod
070         */
071        String bukkitPlugin() default "";
072        /**
073         * Mods that this mod will <strong>not</strong> load with.
074         * An optional comma separated string of modid[@value], or the value - which specify mods that
075         * this mod will refuse to load with, resulting in the game failing to start. The special value - is
076         * interpreted as meaning <strong>all</strong> mods, except FML and MCP. The special value -f is
077         * interpreted as meaning <strong>all</strong> mods except FML, MCP and MinecraftForge.
078         *
079         * If a mod is present on the excluded list, the game will stop and show an error screen. If the
080         * class containing the {@link Mod} annotation has a "getCustomErrorException" method, it will be
081         * called to retrieve a custom error message for display in this case. If two mods have a declared
082         * exclusion which screen is shown is indeterminate.
083         *
084         * @return A string listing modids to exclude from loading with this mod.
085         */
086        String modExclusionList() default "";
087        /**
088         * Mark the designated method as being called at the "pre-initialization" phase
089         * @author cpw
090         *
091         */
092        @Retention(RetentionPolicy.RUNTIME)
093        @Target(ElementType.METHOD)
094        public @interface PreInit {}
095        /**
096         * Mark the designated method as being called at the "initialization" phase
097         * @author cpw
098         *
099         */
100        @Retention(RetentionPolicy.RUNTIME)
101        @Target(ElementType.METHOD)
102        public @interface Init {}
103        /**
104         * Mark the designated method as being called at the "post-initialization" phase
105         * @author cpw
106         *
107         */
108        @Retention(RetentionPolicy.RUNTIME)
109        @Target(ElementType.METHOD)
110        public @interface PostInit {}
111        /**
112         * Mark the designated method as being called at the "server-starting" phase
113         * @author cpw
114         *
115         */
116        @Retention(RetentionPolicy.RUNTIME)
117        @Target(ElementType.METHOD)
118        public @interface ServerStarting {}
119        /**
120         * Mark the designated method as being called at the "server-started" phase
121         * @author cpw
122         *
123         */
124        @Retention(RetentionPolicy.RUNTIME)
125        @Target(ElementType.METHOD)
126        public @interface ServerStarted {}
127        /**
128         * Mark the designated method as being called at the "server-stopping" phase
129         * @author cpw
130         *
131         */
132        @Retention(RetentionPolicy.RUNTIME)
133        @Target(ElementType.METHOD)
134        public @interface ServerStopping {}
135        /**
136         * Mark the designated method as the receiver for {@link FMLInterModComms} messages
137         * Called between {@link Init} and {@link PostInit}
138         * @author cpw
139         *
140         */
141        @Retention(RetentionPolicy.RUNTIME)
142        @Target(ElementType.METHOD)
143        public @interface IMCCallback {}
144        /**
145         * Populate the annotated field with the mod instance.
146         * @author cpw
147         *
148         */
149        @Retention(RetentionPolicy.RUNTIME)
150        @Target(ElementType.FIELD)
151        public @interface Instance {
152            /**
153             * The mod object to inject into this field
154             */
155            String value() default "";
156        }
157        /**
158         * Populate the annotated field with the mod's metadata.
159         * @author cpw
160         *
161         */
162        @Retention(RetentionPolicy.RUNTIME)
163        @Target(ElementType.FIELD)
164        public @interface Metadata {
165            /**
166             * The mod id specifying the metadata to load here
167             */
168            String value() default "";
169        }
170        /**
171         * Populate the annotated field with an instance of the Block as specified
172         * @author cpw
173         *
174         */
175        @Retention(RetentionPolicy.RUNTIME)
176        @Target(ElementType.FIELD)
177        public @interface Block {
178            /**
179             * The block's name
180             */
181            String name();
182            /**
183             * The associated ItemBlock subtype for the item (can be null for an ItemBlock)
184             */
185            Class<?> itemTypeClass() default ItemBlock.class;
186        }
187        /**
188         * Populate the annotated field with an Item
189         * @author cpw
190         *
191         */
192        @Retention(RetentionPolicy.RUNTIME)
193        @Target(ElementType.FIELD)
194        public @interface Item {
195            /**
196             * The name of the item
197             */
198            String name();
199            /**
200             * The type of the item
201             */
202            String typeClass();
203        }
204    }