if (config == null) {
return false;
}
// Look if the plugin is already installed
PluginID defaultPluginId = config.getCsConfig().getPluginConfig().getId();
List<WGAPlugin> installedPlugins = currentPlugins.getPluginsByUniqueName(defaultPluginId.getUniqueName());
for (WGAPlugin plugin : installedPlugins) {
// Same plugin file = plugin already installed
if (plugin.getPluginFile().equals(file)) {
return false;
}
// Don't overwrite (active) dev plugin dirs
if (plugin.isDirectory() && plugin.isActive()) {
return false;
}
// Skip reasons that do not apply to dev plugins
if (!file.isDirectory()) {
// Don't overwrite (active) plugins that are of higher version
int versionComparison = plugin.getPluginID().getVersion().compareTo(defaultPluginId.getVersion());
if (versionComparison > 0 && plugin.isActive()) {
return false;
}
// Don't overwrite (active) plugins of same version and same or higher build
if (versionComparison == 0 && plugin.isActive() && plugin.getPluginID().getVersion().getBuildVersion() >= defaultPluginId.getVersion().getBuildVersion()) {
return false;
}
}
}