2024-07-11 13:43:54 -05:00
|
|
|
package one.oth3r.sit.file;
|
|
|
|
|
2025-05-04 13:39:34 -05:00
|
|
|
import com.google.common.base.Objects;
|
|
|
|
import com.google.gson.JsonElement;
|
2024-07-11 13:43:54 -05:00
|
|
|
import com.google.gson.annotations.SerializedName;
|
|
|
|
import net.minecraft.util.Hand;
|
2025-05-04 13:39:34 -05:00
|
|
|
import one.oth3r.otterlib.file.CustomFile;
|
|
|
|
import one.oth3r.otterlib.file.FileSettings;
|
2024-07-23 13:49:43 -05:00
|
|
|
import one.oth3r.sit.utl.Data;
|
2024-08-26 14:46:01 -05:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2024-07-11 13:43:54 -05:00
|
|
|
|
2025-05-04 13:39:34 -05:00
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
2024-08-26 14:46:01 -05:00
|
|
|
public class SittingConfig implements CustomFile<SittingConfig> {
|
2024-07-11 13:43:54 -05:00
|
|
|
|
|
|
|
@SerializedName("version")
|
|
|
|
private Double version = 1.0;
|
2024-07-23 11:27:06 -05:00
|
|
|
@SerializedName("enabled")
|
|
|
|
private Boolean enabled = true;
|
2024-07-11 13:43:54 -05:00
|
|
|
@SerializedName("hand-sitting")
|
2024-07-23 11:27:06 -05:00
|
|
|
private Boolean handSitting = true;
|
2024-07-11 13:43:54 -05:00
|
|
|
@SerializedName("main-hand")
|
2024-08-07 12:45:53 -05:00
|
|
|
private HandSetting mainHand = FileData.Defaults.MAIN_HAND;
|
2024-07-11 13:43:54 -05:00
|
|
|
@SerializedName("off-hand")
|
2024-08-07 12:45:53 -05:00
|
|
|
private HandSetting offHand = FileData.Defaults.OFF_HAND;
|
2024-07-11 13:43:54 -05:00
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public SittingConfig() {}
|
2024-07-11 13:43:54 -05:00
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public SittingConfig(double version, boolean enabled, boolean handSitting, HandSetting mainHand, HandSetting offHand) {
|
2024-07-11 13:43:54 -05:00
|
|
|
this.version = version;
|
2024-07-23 11:27:06 -05:00
|
|
|
this.enabled = enabled;
|
2024-07-11 13:43:54 -05:00
|
|
|
this.handSitting = handSitting;
|
|
|
|
this.mainHand = mainHand;
|
|
|
|
this.offHand = offHand;
|
|
|
|
}
|
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public SittingConfig(SittingConfig sittingConfig) {
|
2025-05-04 13:39:34 -05:00
|
|
|
copyFileData(sittingConfig);
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public Double getVersion() {
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2024-07-23 13:49:43 -05:00
|
|
|
public Boolean getEnabled() {
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEnabled(Boolean enabled) {
|
|
|
|
this.enabled = enabled;
|
|
|
|
}
|
|
|
|
|
2024-07-11 13:43:54 -05:00
|
|
|
public boolean canSitWithHand() {
|
|
|
|
return handSitting;
|
|
|
|
}
|
|
|
|
|
2024-07-23 13:49:43 -05:00
|
|
|
public void setHandSitting(Boolean handSitting) {
|
|
|
|
this.handSitting = handSitting;
|
|
|
|
}
|
|
|
|
|
2024-07-11 13:43:54 -05:00
|
|
|
public HandSetting getHand(Hand handType) {
|
|
|
|
return handType.equals(Hand.MAIN_HAND) ? mainHand : offHand;
|
|
|
|
}
|
|
|
|
|
|
|
|
public HandSetting getMainHand() {
|
|
|
|
return mainHand;
|
|
|
|
}
|
|
|
|
|
|
|
|
public HandSetting getOffHand() {
|
|
|
|
return offHand;
|
|
|
|
}
|
|
|
|
|
2025-05-04 13:39:34 -05:00
|
|
|
@Override
|
|
|
|
public FileSettings getFileSettings() {
|
2025-05-12 23:10:20 -05:00
|
|
|
return new FileSettings(Data.LOGGER);
|
2025-05-04 13:39:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Path getFilePath() {
|
|
|
|
return Paths.get(Data.CONFIG_DIR, "sitting-config.json");
|
|
|
|
}
|
|
|
|
|
2024-08-26 14:46:01 -05:00
|
|
|
@Override
|
|
|
|
public void reset() {
|
2025-05-04 13:39:34 -05:00
|
|
|
copyFileData(new SittingConfig());
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
2024-08-26 14:46:01 -05:00
|
|
|
@Override
|
|
|
|
public @NotNull Class<SittingConfig> getFileClass() {
|
|
|
|
return SittingConfig.class;
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
2024-08-26 14:46:01 -05:00
|
|
|
@Override
|
2025-05-04 13:39:34 -05:00
|
|
|
public void copyFileData(SittingConfig sittingConfig) {
|
|
|
|
this.version = sittingConfig.version;
|
|
|
|
this.enabled = sittingConfig.enabled;
|
|
|
|
this.handSitting = sittingConfig.handSitting;
|
|
|
|
this.mainHand = new HandSetting(sittingConfig.mainHand);
|
|
|
|
this.offHand = new HandSetting(sittingConfig.offHand);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2025-06-16 15:07:37 -05:00
|
|
|
public void updateInstance() {
|
2025-05-04 13:39:34 -05:00
|
|
|
|
2024-08-26 14:46:01 -05:00
|
|
|
}
|
|
|
|
|
2024-12-02 12:55:55 -06:00
|
|
|
@Override
|
2025-05-04 13:39:34 -05:00
|
|
|
public SittingConfig clone() {
|
|
|
|
SittingConfig clone = new SittingConfig();
|
|
|
|
clone.copyFileData(this);
|
|
|
|
return clone;
|
|
|
|
}
|
2024-12-02 12:55:55 -06:00
|
|
|
|
2024-08-26 14:46:01 -05:00
|
|
|
@Override
|
2025-05-04 13:39:34 -05:00
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
SittingConfig that = (SittingConfig) o;
|
|
|
|
return Objects.equal(version, that.version) && Objects.equal(enabled, that.enabled) && Objects.equal(handSitting, that.handSitting) && Objects.equal(mainHand, that.mainHand) && Objects.equal(offHand, that.offHand);
|
2024-08-26 14:46:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2025-05-04 13:39:34 -05:00
|
|
|
public int hashCode() {
|
|
|
|
return Objects.hashCode(version, enabled, handSitting, mainHand, offHand);
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
}
|