Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -4,15 +4,13 @@ import java.lang.reflect.Type;
|
|||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import ru.betterend.util.JsonFactory;
|
||||
|
||||
public final class ConfigKeeper {
|
||||
|
@ -109,7 +107,7 @@ public final class ConfigKeeper {
|
|||
|
||||
@Override
|
||||
public Boolean fromJson() {
|
||||
return JsonHelper.getBoolean(location, key, defaultValue);
|
||||
return GsonHelper.getAsBoolean(location, key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,7 +124,7 @@ public final class ConfigKeeper {
|
|||
|
||||
@Override
|
||||
public Float fromJson() {
|
||||
return JsonHelper.getFloat(location, key, defaultValue);
|
||||
return GsonHelper.getAsFloat(location, key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,7 +141,7 @@ public final class ConfigKeeper {
|
|||
|
||||
@Override
|
||||
public Float fromJson() {
|
||||
return JsonHelper.getFloat(location, key, defaultValue);
|
||||
return GsonHelper.getAsFloat(location, key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -165,7 +163,7 @@ public final class ConfigKeeper {
|
|||
|
||||
@Override
|
||||
public Integer fromJson() {
|
||||
return JsonHelper.getInt(location, key, defaultValue);
|
||||
return GsonHelper.getAsInt(location, key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,7 +180,7 @@ public final class ConfigKeeper {
|
|||
|
||||
@Override
|
||||
public Integer fromJson() {
|
||||
return JsonHelper.getInt(location, key, defaultValue);
|
||||
return GsonHelper.getAsInt(location, key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,7 +197,7 @@ public final class ConfigKeeper {
|
|||
|
||||
@Override
|
||||
public String fromJson() {
|
||||
return JsonHelper.getString(location, key, defaultValue);
|
||||
return GsonHelper.getAsString(location, key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,14 +6,14 @@ public class ConfigKey {
|
|||
private final String path[];
|
||||
private final String entry;
|
||||
private final boolean root;
|
||||
|
||||
|
||||
public ConfigKey(String entry, String... path) {
|
||||
this.validate(entry);
|
||||
this.path = path;
|
||||
this.entry = entry;
|
||||
this.root = path.length == 0 || (path.length == 1 && path[0].isEmpty());
|
||||
}
|
||||
|
||||
|
||||
public ConfigKey(String entry, ResourceLocation path) {
|
||||
this(entry, path.getNamespace(), path.getPath());
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class ConfigKey {
|
|||
public String getEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRoot() {
|
||||
return root;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class ConfigKey {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (root) {
|
||||
|
@ -73,7 +73,7 @@ public class ConfigKey {
|
|||
}
|
||||
return String.format("%s:%s", p, entry);
|
||||
}
|
||||
|
||||
|
||||
private void validate(String entry) {
|
||||
if (entry == null) {
|
||||
throw new NullPointerException("Config key must be not null!");
|
||||
|
|
|
@ -1,26 +1,23 @@
|
|||
package ru.betterend.config;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.betterend.config.ConfigKeeper.Entry;
|
||||
import ru.betterend.config.ConfigKeeper.FloatRange;
|
||||
import ru.betterend.config.ConfigKeeper.IntegerRange;
|
||||
|
||||
public class IdConfig extends Config {
|
||||
|
||||
|
||||
protected final BiFunction<ResourceLocation, String, ConfigKey> keyFactory;
|
||||
|
||||
|
||||
public IdConfig(String group, BiFunction<ResourceLocation, String, ConfigKey> keyFactory) {
|
||||
super(group);
|
||||
this.keyFactory = keyFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerEntries() {
|
||||
}
|
||||
protected void registerEntries() {}
|
||||
|
||||
protected ConfigKey createKey(ResourceLocation id, String key) {
|
||||
return this.keyFactory.apply(id, key);
|
||||
|
@ -63,7 +60,7 @@ public class IdConfig extends Config {
|
|||
public boolean setRangedInt(ResourceLocation id, String key, int value) {
|
||||
return this.setRanged(createKey(id, key), value, IntegerRange.class);
|
||||
}
|
||||
|
||||
|
||||
public boolean setRangedFloat(ResourceLocation id, String key, float value) {
|
||||
return this.setRanged(createKey(id, key), value, FloatRange.class);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue