Port to java 16 and MC 1.17

This commit is contained in:
ffrann
2021-05-26 20:27:14 -04:00
parent c2d7cacdab
commit f468546eea
21 changed files with 157 additions and 156 deletions
@@ -1,7 +1,7 @@
package draylar.omegaconfig.api;
import draylar.omegaconfig.OmegaConfig;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@@ -16,12 +16,12 @@ public interface Config {
OmegaConfig.writeConfig((Class<Config>) getClass(), this);
}
default CompoundTag writeSyncingTag() {
CompoundTag tag = new CompoundTag();
default NbtCompound writeSyncingTag() {
NbtCompound tag = new NbtCompound();
tag.putString("ConfigName", getName());
// all config vs. individual fields
if(Arrays.stream(getClass().getAnnotations()).anyMatch(annotation -> annotation instanceof Syncing)) {
if (Arrays.stream(getClass().getAnnotations()).anyMatch(annotation -> annotation instanceof Syncing)) {
// write ALL fields to tag
String json = OmegaConfig.GSON.toJson(this);
tag.putString("Serialized", json);
@@ -37,7 +37,7 @@ public interface Config {
}
/**
* @return true if this {@link Config} has any values that should be synced to the client
* @return true if this {@link Config} has any values that should be synced to the client
*/
default boolean hasAnySyncable() {
boolean hasSyncingField = Arrays.stream(getClass().getDeclaredFields()).anyMatch(field -> Arrays.stream(field.getDeclaredAnnotations()).anyMatch(annotation -> annotation instanceof Syncing));
@@ -55,7 +55,7 @@ public interface Config {
* <li>No special characters ($, %, ^, etc.)
* <li>No spaces
*
* @return the name of this config, which is used for the name of the config file saved to disk.
* @return the name of this config, which is used for the name of the config file saved to disk.
*/
String getName();
@@ -64,14 +64,14 @@ public interface Config {
*
* <p>
* This functionality is used for libraries like ModMenu, which depend on
* modids for configuration screen instances in their menu.
* modids for configuration screen instances in their menu.
* If you are intending for this config to have a ModMenu config
* screen, this method should return the modid specified in your fabric.mod.json.
*
* screen, this method should return the modid specified in your fabric.mod.json.
* <p>
* If this method is not overridden, null will be returned, which
* means this config is not explicitly associated with any particular mod.
* means this config is not explicitly associated with any particular mod.
*
* @return the modid of the mod associated with this config, or null if none was specified
* @return the modid of the mod associated with this config, or null if none was specified
*/
@Nullable
default String getModid() {
@@ -84,9 +84,9 @@ public interface Config {
* <p>
* The file extension is used while serializing this config to a local file.
* The primary use-case of switching this would be supporting existing config files
* when porting from other json5 config libraries.
* when porting from other json5 config libraries.
*
* @return the file extension of this config
* @return the file extension of this config
*/
default String getExtension() {
return "json";
@@ -98,11 +98,11 @@ public interface Config {
* <p>
* By default, a config such as 'my_config' will appear at /config/my_config.json.
* If this method specifies a directory, such as 'configurations',
* the config file will appear at /config/configurations/my_config.json.
*
* the config file will appear at /config/configurations/my_config.json.
* <p>
* Nested directories can be specified by using a string such as 'configurations/client'.
*
* @return the directory of this config
* @return the directory of this config
*/
default String getDirectory() {
return "";