Skip to content

Instantly share code, notes, and snippets.

@kinggoesgaming
Last active April 29, 2016 20:33
Show Gist options
  • Save kinggoesgaming/1bb2fe0e8e7f01502f6ba097aaa3c4ce to your computer and use it in GitHub Desktop.
Save kinggoesgaming/1bb2fe0e8e7f01502f6ba097aaa3c4ce to your computer and use it in GitHub Desktop.
private Map<Object, Map<String, C config>> configsMap = new HashMap<>();
public void register(@Nonnull Object plugin, @Nonnull String key, @Nonnull C config) {
getPluginManager().fromInstance(checkNotNull(plugin, nullTemplate, "plugin")).ifPresent(container -> {
final String id = container.getId();
Map<String, C> tempMap;
if (configsMap.containsKey(id)) {
tempMap = configsMap.get(id);
} else {
tempMap = new HashMap<>();
}
if (!tempMap.containsKey(checkNotNull(key, nullTemplate, "key"))) {
tempMap.put(key, checkNotNull(config, nullTemplate, "config"));
configsMap.put(plugin, tempMap);
} else {
getFoundationsCore().getLogger().info(format(getSysMessages().get().getNode("configurations", "keyAlreadyRegistered").getString(), key));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment