Add BConfig

This commit is contained in:
JaTiTV 2022-01-05 21:50:03 +01:00
parent c171a1674d
commit da2e9ff6a4
6 changed files with 90 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<component name="ArtifactManager">
<artifact type="jar" name="T2CodeLib_9.0">
<artifact type="jar" name="T2CodeLib_10.0">
<output-path>$PROJECT_DIR$/../../Plugins/T2CodeLib/.jar</output-path>
<root id="archive" name="T2CodeLib_9.0.jar">
<root id="archive" name="T2CodeLib_10.0.jar">
<element id="module-output" name="T2CodeLib" />
</root>
</artifact>

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>9.0</version>
<version>10.0</version>
<packaging>jar</packaging>
<name>T2CodeLib</name>

View File

@ -0,0 +1,85 @@
package net.t2code.lib.Bungee.Lib.yamlConfiguration;
import net.md_5.bungee.config.Configuration;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import java.util.ArrayList;
import java.util.List;
public class BConfig {
public static void set(String path, String value, Configuration configuration) {
if (!configuration.contains(path)) {
configuration.set(path, value);
}
}
public static void set(String path, Configuration configuration) {
configuration.set(path, null);
}
public static void set(String path, Integer value, Configuration configuration) {
if (!configuration.contains(path)) {
configuration.set(path, value);
}
}
public static void set(String path, Double value, Configuration configuration) {
if (!configuration.contains(path)) {
configuration.set(path, value);
}
}
public static void set(String path, Boolean value, Configuration configuration) {
if (!configuration.contains(path)) {
configuration.set(path, value);
}
}
public static void set(String path, List<String> value, Configuration configuration) {
if (!configuration.contains(path)) {
configuration.set(path, value);
}
}
public static String select(String prefix, String path, Configuration configuration) {
return Replace.replace(prefix, configuration.getString(path));
}
public static Integer selectInt(String path, Configuration configuration) {
return (configuration.getInt(path));
}
public static Boolean selectBoolean(String path, Configuration configuration) {
return (configuration.getBoolean(path));
}
public static Double selectDouble(String path, Configuration configuration) {
return (configuration.getDouble(path));
}
public static List<String> selectList(String path, Configuration configuration) {
return (configuration.getStringList(path));
}
public static List<String> selectList(String prefix, String path, Configuration configuration) {
List<String> output = new ArrayList<>();
List<String> input = configuration.getStringList(path);
for (String st : input) {
output.add(Replace.replace(prefix, st));
}
return output;
}
public static void select(String prefix, List<String> value, String path, Configuration configuration) {
List<String> output = new ArrayList<>();
List<String> input = configuration.getStringList(path);
for (String st : input) {
output.add(Replace.replace(prefix, st));
}
value = output;
}
}

View File

@ -1,5 +1,5 @@
name: T2CodeLib
version: 9.0
version: 10.0
main: net.t2code.lib.Bungee.BMain
author: JaTiTV, Jkobs
description: Libarie from T2Code Plugins

View File

@ -1,5 +1,5 @@
name: T2CodeLib
version: 9.0
version: 10.0
main: net.t2code.lib.Spigot.system.Main
api-version: 1.13
prefix: T2CodeLib