MCPcopy Create free account
hub / github.com/Teneted/Tenet / SimplePluginManager

Class SimplePluginManager

src/main/java/org/bukkit/plugin/SimplePluginManager.java:46–874  ·  view source on GitHub ↗

Handles all plugin management from the Server

Source from the content-addressed store, hash-verified

44 * Handles all plugin management from the Server
45 */
46public final class SimplePluginManager implements PluginManager {
47 private final Server server;
48 private final Map<Pattern, PluginLoader> fileAssociations = new HashMap<Pattern, PluginLoader>();
49 private final List<Plugin> plugins = new ArrayList<Plugin>();
50 private final Map<String, Plugin> lookupNames = new HashMap<String, Plugin>();
51 private MutableGraph<String> dependencyGraph = GraphBuilder.directed().build();
52 private File updateDirectory;
53 private final SimpleCommandMap commandMap;
54 private final Map<String, Permission> permissions = new HashMap<String, Permission>();
55 private final Map<Boolean, Set<Permission>> defaultPerms = new LinkedHashMap<Boolean, Set<Permission>>();
56 private final Map<String, Map<Permissible, Boolean>> permSubs = new HashMap<String, Map<Permissible, Boolean>>();
57 private final Map<Boolean, Map<Permissible, Boolean>> defSubs = new HashMap<Boolean, Map<Permissible, Boolean>>();
58 private boolean useTimings = false;
59
60 public SimplePluginManager(@NotNull Server instance, @NotNull SimpleCommandMap commandMap) {
61 server = instance;
62 this.commandMap = commandMap;
63
64 defaultPerms.put(true, new LinkedHashSet<Permission>());
65 defaultPerms.put(false, new LinkedHashSet<Permission>());
66 }
67
68 /**
69 * Registers the specified plugin loader
70 *
71 * @param loader Class name of the PluginLoader to register
72 * @throws IllegalArgumentException Thrown when the given Class is not a
73 * valid PluginLoader
74 */
75 @Override
76 public void registerInterface(@NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentException {
77 PluginLoader instance;
78
79 if (PluginLoader.class.isAssignableFrom(loader)) {
80 Constructor<? extends PluginLoader> constructor;
81
82 try {
83 constructor = loader.getConstructor(Server.class);
84 instance = constructor.newInstance(server);
85 } catch (NoSuchMethodException ex) {
86 String className = loader.getName();
87
88 throw new IllegalArgumentException(String.format("Class %s does not have a public %s(Server) constructor", className, className), ex);
89 } catch (Exception ex) {
90 throw new IllegalArgumentException(String.format("Unexpected exception %s while attempting to construct a new instance of %s", ex.getClass().getName(), loader.getName()), ex);
91 }
92 } else {
93 throw new IllegalArgumentException(String.format("Class %s does not implement interface PluginLoader", loader.getName()));
94 }
95
96 Pattern[] patterns = instance.getPluginFileFilters();
97
98 synchronized (this) {
99 for (Pattern pattern : patterns) {
100 fileAssociations.put(pattern, instance);
101 }
102 }
103 }

Callers

nothing calls this directly

Calls 1

buildMethod · 0.65

Tested by

no test coverage detected