mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-28 18:45:10 +01:00
Let there be light
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package at.helpch.placeholderapi.configuration;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIBootstrap;
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import com.google.gson.FieldNamingPolicy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -11,7 +11,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -63,6 +62,11 @@ public final class ConfigManager {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T convertExpansion(@NotNull final Map<String, Object> expansionConfig, @NotNull final Class<T> type) {
|
||||
return GSON.fromJson(GSON.toJsonTree(expansionConfig), type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Path createFile(@NotNull final String internalPath, @NotNull final String externalPath) {
|
||||
final Path file = Paths.get(externalPath);
|
||||
@@ -94,7 +98,7 @@ public final class ConfigManager {
|
||||
|
||||
private boolean exportResource(@NotNull final String internalPath, @NotNull final String externalPath) {
|
||||
try {
|
||||
Files.copy(PlaceholderAPIBootstrap.class.getResourceAsStream(internalPath), Paths.get(externalPath),
|
||||
Files.copy(PlaceholderAPIPlugin.class.getResourceAsStream(internalPath), Paths.get(externalPath),
|
||||
StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -22,8 +22,88 @@ package at.helpch.placeholderapi.configuration;
|
||||
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record PlaceholderAPIConfig(boolean cloudEnabled, boolean debugMode, @NotNull ExpansionSort cloudSorting,
|
||||
@NotNull BooleanValue booleanValue, @NotNull String dateFormat) {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class PlaceholderAPIConfig {
|
||||
private boolean cloudEnabled;
|
||||
private boolean debugMode;
|
||||
private ExpansionSort cloudSorting;
|
||||
private BooleanValue booleanValue;
|
||||
private String dateFormat;
|
||||
private Map<String, Object> expansions;
|
||||
|
||||
public PlaceholderAPIConfig(boolean cloudEnabled, boolean debugMode, @NotNull ExpansionSort cloudSorting,
|
||||
@NotNull BooleanValue booleanValue, @NotNull String dateFormat) {
|
||||
this.cloudEnabled = cloudEnabled;
|
||||
this.debugMode = debugMode;
|
||||
this.cloudSorting = cloudSorting;
|
||||
this.booleanValue = booleanValue;
|
||||
this.dateFormat = dateFormat;
|
||||
this.expansions = new HashMap<>();
|
||||
}
|
||||
|
||||
public PlaceholderAPIConfig(boolean cloudEnabled, boolean debugMode, @NotNull ExpansionSort cloudSorting,
|
||||
@NotNull BooleanValue booleanValue, @NotNull String dateFormat, Map<String, Object> expansions) {
|
||||
this.cloudEnabled = cloudEnabled;
|
||||
this.debugMode = debugMode;
|
||||
this.cloudSorting = cloudSorting;
|
||||
this.booleanValue = booleanValue;
|
||||
this.dateFormat = dateFormat;
|
||||
this.expansions = expansions;
|
||||
}
|
||||
|
||||
public boolean cloudEnabled() {
|
||||
return cloudEnabled;
|
||||
}
|
||||
|
||||
public void cloudEnabled(final boolean value) {
|
||||
cloudEnabled = value;
|
||||
}
|
||||
|
||||
public boolean debugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
|
||||
public void debugMode(final boolean value) {
|
||||
debugMode = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExpansionSort cloudSorting() {
|
||||
return cloudSorting;
|
||||
}
|
||||
|
||||
public void cloudSorting(@NotNull final ExpansionSort value) {
|
||||
cloudSorting = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BooleanValue booleanValue() {
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
public void booleanValue(@NotNull final BooleanValue value) {
|
||||
booleanValue = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String dateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void dateFormat(@NotNull final String value) {
|
||||
dateFormat = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, Object> expansions() {
|
||||
return expansions;
|
||||
}
|
||||
|
||||
public void expansions(@NotNull final Map<String, Object> value) {
|
||||
expansions = value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user