diff --git a/src/main/java/one/oth3r/sit/file/CustomBlock.java b/src/main/java/one/oth3r/sit/file/CustomBlock.java index 0c4f5e7..6f8f0f7 100644 --- a/src/main/java/one/oth3r/sit/file/CustomBlock.java +++ b/src/main/java/one/oth3r/sit/file/CustomBlock.java @@ -51,6 +51,7 @@ public class CustomBlock { boolean blockType = checkBlockType(blockState); if (!blockType) return false; + /// BLOCK STATE CHECKER // now check if the state is one of the acceptable states for (String state : blockStates) { // if there is a NOT (!) blockstate diff --git a/src/main/java/one/oth3r/sit/file/CustomFile.java b/src/main/java/one/oth3r/sit/file/CustomFile.java index fb2d279..eab2d74 100644 --- a/src/main/java/one/oth3r/sit/file/CustomFile.java +++ b/src/main/java/one/oth3r/sit/file/CustomFile.java @@ -56,13 +56,24 @@ public interface CustomFile > { if (file == null) throw new NullPointerException(); // update the instance - updateToNewFile(file); + file.update(); + // load the file to the current object + loadFileData(file); } @NotNull Class getFileClass(); - void updateToNewFile(T newFile); + /** + * loads the data from the file object into the current object + * @param newFile the file to take the properties from + */ + void loadFileData(T newFile); + + /** + * updates the file based on the version number of the current instance + */ + void update(); /** * logic for the file not existing when loading, defaults to saving diff --git a/src/main/java/one/oth3r/sit/file/SittingConfig.java b/src/main/java/one/oth3r/sit/file/SittingConfig.java index c3409fe..d9e65e8 100644 --- a/src/main/java/one/oth3r/sit/file/SittingConfig.java +++ b/src/main/java/one/oth3r/sit/file/SittingConfig.java @@ -3,16 +3,8 @@ package one.oth3r.sit.file; import com.google.gson.annotations.SerializedName; import net.minecraft.util.Hand; import one.oth3r.sit.utl.Data; -import one.oth3r.sit.utl.Utl; import org.jetbrains.annotations.NotNull; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.ArrayList; - public class SittingConfig implements CustomFile { @SerializedName("version") @@ -37,7 +29,7 @@ public class SittingConfig implements CustomFile { } public SittingConfig(SittingConfig sittingConfig) { - updateToNewFile(sittingConfig); + loadFileData(sittingConfig); } public Double getVersion() { @@ -74,7 +66,7 @@ public class SittingConfig implements CustomFile { @Override public void reset() { - updateToNewFile(new SittingConfig()); + loadFileData(new SittingConfig()); } @Override @@ -83,7 +75,7 @@ public class SittingConfig implements CustomFile { } @Override - public void updateToNewFile(SittingConfig newFile) { + public void loadFileData(SittingConfig newFile) { this.version = newFile.version; this.enabled = newFile.enabled; this.handSitting = newFile.handSitting; @@ -91,6 +83,9 @@ public class SittingConfig implements CustomFile { this.offHand = newFile.offHand; } + @Override + public void update() {} + @Override public String getFileName() { return "sitting-config.json";