first commit
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s

This commit is contained in:
asminme committed 2026-10-24 15:18:03 +02:00
commit bbccd4a815
454 files changed
+45050

No files matched your search

@@ -0,0 +1,454 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
public class CommentedProperties
implements Map<String, String> {
private final boolean strict;
private final List<String> headerComments;
private final Map<String, Property> properties;
public CommentedProperties(boolean strict) {
this.strict = strict;
this.headerComments = new ArrayList<String>();
this.properties = new LinkedHashMap<String, Property>();
}
public CommentedProperties() {
this(true);
}
public CommentedProperties addHeaderComment(String comment) {
this.headerComments.add(comment);
return this;
}
public CommentedProperties setHeaderComments(List<String> headerComments) {
this.headerComments.clear();
this.headerComments.addAll(headerComments);
return this;
}
void sort(Comparator<String> comparator) {
ArrayList<Map.Entry<String, Property>> list = new ArrayList<Map.Entry<String, Property>>(this.properties.entrySet());
list.sort((o1, o2) -> comparator.compare((String)o1.getKey(), (String)o2.getKey()));
this.properties.clear();
for (Map.Entry entry : list) {
this.properties.put((String)entry.getKey(), (Property)entry.getValue());
}
}
@Nullable
public String get(String key) {
Objects.requireNonNull(key);
Property property = this.properties.get(key);
if (property == null) {
return null;
}
return property.value;
}
@Nullable
public List<String> getComments(String key) {
Objects.requireNonNull(key);
Property property = this.properties.get(key);
if (property == null) {
return null;
}
return property.comments;
}
public CommentedProperties setComments(String key, List<String> comments) {
Objects.requireNonNull(key);
Property property = this.properties.get(key);
if (property == null) {
this.properties.put(key, new Property(comments, ""));
return this;
}
property.comments = comments;
return this;
}
public CommentedProperties set(String key, String value, String ... comments) {
Objects.requireNonNull(key);
Objects.requireNonNull(value);
this.properties.put(key, new Property(Arrays.asList(comments), value));
return this;
}
public CommentedProperties load(InputStream inputStream) throws IOException {
ArrayList<String> headerComments = new ArrayList<String>();
LinkedHashMap<String, Property> properties = new LinkedHashMap<String, Property>();
try (LineReader reader = LineReader.fromInputStream(inputStream);){
String line;
boolean header = true;
ArrayList<String> previousComments = new ArrayList<String>();
while ((line = reader.nextLine()) != null) {
if (line.trim().isEmpty()) {
if (!header) continue;
headerComments.addAll(previousComments);
previousComments.clear();
header = false;
continue;
}
Pair pair = CommentedProperties.readLine(line);
if (pair.key == null) {
previousComments.add(pair.value);
continue;
}
Property property = new Property(pair.value);
property.comments.addAll(previousComments);
previousComments.clear();
properties.put(pair.key, property);
header = false;
}
}
this.setHeaderComments(headerComments);
this.properties.clear();
this.properties.putAll(properties);
return this;
}
protected static Pair readLine(String line) throws IOException {
int c;
StringBuilder key = new StringBuilder();
StringBuilder value = new StringBuilder();
StringReader reader = new StringReader(line);
boolean isKey = true;
boolean isComment = false;
boolean isPrecedingBackslash = false;
boolean onlyHadWhitespace = true;
boolean isStartOfValue = false;
while ((c = reader.read()) != -1) {
boolean isWhitespace = CommentedProperties.isWhitespace(c);
if (isComment) {
if (onlyHadWhitespace && isWhitespace) continue;
onlyHadWhitespace = false;
value.append((char)c);
continue;
}
if (isPrecedingBackslash) {
if (isKey) {
key.append((char)CommentedProperties.readEscapedCharacter(c, reader));
} else {
value.append((char)CommentedProperties.readEscapedCharacter(c, reader));
}
isPrecedingBackslash = false;
isStartOfValue = false;
continue;
}
if (c == 92) {
isPrecedingBackslash = true;
continue;
}
if ((c == 35 || c == 33) && onlyHadWhitespace) {
isComment = true;
continue;
}
if (isKey) {
if (key.length() <= 0 && CommentedProperties.isWhitespace(c)) continue;
if (CommentedProperties.isSeparator(c)) {
isKey = false;
isStartOfValue = true;
onlyHadWhitespace = false;
continue;
}
if (CommentedProperties.isWhitespace(c)) continue;
key.append((char)c);
} else {
if (isStartOfValue && (CommentedProperties.isWhitespace(c) || CommentedProperties.isSeparator(c))) continue;
value.append((char)c);
isStartOfValue = false;
}
if (!onlyHadWhitespace || isWhitespace) continue;
onlyHadWhitespace = false;
}
return new Pair(isComment ? null : key.toString(), value.toString());
}
private static int readEscapedCharacter(int c, StringReader reader) throws IOException {
if (c == 117) {
int u = 0;
for (int i = 0; i < 4; ++i) {
int uc = reader.read();
if (uc == -1) {
throw new IOException("Invalid unicode escape sequence");
}
u <<= 4;
if (uc >= 48 && uc <= 57) {
u += uc - 48;
continue;
}
if (uc >= 97 && uc <= 102) {
u += uc - 97 + 10;
continue;
}
if (uc >= 65 && uc <= 70) {
u += uc - 65 + 10;
continue;
}
throw new IOException("Invalid unicode escape sequence");
}
return u;
}
if (c == 116) {
return 9;
}
if (c == 114) {
return 13;
}
if (c == 110) {
return 10;
}
if (c == 102) {
return 12;
}
return c;
}
private static boolean isWhitespace(int c) {
return c == 32 || c == 9 || c == 13 || c == 12 || Character.isWhitespace(c);
}
private static boolean isSeparator(int c) {
return c == 61 || c == 58 || c == 32 || c == 9 || c == 12;
}
public CommentedProperties save(OutputStream outputStream) {
try (PrintWriter writer = new PrintWriter(outputStream);){
for (String string : CommentedProperties.removeNewLines(this.headerComments)) {
writer.print("# ");
writer.println(string);
}
if (this.headerComments.size() > 0) {
writer.println();
}
for (Map.Entry entry : this.properties.entrySet()) {
for (String comment : CommentedProperties.removeNewLines(((Property)entry.getValue()).comments)) {
writer.print("# ");
writer.println(comment);
}
writer.print(this.escapeKey((String)entry.getKey()));
writer.print("=");
writer.println(this.escapeValue(((Property)entry.getValue()).value));
}
writer.flush();
}
return this;
}
private static List<String> removeNewLines(List<String> comments) {
ArrayList<String> newComments = new ArrayList<String>();
for (String comment : comments) {
newComments.addAll(Arrays.asList(comment.split("\\r?\\n")));
}
return newComments;
}
private String escapeKey(String str) {
str = this.escape(str);
str = str.replace(" ", "\\ ");
str = str.replace("=", "\\=");
str = str.replace(":", "\\:");
return str;
}
private String escapeValue(String str) {
str = this.escape(str);
if (this.strict) {
str = str.replace("=", "\\=");
str = str.replace(":", "\\:");
}
if (str.startsWith(" ")) {
str = String.format("\\%s", str);
}
return str;
}
private String escape(String str) {
str = str.replace("\\", "\\\\");
str = str.replace("\n", "\\n");
str = str.replace("\r", "\\n");
str = str.replace("\t", "\\t");
str = str.replace("#", "\\#");
str = str.replace("!", "\\!");
for (int i = 0; i < str.length(); ++i) {
char c = str.charAt(i);
if (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.BASIC_LATIN) continue;
str = String.format("%s\\u%04X%s", str.substring(0, i), (int)c, str.substring(i + 1));
}
return str;
}
@Override
public int size() {
return this.properties.size();
}
@Override
public boolean isEmpty() {
return this.properties.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return this.properties.containsKey(key);
}
@Override
@Deprecated
public boolean containsValue(Object value) {
for (Property property : this.properties.values()) {
if (!property.value.equals(value)) continue;
return true;
}
return false;
}
@Override
@Nullable
@Deprecated
public String get(Object key) {
if (!(key instanceof String)) {
return null;
}
return this.get((String)key);
}
@Override
@Deprecated
public String put(String key, String value) {
Objects.requireNonNull(key);
Objects.requireNonNull(value);
Property put = this.properties.put(key, new Property(value));
if (put == null) {
return null;
}
return put.value;
}
@Override
public String remove(Object key) {
Property removed = this.properties.remove(key);
if (removed == null) {
return null;
}
return removed.value;
}
@Override
@Deprecated
public void putAll(Map<? extends String, ? extends String> map) {
for (Map.Entry<? extends String, ? extends String> entry : map.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
}
@Override
public void clear() {
this.headerComments.clear();
this.properties.clear();
}
@Override
public Set<String> keySet() {
return this.properties.keySet();
}
@Override
@Deprecated
public Collection<String> values() {
return this.properties.values().stream().map(property -> ((Property)property).value).collect(Collectors.toList());
}
@Override
@Deprecated
public Set<Map.Entry<String, String>> entrySet() {
return this.properties.entrySet().stream().map(entry -> new AbstractMap.SimpleEntry<String, String>((String)entry.getKey(), ((Property)entry.getValue()).value)).collect(Collectors.toSet());
}
protected static class Property {
private List<String> comments;
private String value;
public Property(List<String> comments, String value) {
this.comments = comments;
this.value = value;
}
public Property(String value) {
this(new ArrayList<String>(), value);
}
}
protected static class LineReader
implements Closeable {
private final BufferedReader reader;
public LineReader(BufferedReader reader) {
this.reader = reader;
}
public static LineReader fromInputStream(InputStream inputStream) {
return new LineReader(new BufferedReader(new InputStreamReader(inputStream)));
}
@Nullable
public String nextLine() throws IOException {
String line = this.reader.readLine();
if (line == null) {
return null;
}
if (line.endsWith("\\")) {
line = line.substring(0, line.length() - 1);
String nextLine = this.nextLine();
if (nextLine == null) {
return line;
}
return line + nextLine;
}
return line;
}
@Override
public void close() throws IOException {
this.reader.close();
}
}
protected static class Pair {
private String key;
private String value;
public Pair(String key, String value) {
this.key = key;
this.value = value;
}
}
}
@@ -0,0 +1,144 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder;
import de.maxhenkel.voicechat.configbuilder.CommentedProperties;
import de.maxhenkel.voicechat.configbuilder.Config;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.FileAttribute;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
public class CommentedPropertyConfig
implements Config {
private static final Logger LOGGER = Logger.getLogger(CommentedPropertyConfig.class.getName());
private static final ExecutorService SAVE_EXECUTOR_SERVICE = Executors.newSingleThreadExecutor(runnable -> {
Thread thread = new Thread(runnable);
thread.setName("ConfigSaver");
thread.setDaemon(true);
return thread;
});
protected CommentedProperties properties;
@Nullable
protected Path path;
protected CommentedPropertyConfig(CommentedProperties properties) {
this.properties = properties;
}
public static Builder builder() {
return new Builder();
}
public String get(String key) {
return this.properties.get(key);
}
public boolean has(String key) {
return this.properties.containsKey(key);
}
public void set(String key, String value, String ... comments) {
this.properties.set(key, value, comments);
}
public CommentedProperties getProperties() {
return this.properties;
}
public void load() throws IOException {
if (this.path == null) {
return;
}
if (Files.exists(this.path, new LinkOption[0])) {
try (InputStream inputStream = Files.newInputStream(this.path, new OpenOption[0]);){
this.properties.load(inputStream);
}
}
}
public void reload() {
this.properties.clear();
try {
this.load();
}
catch (IOException e) {
LOGGER.log(Level.SEVERE, "Failed to reload config", e);
}
}
public synchronized void saveSync() {
if (this.path == null) {
return;
}
try {
Files.createDirectories(this.path.getParent(), new FileAttribute[0]);
}
catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to create parent directories of config", e);
}
try (OutputStream stream = Files.newOutputStream(this.path, StandardOpenOption.CREATE, StandardOpenOption.SYNC, StandardOpenOption.TRUNCATE_EXISTING);){
this.properties.save(stream);
}
catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to save config", e);
}
}
public void save() {
if (this.path == null) {
return;
}
SAVE_EXECUTOR_SERVICE.execute(this::saveSync);
}
@Override
public Map<String, String> getEntries() {
return Collections.unmodifiableMap(this.properties);
}
public static class Builder {
@Nullable
private Path path;
private boolean strict = true;
private Builder() {
}
public Builder path(Path path) {
this.path = path;
return this;
}
public Builder strict(boolean strict) {
this.strict = strict;
return this;
}
public CommentedPropertyConfig build() {
CommentedPropertyConfig config = new CommentedPropertyConfig(new CommentedProperties(this.strict));
if (this.path != null) {
config.path = this.path.toAbsolutePath();
}
config.reload();
return config;
}
}
}
@@ -0,0 +1,11 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder;
import java.util.Map;
public interface Config {
public Map<String, String> getEntries();
}
@@ -0,0 +1,167 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.ConfigBuilderImpl;
import de.maxhenkel.voicechat.configbuilder.MigratableConfig;
import de.maxhenkel.voicechat.configbuilder.MigratableConfigImpl;
import de.maxhenkel.voicechat.configbuilder.entry.BooleanConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.DoubleConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.EnumConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.FloatConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.IntegerConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.LongConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.StringConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface ConfigBuilder {
public ConfigBuilder header(String ... var1);
public BooleanConfigEntry booleanEntry(String var1, Boolean var2, String ... var3);
public IntegerConfigEntry integerEntry(String var1, Integer var2, Integer var3, Integer var4, String ... var5);
default public IntegerConfigEntry integerEntry(String key, Integer def, String ... comments) {
return this.integerEntry(key, def, (Integer)null, (Integer)null, comments);
}
public LongConfigEntry longEntry(String var1, Long var2, Long var3, Long var4, String ... var5);
default public LongConfigEntry longEntry(String key, Long def, String ... comments) {
return this.longEntry(key, def, (Long)null, (Long)null, comments);
}
public DoubleConfigEntry doubleEntry(String var1, Double var2, Double var3, Double var4, String ... var5);
default public DoubleConfigEntry doubleEntry(String key, Double def, String ... comments) {
return this.doubleEntry(key, def, (Double)null, (Double)null, comments);
}
public FloatConfigEntry floatEntry(String var1, Float var2, Float var3, Float var4, String ... var5);
default public FloatConfigEntry floatEntry(String key, Float def, String ... comments) {
return this.floatEntry(key, def, (Float)null, (Float)null, comments);
}
public StringConfigEntry stringEntry(String var1, String var2, String ... var3);
public <E extends Enum<E>> EnumConfigEntry<E> enumEntry(String var1, E var2, String ... var3);
public <T> ConfigEntry<T> entry(String var1, T var2, String ... var3);
public static <C> Builder<C> builder(@Nonnull Function<ConfigBuilder, C> builderConsumer) {
return new Builder(builderConsumer);
}
public static class Builder<C> {
@Nonnull
private final Function<ConfigBuilder, C> builderConsumer;
@Nullable
private Path path;
private final Map<Class<?>, ValueSerializer<?>> valueSerializers;
private boolean removeUnused;
private boolean strict;
private boolean keepOrder;
private boolean saveAfterBuild;
private boolean saveSyncAfterBuild;
@Nullable
private Consumer<MigratableConfig> migration;
private Builder(@Nonnull Function<ConfigBuilder, C> builderConsumer) {
this.builderConsumer = builderConsumer;
this.valueSerializers = new HashMap();
this.removeUnused = true;
this.strict = false;
this.keepOrder = true;
this.saveAfterBuild = true;
this.saveSyncAfterBuild = false;
}
public Builder<C> path(Path path) {
this.path = path;
return this;
}
public <T> Builder<C> addValueSerializer(Class<T> type, ValueSerializer<T> serializer) {
this.valueSerializers.put(type, serializer);
return this;
}
public Builder<C> removeUnused(boolean removeUnused) {
this.removeUnused = removeUnused;
return this;
}
public Builder<C> strict(boolean strict) {
this.strict = strict;
return this;
}
public Builder<C> keepOrder(boolean keepOrder) {
this.keepOrder = keepOrder;
return this;
}
public Builder<C> saveAfterBuild(boolean saveAfterBuild) {
this.saveAfterBuild = saveAfterBuild;
if (saveAfterBuild) {
this.saveSyncAfterBuild = false;
}
return this;
}
public Builder<C> saveSyncAfterBuild(boolean saveSyncAfterBuild) {
this.saveSyncAfterBuild = saveSyncAfterBuild;
if (saveSyncAfterBuild) {
this.saveAfterBuild = false;
}
return this;
}
public Builder<C> migration(Consumer<MigratableConfig> migration) {
this.migration = migration;
return this;
}
public C build() {
CommentedPropertyConfig cpc = CommentedPropertyConfig.builder().path(this.path).strict(this.strict).build();
if (this.migration != null && this.path != null && Files.exists(this.path, new LinkOption[0])) {
MigratableConfigImpl migratableConfig = new MigratableConfigImpl(cpc);
this.migration.accept(migratableConfig);
migratableConfig.freeze();
}
ConfigBuilderImpl builder = new ConfigBuilderImpl(cpc, this.valueSerializers);
C config = this.builderConsumer.apply(builder);
builder.freeze();
if (this.removeUnused) {
builder.removeUnused();
}
if (this.keepOrder) {
builder.sortEntries();
}
if (this.saveAfterBuild) {
builder.config.save();
} else if (this.saveSyncAfterBuild) {
builder.config.saveSync();
}
return config;
}
}
}
@@ -0,0 +1,211 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.ConfigBuilder;
import de.maxhenkel.voicechat.configbuilder.custom.IntegerList;
import de.maxhenkel.voicechat.configbuilder.custom.StringList;
import de.maxhenkel.voicechat.configbuilder.custom.StringMap;
import de.maxhenkel.voicechat.configbuilder.custom.serializer.IntegerListValueSerializer;
import de.maxhenkel.voicechat.configbuilder.custom.serializer.StringListValueSerializer;
import de.maxhenkel.voicechat.configbuilder.custom.serializer.StringMapValueSerializer;
import de.maxhenkel.voicechat.configbuilder.custom.serializer.UUIDSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.BooleanConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.DoubleConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.EnumConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.FloatConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.GenericConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.IntegerConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.LongConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.StringConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.BooleanSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.DoubleSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.EnumSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.FloatSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.IntegerSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.LongSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.StringSerializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializable;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
public class ConfigBuilderImpl
implements ConfigBuilder {
protected final CommentedPropertyConfig config;
protected final Map<Class<?>, ValueSerializer<?>> valueSerializers;
protected List<AbstractConfigEntry<?>> entries;
protected boolean frozen;
public ConfigBuilderImpl(CommentedPropertyConfig config) {
this(config, null);
}
public ConfigBuilderImpl(CommentedPropertyConfig config, @Nullable Map<Class<?>, ValueSerializer<?>> customValueSerializers) {
this.config = config;
this.valueSerializers = ConfigBuilderImpl.getDefaultValueSerializers();
if (customValueSerializers != null) {
this.valueSerializers.putAll(customValueSerializers);
}
this.entries = new ArrayList();
}
void removeUnused() {
List existingKeys = this.entries.stream().map(AbstractConfigEntry::getKey).collect(Collectors.toList());
List toRemove = this.config.getProperties().keySet().stream().filter(s -> !existingKeys.contains(s)).collect(Collectors.toList());
for (String key : toRemove) {
this.config.getProperties().remove(key);
}
}
void sortEntries() {
HashMap<String, Integer> map = new HashMap<String, Integer>();
for (int i = 0; i < this.entries.size(); ++i) {
map.put(this.entries.get(i).getKey(), i);
}
this.config.getProperties().sort(Comparator.comparingInt(o -> map.getOrDefault(o, Integer.MAX_VALUE)));
}
void reloadFromDisk() {
this.config.reload();
this.entries.forEach(AbstractConfigEntry::reload);
}
void freeze() {
this.frozen = true;
}
void checkFrozen() {
if (this.frozen) {
throw new IllegalStateException("ConfigBuilder is frozen");
}
}
@Override
public ConfigBuilderImpl header(String ... header) {
this.checkFrozen();
this.config.getProperties().setHeaderComments(Arrays.asList(header));
return this;
}
@Override
public BooleanConfigEntry booleanEntry(String key, Boolean def, String ... comments) {
this.checkFrozen();
BooleanConfigEntry entry = new BooleanConfigEntry(this.config, BooleanSerializer.INSTANCE, comments, key, def);
this.entries.add(entry);
return entry;
}
@Override
public IntegerConfigEntry integerEntry(String key, Integer def, Integer min, Integer max, String ... comments) {
this.checkFrozen();
IntegerConfigEntry entry = new IntegerConfigEntry(this.config, IntegerSerializer.INSTANCE, comments, key, def, min, max);
this.entries.add(entry);
return entry;
}
@Override
public LongConfigEntry longEntry(String key, Long def, Long min, Long max, String ... comments) {
this.checkFrozen();
LongConfigEntry entry = new LongConfigEntry(this.config, LongSerializer.INSTANCE, comments, key, def, min, max);
this.entries.add(entry);
return entry;
}
@Override
public DoubleConfigEntry doubleEntry(String key, Double def, Double min, Double max, String ... comments) {
this.checkFrozen();
DoubleConfigEntry entry = new DoubleConfigEntry(this.config, DoubleSerializer.INSTANCE, comments, key, def, min, max);
this.entries.add(entry);
return entry;
}
@Override
public FloatConfigEntry floatEntry(String key, Float def, Float min, Float max, String ... comments) {
this.checkFrozen();
FloatConfigEntry entry = new FloatConfigEntry(this.config, FloatSerializer.INSTANCE, comments, key, def, min, max);
this.entries.add(entry);
return entry;
}
@Override
public StringConfigEntry stringEntry(String key, String def, String ... comments) {
this.checkFrozen();
StringConfigEntry entry = new StringConfigEntry(this.config, StringSerializer.INSTANCE, comments, key, def);
this.entries.add(entry);
return entry;
}
@Override
public <E extends Enum<E>> EnumConfigEntry<E> enumEntry(String key, E def, String ... comments) {
this.checkFrozen();
EnumConfigEntry entry = new EnumConfigEntry(this.config, new EnumSerializer(def.getClass()), comments, key, def);
this.entries.add(entry);
return entry;
}
@Override
public <T> ConfigEntry<T> entry(String key, T def, String ... comments) {
this.checkFrozen();
AbstractConfigEntry<T> entry = this.entryInternal(key, def, comments);
this.entries.add(entry);
return entry;
}
private <T> AbstractConfigEntry<T> entryInternal(String key, T def, String ... comments) {
ValueSerializer<?> valueSerializer = this.valueSerializers.get(def.getClass());
if (valueSerializer != null) {
return new GenericConfigEntry(this.config, valueSerializer, comments, key, def);
}
if (def instanceof Enum) {
return this.enumEntry(key, (Enum)def, comments);
}
try {
ValueSerializable annotation = def.getClass().getDeclaredAnnotation(ValueSerializable.class);
if (annotation == null) {
throw new IllegalArgumentException(String.format("Unsupported data type: %s", def.getClass().getName()));
}
Class<ValueSerializer<?>> entryConverterClass = annotation.value();
Constructor<ValueSerializer<?>> constructor = entryConverterClass.getDeclaredConstructor(new Class[0]);
constructor.setAccessible(true);
constructor.newInstance(new Object[0]);
ValueSerializer<?> converter = constructor.newInstance(new Object[0]);
return new GenericConfigEntry(this.config, converter, comments, key, def);
}
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException("Could not instantiate value serializer", e);
}
}
protected static Map<Class<?>, ValueSerializer<?>> getDefaultValueSerializers() {
HashMap valueSerializers = new HashMap();
valueSerializers.put(Boolean.class, new BooleanSerializer());
valueSerializers.put(Integer.class, new IntegerSerializer());
valueSerializers.put(Long.class, new LongSerializer());
valueSerializers.put(Float.class, new FloatSerializer());
valueSerializers.put(Double.class, new DoubleSerializer());
valueSerializers.put(String.class, new StringSerializer());
valueSerializers.put(UUID.class, UUIDSerializer.INSTANCE);
valueSerializers.put(StringList.class, StringListValueSerializer.INSTANCE);
valueSerializers.put(IntegerList.class, IntegerListValueSerializer.INSTANCE);
valueSerializers.put(StringMap.class, StringMapValueSerializer.INSTANCE);
return valueSerializers;
}
}
@@ -0,0 +1,21 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder;
import de.maxhenkel.voicechat.configbuilder.Config;
import javax.annotation.Nullable;
public interface MigratableConfig
extends Config {
@Nullable
public String get(String var1);
public boolean has(String var1);
public void set(String var1, String var2);
}
@@ -0,0 +1,58 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.MigratableConfig;
import java.util.Map;
import javax.annotation.Nullable;
class MigratableConfigImpl
implements MigratableConfig {
private final CommentedPropertyConfig config;
private boolean frozen;
public MigratableConfigImpl(CommentedPropertyConfig config) {
this.config = config;
}
@Override
@Nullable
public String get(String key) {
this.checkFrozen();
return this.config.get(key);
}
@Override
public boolean has(String key) {
this.checkFrozen();
return this.config.has(key);
}
@Override
public void set(String key, String value) {
this.checkFrozen();
this.config.set(key, value, new String[0]);
}
@Override
public Map<String, String> getEntries() {
this.checkFrozen();
return this.config.getEntries();
}
public void freeze() {
this.frozen = true;
}
private void checkFrozen() {
if (this.frozen) {
throw new IllegalStateException("ConfigBuilder is frozen");
}
}
}
@@ -0,0 +1,162 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Objects;
public abstract class AbstractValueList<T>
implements List<T> {
protected final List<T> list;
protected AbstractValueList(T ... values) {
this(Arrays.asList(values));
}
protected AbstractValueList(List<T> values) {
this.list = Collections.unmodifiableList(values);
}
@Override
public int size() {
return this.list.size();
}
@Override
public boolean isEmpty() {
return this.list.isEmpty();
}
@Override
public boolean contains(Object o) {
return this.list.contains(o);
}
@Override
public Iterator<T> iterator() {
return this.list.iterator();
}
@Override
public Object[] toArray() {
return this.list.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return this.list.toArray(a);
}
@Override
public boolean add(T s) {
return (Boolean)AbstractValueList.throwException();
}
@Override
public boolean remove(Object o) {
return (Boolean)AbstractValueList.throwException();
}
@Override
public boolean containsAll(Collection<?> c) {
return this.list.containsAll(c);
}
@Override
public boolean addAll(Collection<? extends T> c) {
return (Boolean)AbstractValueList.throwException();
}
@Override
public boolean addAll(int index, Collection<? extends T> c) {
return (Boolean)AbstractValueList.throwException();
}
@Override
public boolean removeAll(Collection<?> c) {
return (Boolean)AbstractValueList.throwException();
}
@Override
public boolean retainAll(Collection<?> c) {
return (Boolean)AbstractValueList.throwException();
}
@Override
public void clear() {
AbstractValueList.throwException();
}
@Override
public T get(int index) {
return this.list.get(index);
}
@Override
public T set(int index, T element) {
return AbstractValueList.throwException();
}
@Override
public void add(int index, T element) {
AbstractValueList.throwException();
}
@Override
public T remove(int index) {
return AbstractValueList.throwException();
}
@Override
public int indexOf(Object o) {
return this.list.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return this.list.lastIndexOf(o);
}
@Override
public ListIterator<T> listIterator() {
return this.list.listIterator();
}
@Override
public ListIterator<T> listIterator(int index) {
return this.list.listIterator(index);
}
@Override
public List<T> subList(int fromIndex, int toIndex) {
return this.list.subList(fromIndex, toIndex);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
AbstractValueList that = (AbstractValueList)o;
return Objects.equals(this.list, that.list);
}
@Override
public int hashCode() {
return this.list.hashCode();
}
private static <T> T throwException() {
throw new UnsupportedOperationException("Can't modify config entries");
}
}
@@ -0,0 +1,120 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public class AbstractValueMap<K, V>
implements Map<K, V> {
protected final Map<K, V> map;
protected AbstractValueMap(Map<K, V> map) {
this.map = Collections.unmodifiableMap(new LinkedHashMap<K, V>(map));
}
@Override
public int size() {
return this.map.size();
}
@Override
public boolean isEmpty() {
return this.map.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return this.map.containsKey(key);
}
@Override
public boolean containsValue(Object value) {
return this.map.containsValue(value);
}
@Override
public V get(Object key) {
return this.map.get(key);
}
@Override
public V put(K key, V value) {
return (V)AbstractValueMap.throwException();
}
@Override
public V remove(Object key) {
return (V)AbstractValueMap.throwException();
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
AbstractValueMap.throwException();
}
@Override
public void clear() {
AbstractValueMap.throwException();
}
@Override
public Set<K> keySet() {
return this.map.keySet();
}
@Override
public Collection<V> values() {
return this.map.values();
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
return this.map.entrySet();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
AbstractValueMap that = (AbstractValueMap)o;
return this.map.equals(that.map);
}
@Override
public int hashCode() {
return this.map.hashCode();
}
private static <T> T throwException() {
throw new UnsupportedOperationException("Can't modify config entries");
}
public static abstract class Builder<K, V, M extends AbstractValueMap<K, V>> {
protected final Map<K, V> map = new LinkedHashMap();
protected Builder() {
}
public Builder<K, V, M> put(K key, V value) {
this.map.put(key, value);
return this;
}
public Builder<K, V, M> putAll(Map<K, V> map) {
this.map.putAll(map);
return this;
}
public abstract M build();
}
}
@@ -0,0 +1,27 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom;
import de.maxhenkel.voicechat.configbuilder.custom.AbstractValueList;
import java.util.List;
public class IntegerList
extends AbstractValueList<Integer> {
protected IntegerList(Integer ... values) {
super(values);
}
protected IntegerList(List<Integer> values) {
super(values);
}
public static IntegerList of(Integer ... values) {
return new IntegerList(values);
}
public static IntegerList of(List<Integer> values) {
return new IntegerList(values);
}
}
@@ -0,0 +1,27 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom;
import de.maxhenkel.voicechat.configbuilder.custom.AbstractValueList;
import java.util.List;
public class StringList
extends AbstractValueList<String> {
protected StringList(String ... values) {
super(values);
}
protected StringList(List<String> values) {
super(values);
}
public static StringList of(String ... values) {
return new StringList(values);
}
public static StringList of(List<String> values) {
return new StringList(values);
}
}
@@ -0,0 +1,36 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom;
import de.maxhenkel.voicechat.configbuilder.custom.AbstractValueMap;
import java.util.Collections;
import java.util.Map;
public class StringMap
extends AbstractValueMap<String, String> {
protected StringMap(Map<String, String> map) {
super(map);
}
public static StringMap of(Map<String, String> map) {
return new StringMap(map);
}
public static StringMap of() {
return new StringMap(Collections.emptyMap());
}
public static Builder builder() {
return new Builder();
}
public static class Builder
extends AbstractValueMap.Builder<String, String, StringMap> {
@Override
public StringMap build() {
return new StringMap(this.map);
}
}
}
@@ -0,0 +1,42 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.custom.serializer;
import de.maxhenkel.voicechat.configbuilder.custom.IntegerList;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.util.ArrayList;
import javax.annotation.Nullable;
public class IntegerListValueSerializer
implements ValueSerializer<IntegerList> {
public static final IntegerListValueSerializer INSTANCE = new IntegerListValueSerializer();
@Override
@Nullable
public IntegerList deserialize(String str) {
ArrayList<Integer> resultList = new ArrayList<Integer>();
for (String s : str.split(",")) {
try {
resultList.add(Integer.valueOf(s));
}
catch (NumberFormatException e) {
return null;
}
}
return IntegerList.of(resultList);
}
@Override
public String serialize(IntegerList val) {
ArrayList<String> resultList = new ArrayList<String>(val.size());
for (Integer i : val) {
resultList.add(String.valueOf(i));
}
return String.join((CharSequence)",", resultList);
}
}
@@ -0,0 +1,32 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom.serializer;
import de.maxhenkel.voicechat.configbuilder.custom.StringList;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.util.ArrayList;
public class StringListValueSerializer
implements ValueSerializer<StringList> {
public static final StringListValueSerializer INSTANCE = new StringListValueSerializer();
@Override
public StringList deserialize(String str) {
ArrayList<String> resultList = new ArrayList<String>();
for (String s : str.split("(?<!\\\\),")) {
resultList.add(s.replace("\\,", ","));
}
return StringList.of(resultList);
}
@Override
public String serialize(StringList val) {
ArrayList<String> resultList = new ArrayList<String>(val.size());
for (String str : val) {
resultList.add(str.replace(",", "\\,"));
}
return String.join((CharSequence)",", resultList);
}
}
@@ -0,0 +1,55 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.custom.serializer;
import de.maxhenkel.voicechat.configbuilder.custom.StringMap;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
public class StringMapValueSerializer
implements ValueSerializer<StringMap> {
public static final StringMapValueSerializer INSTANCE = new StringMapValueSerializer();
public static final Pattern QUOTE_ESCAPE_PATTERN = Pattern.compile("\"((?:(?![\"\\\\]).|\\\\.)*)\"\\s*=\\s*\"((?:(?![\"\\\\]).|\\\\.)*)\"");
@Override
@Nullable
public StringMap deserialize(String str) {
boolean matches = QUOTE_ESCAPE_PATTERN.splitAsStream(str).allMatch(s -> s.trim().isEmpty() || s.trim().equals(","));
if (!matches) {
return null;
}
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
Matcher matcher = QUOTE_ESCAPE_PATTERN.matcher(str);
while (matcher.find()) {
map.put(StringMapValueSerializer.unescape(matcher.group(1)), StringMapValueSerializer.unescape(matcher.group(2)));
}
return StringMap.of(map);
}
@Override
public String serialize(StringMap val) {
ArrayList<String> resultList = new ArrayList<String>(val.size());
for (Map.Entry entry : val.entrySet()) {
resultList.add("\"" + StringMapValueSerializer.escape((String)entry.getKey()) + "\"=\"" + StringMapValueSerializer.escape((String)entry.getValue()) + "\"");
}
return String.join((CharSequence)",", resultList);
}
private static String escape(String input) {
return input.replace("\\", "\\\\").replace("\"", "\\\"");
}
private static String unescape(String input) {
return input.replace("\\\"", "\"").replace("\\\\", "\\");
}
}
@@ -0,0 +1,23 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.custom.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.util.UUID;
public class UUIDSerializer
implements ValueSerializer<UUID> {
public static final UUIDSerializer INSTANCE = new UUIDSerializer();
@Override
public UUID deserialize(String str) {
return UUID.fromString(str);
}
@Override
public String serialize(UUID val) {
return val.toString();
}
}
@@ -0,0 +1,134 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.Config;
import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.util.Objects;
import javax.annotation.Nullable;
public abstract class AbstractConfigEntry<T>
implements ConfigEntry<T> {
protected final CommentedPropertyConfig config;
protected final ValueSerializer<T> serializer;
protected String[] comments;
protected String key;
protected T def;
@Nullable
protected T value;
public AbstractConfigEntry(CommentedPropertyConfig config, ValueSerializer<T> serializer, String[] comments, String key, T def) {
Objects.requireNonNull(config);
Objects.requireNonNull(serializer);
Objects.requireNonNull(comments);
Objects.requireNonNull(key);
Objects.requireNonNull(def);
this.config = config;
this.serializer = serializer;
this.comments = comments;
this.key = key;
this.def = def;
}
public void reload() {
if (this.config.getProperties().containsKey(this.key)) {
T val = this.serializer.deserialize(this.config.getProperties().get(this.key));
if (val == null) {
this.reset();
} else {
this.value = this.fixValue(val);
this.syncEntryToProperties();
}
} else {
this.reset();
}
}
@Override
public T get() {
return this.value;
}
@Override
public AbstractConfigEntry<T> set(T value) {
if (this.value != null && this.value.equals(value)) {
return this;
}
this.value = this.fixValue(value);
this.syncEntryToProperties();
return this;
}
@Override
public String getKey() {
return this.key;
}
@Override
public AbstractConfigEntry<T> comment(String ... comments) {
this.comments = comments;
this.syncEntryToProperties();
return this;
}
@Override
public String[] getComments() {
return this.comments;
}
@Override
public ConfigEntry<T> reset() {
this.value = this.def;
this.syncEntryToProperties();
return this;
}
private void syncEntryToProperties() {
String serialized = this.serializer.serialize(this.value);
if (serialized == null) {
if (this.value == this.def) {
throw new IllegalStateException("Failed to serialize default value");
}
this.reset();
return;
}
this.config.getProperties().set(this.key, serialized, this.comments);
}
@Override
public ConfigEntry<T> save() {
this.config.save();
return this;
}
@Override
public ConfigEntry<T> saveSync() {
this.config.saveSync();
return this;
}
T fixValue(T value) {
return value;
}
@Override
public T getDefault() {
return this.def;
}
@Override
public Config getConfig() {
return this.config;
}
public ValueSerializer<T> getSerializer() {
return this.serializer;
}
}
@@ -0,0 +1,49 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.RangedConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class AbstractRangedConfigEntry<T>
extends AbstractConfigEntry<T>
implements RangedConfigEntry<T> {
@Nonnull
protected final T min;
@Nonnull
protected final T max;
public AbstractRangedConfigEntry(CommentedPropertyConfig config, ValueSerializer<T> serializer, String[] comments, String key, T def, @Nullable T min, @Nullable T max) {
super(config, serializer, comments, key, def);
this.min = min != null ? min : this.minimumPossibleValue();
this.max = max != null ? max : this.maximumPossibleValue();
}
@Override
@Nonnull
public T getMin() {
return this.min;
}
@Override
@Nonnull
public T getMax() {
return this.max;
}
@Nonnull
abstract T minimumPossibleValue();
@Nonnull
abstract T maximumPossibleValue();
}
@@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
public class BooleanConfigEntry
extends AbstractConfigEntry<Boolean> {
public BooleanConfigEntry(CommentedPropertyConfig config, ValueSerializer<Boolean> serializer, String[] comments, String key, Boolean def) {
super(config, serializer, comments, key, def);
this.reload();
}
}
@@ -0,0 +1,29 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.Config;
public interface ConfigEntry<T> {
public ConfigEntry<T> comment(String ... var1);
public String[] getComments();
public T get();
public ConfigEntry<T> set(T var1);
public String getKey();
public ConfigEntry<T> reset();
public ConfigEntry<T> save();
public ConfigEntry<T> saveSync();
public T getDefault();
public Config getConfig();
}
@@ -0,0 +1,40 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class DoubleConfigEntry
extends AbstractRangedConfigEntry<Double> {
public DoubleConfigEntry(CommentedPropertyConfig config, ValueSerializer<Double> serializer, String[] comments, String key, Double def, @Nullable Double min, @Nullable Double max) {
super(config, serializer, comments, key, def, min, max);
this.reload();
}
@Override
@Nonnull
Double minimumPossibleValue() {
return Double.MIN_VALUE;
}
@Override
@Nonnull
Double maximumPossibleValue() {
return Double.MAX_VALUE;
}
@Override
Double fixValue(Double value) {
return Math.max(Math.min(value, (Double)this.max), (Double)this.min);
}
}
@@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
public class EnumConfigEntry<E extends Enum<E>>
extends AbstractConfigEntry<E> {
public EnumConfigEntry(CommentedPropertyConfig config, ValueSerializer<E> serializer, String[] comments, String key, E def) {
super(config, serializer, comments, key, def);
this.reload();
}
}
@@ -0,0 +1,40 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class FloatConfigEntry
extends AbstractRangedConfigEntry<Float> {
public FloatConfigEntry(CommentedPropertyConfig config, ValueSerializer<Float> serializer, String[] comments, String key, Float def, @Nullable Float min, @Nullable Float max) {
super(config, serializer, comments, key, def, min, max);
this.reload();
}
@Override
@Nonnull
Float minimumPossibleValue() {
return Float.valueOf(Float.MIN_VALUE);
}
@Override
@Nonnull
Float maximumPossibleValue() {
return Float.valueOf(Float.MAX_VALUE);
}
@Override
Float fixValue(Float value) {
return Float.valueOf(Math.max(Math.min(value.floatValue(), ((Float)this.max).floatValue()), ((Float)this.min).floatValue()));
}
}
@@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
public class GenericConfigEntry<T>
extends AbstractConfigEntry<T> {
public GenericConfigEntry(CommentedPropertyConfig config, ValueSerializer<T> serializer, String[] comments, String key, T def) {
super(config, serializer, comments, key, def);
this.reload();
}
}
@@ -0,0 +1,40 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class IntegerConfigEntry
extends AbstractRangedConfigEntry<Integer> {
public IntegerConfigEntry(CommentedPropertyConfig config, ValueSerializer<Integer> serializer, String[] comments, String key, Integer def, @Nullable Integer min, @Nullable Integer max) {
super(config, serializer, comments, key, def, min, max);
this.reload();
}
@Override
@Nonnull
Integer minimumPossibleValue() {
return Integer.MIN_VALUE;
}
@Override
@Nonnull
Integer maximumPossibleValue() {
return Integer.MAX_VALUE;
}
@Override
Integer fixValue(Integer value) {
return Math.max(Math.min(value, (Integer)this.max), (Integer)this.min);
}
}
@@ -0,0 +1,40 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class LongConfigEntry
extends AbstractRangedConfigEntry<Long> {
public LongConfigEntry(CommentedPropertyConfig config, ValueSerializer<Long> serializer, String[] comments, String key, Long def, @Nullable Long min, @Nullable Long max) {
super(config, serializer, comments, key, def, min, max);
this.reload();
}
@Override
@Nonnull
Long minimumPossibleValue() {
return Long.MIN_VALUE;
}
@Override
@Nonnull
Long maximumPossibleValue() {
return Long.MAX_VALUE;
}
@Override
Long fixValue(Long value) {
return Math.max(Math.min(value, (Long)this.max), (Long)this.min);
}
}
@@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nonnull
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry;
import javax.annotation.Nonnull;
public interface RangedConfigEntry<T>
extends ConfigEntry<T> {
@Nonnull
public T getMin();
@Nonnull
public T getMax();
}
@@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.entry;
import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig;
import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
public class StringConfigEntry
extends AbstractConfigEntry<String> {
public StringConfigEntry(CommentedPropertyConfig config, ValueSerializer<String> serializer, String[] comments, String key, String def) {
super(config, serializer, comments, key, def);
this.reload();
}
}
@@ -0,0 +1,28 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class BooleanSerializer
implements ValueSerializer<Boolean> {
public static final BooleanSerializer INSTANCE = new BooleanSerializer();
@Override
@Nullable
public Boolean deserialize(String str) {
return Boolean.valueOf(str);
}
@Override
@Nullable
public String serialize(Boolean val) {
return String.valueOf(val);
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class DoubleSerializer
implements ValueSerializer<Double> {
public static final DoubleSerializer INSTANCE = new DoubleSerializer();
@Override
@Nullable
public Double deserialize(String str) {
try {
return Double.parseDouble(str);
}
catch (NumberFormatException e) {
return null;
}
}
@Override
@Nullable
public String serialize(Double val) {
return String.valueOf(val);
}
}
@@ -0,0 +1,37 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class EnumSerializer<E extends Enum<E>>
implements ValueSerializer<E> {
protected Class<E> enumClass;
public EnumSerializer(Class<E> enumClass) {
this.enumClass = enumClass;
}
@Override
@Nullable
public E deserialize(String str) {
try {
return Enum.valueOf(this.enumClass, str);
}
catch (Exception e) {
return null;
}
}
@Override
@Nullable
public String serialize(E val) {
return ((Enum)val).name();
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class FloatSerializer
implements ValueSerializer<Float> {
public static final FloatSerializer INSTANCE = new FloatSerializer();
@Override
@Nullable
public Float deserialize(String str) {
try {
return Float.valueOf(Float.parseFloat(str));
}
catch (NumberFormatException e) {
return null;
}
}
@Override
@Nullable
public String serialize(Float val) {
return String.valueOf(val);
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class IntegerSerializer
implements ValueSerializer<Integer> {
public static final IntegerSerializer INSTANCE = new IntegerSerializer();
@Override
@Nullable
public Integer deserialize(String str) {
try {
return Integer.parseInt(str);
}
catch (NumberFormatException e) {
return null;
}
}
@Override
@Nullable
public String serialize(Integer val) {
return String.valueOf(val);
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class LongSerializer
implements ValueSerializer<Long> {
public static final LongSerializer INSTANCE = new LongSerializer();
@Override
@Nullable
public Long deserialize(String str) {
try {
return Long.parseLong(str);
}
catch (NumberFormatException e) {
return null;
}
}
@Override
@Nullable
public String serialize(Long val) {
return String.valueOf(val);
}
}
@@ -0,0 +1,28 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import javax.annotation.Nullable;
public class StringSerializer
implements ValueSerializer<String> {
public static final StringSerializer INSTANCE = new StringSerializer();
@Override
@Nullable
public String deserialize(String str) {
return str;
}
@Override
@Nullable
public String serialize(String val) {
return val;
}
}
@@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value=RetentionPolicy.RUNTIME)
@Target(value={ElementType.TYPE})
public @interface ValueSerializable {
public Class<? extends ValueSerializer<?>> value();
}
@@ -0,0 +1,18 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.configbuilder.entry.serializer;
import javax.annotation.Nullable;
public interface ValueSerializer<T> {
@Nullable
public T deserialize(String var1);
@Nullable
public String serialize(T var1);
}