PluginsConfigSection no longer requires Plan as variable

This commit is contained in:
Rsl1122 2017-12-12 13:39:03 +02:00
parent 706b8f1c8d
commit 1821217530
2 changed files with 7 additions and 15 deletions

View File

@ -18,7 +18,7 @@ import java.util.List;
public class HookHandler { public class HookHandler {
private final List<PluginData> additionalDataSources; private final List<PluginData> additionalDataSources;
private final PluginConfigSectionHandler configHandler; private final PluginsConfigSection configHandler;
/** /**
* Class constructor, hooks to plugins. * Class constructor, hooks to plugins.
@ -27,7 +27,7 @@ public class HookHandler {
*/ */
public HookHandler(Plan plugin) { public HookHandler(Plan plugin) {
additionalDataSources = new ArrayList<>(); additionalDataSources = new ArrayList<>();
configHandler = new PluginConfigSectionHandler(plugin); configHandler = new PluginsConfigSection();
try { try {
Bridge.hook(this); Bridge.hook(this);
} catch (Exception e) { } catch (Exception e) {

View File

@ -2,7 +2,7 @@ package main.java.com.djrapitops.plan.data.plugin;
import com.djrapitops.plugin.api.config.ConfigNode; import com.djrapitops.plugin.api.config.ConfigNode;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.systems.store.config.ConfigSystem;
import java.io.IOException; import java.io.IOException;
@ -13,25 +13,17 @@ import java.io.IOException;
* @author Rsl1122 * @author Rsl1122
* @since 3.5.0 * @since 3.5.0
*/ */
public class PluginConfigSectionHandler { public class PluginsConfigSection {
private final Plan plan;
public PluginConfigSectionHandler(Plan plan) {
this.plan = plan;
}
public boolean hasSection(PluginData dataSource) { public boolean hasSection(PluginData dataSource) {
ConfigNode section = getPluginsSection(); ConfigNode section = getPluginsSection();
String pluginName = dataSource.getSourcePlugin(); String pluginName = dataSource.getSourcePlugin();
if (!section.getChildren().containsKey(pluginName)) { return section.getChildren().containsKey(pluginName)
return false; && section.getConfigNode(pluginName).getChildren().containsKey("Enabled");
}
return section.getConfigNode(pluginName).getChildren().containsKey("Enabled");
} }
private ConfigNode getPluginsSection() { private ConfigNode getPluginsSection() {
return plan.getMainConfig().getConfigNode("Plugins"); return ConfigSystem.getInstance().getConfig().getConfigNode("Plugins");
} }
public void createSection(PluginData dataSource) { public void createSection(PluginData dataSource) {