Added getConfigMap() method
This commit is contained in:
parent
f875985aa9
commit
7fd422136b
4 changed files with 17 additions and 2 deletions
|
@ -12,7 +12,6 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
|
|
|
@ -10,12 +10,14 @@ import lombok.Getter;
|
|||
import lombok.NonNull;
|
||||
import lombok.experimental.var;
|
||||
import lombok.val;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Configuration is based on class name
|
||||
|
@ -222,6 +224,19 @@ public abstract class Component<TP extends JavaPlugin> {
|
|||
return listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of configs that are under the given key.
|
||||
* @param key The key to use
|
||||
* @return A map containing configs
|
||||
*/
|
||||
protected Map<String, IHaveConfig> getConfigMap(String key) {
|
||||
val c=getConfig().getConfig();
|
||||
var cs=c.getConfigurationSection(key);
|
||||
if(cs==null) cs=c.createSection(key);
|
||||
return cs.getValues(false).entrySet().stream().filter(e->e.getValue() instanceof ConfigurationSection)
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, kv -> new IHaveConfig((ConfigurationSection) kv.getValue())));
|
||||
}
|
||||
|
||||
private String getClassName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.21" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.21" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
|
|
Loading…
Reference in a new issue