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,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;
}
}