001package com.fs.starfarer.api.campaign; 002 003import java.util.List; 004 005public interface GenericPluginManagerAPI { 006 007 /** 008 * Lowest priority. Should only be used by core code, a modded plugin with this priority may not end up being used 009 * anywhere, as what gets picked when multiple plugins have the same priority is undefined. 010 */ 011 public static int CORE_GENERAL = 0; 012 013 /** 014 * Should be used by mods for wholesale replacement of campaign features. 015 */ 016 public static int MOD_GENERAL = 100; 017 018 /** 019 * Should only be used by core code. 020 */ 021 public static int CORE_SUBSET = 200; 022 023 /** 024 * For a plugin that handles a set of circumstances. For example "interaction with all jungle worlds". 025 * Overrides any _GENERAL prioritiy implementations (i.e. "interaction with all planets"). 026 * Is overriden by _SPECIFIC priority ("interaction with this particular planet"). 027 */ 028 public static int MOD_SUBSET = 300; 029 030 /** 031 * Should be used by core code only for specific encounters. For example, a "special" planet or fleet 032 * could have their own dialog, and the priority of this would override a mod that replaces the general interactions 033 * with all planets or fleets. 034 */ 035 public static int CORE_SPECIFIC = 400; 036 037 /** 038 * Should be used by mods for specific encounters, that is, encounters that aren't handled by 039 * any of the _GENERAL and _SET priority plugins. For example, if a specific fleet has a special encounter dialog, it would be 040 * returned using this priority. 041 */ 042 public static int MOD_SPECIFIC = 500; 043 044 /** 045 * Absolute highest priority; shouldn't be used without good reason. 046 * A mod compilation might use this to resolve conflicts introduced by mods it contains. 047 */ 048 public static int HIGHEST = Integer.MAX_VALUE; 049 050 051 052 053 public static interface GenericPlugin { 054 /** 055 * Negative priority means plugin doesn't want to handle whatever the parameters indicate the 056 * action is. 057 * @param params 058 * @return 059 */ 060 int getHandlingPriority(Object params); 061 } 062 063 boolean hasPlugin(Class c); 064 void addPlugin(GenericPlugin plugin); 065 void addPlugin(GenericPlugin plugin, boolean isTransient); 066 void removePlugin(GenericPlugin plugin); 067 List<GenericPlugin> getPluginsOfClass(Class c); 068 <T>T pickPlugin(Class<T> c, Object params); 069}