Files
CustomNPC-Plus/src/main/java/noppes/npcs/controllers/data/ProfileOptions.java
T

85 lines
2.7 KiB
Java
Raw Normal View History

2025-02-21 06:19:24 -05:00
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.IProfileOptions;
import noppes.npcs.constants.EnumProfileSync;
public class ProfileOptions implements IProfileOptions {
2025-03-12 20:12:01 -04:00
public boolean enableOptions = false;
2025-02-21 06:19:24 -05:00
public EnumProfileSync cooldownControl = EnumProfileSync.Individual;
2025-03-12 20:12:01 -04:00
public EnumProfileSync completeControl = EnumProfileSync.Individual;
2025-02-21 06:19:24 -05:00
2025-03-12 20:12:01 -04:00
public void readFromNBT(NBTTagCompound compound) {
// Party Management
2025-02-21 06:19:24 -05:00
enableOptions = compound.getBoolean("EnableProfiles");
2025-03-12 20:12:01 -04:00
if (enableOptions) {
2025-02-21 06:19:24 -05:00
cooldownControl = EnumProfileSync.values()[compound.getInteger("CooldownControl")];
completeControl = EnumProfileSync.values()[compound.getInteger("CompleteControl")];
2025-03-12 20:12:01 -04:00
} else {
if (compound.hasKey("CooldownControl")) {
2025-02-21 06:19:24 -05:00
compound.removeTag("CooldownControl");
}
2025-03-12 20:12:01 -04:00
if (compound.hasKey("CompleteControl")) {
compound.removeTag("CompleteControl");
}
2025-02-21 06:19:24 -05:00
cooldownControl = EnumProfileSync.Individual;
completeControl = EnumProfileSync.Individual;
2025-03-12 20:12:01 -04:00
}
2025-02-21 06:19:24 -05:00
}
2025-03-12 20:12:01 -04:00
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("EnableProfiles", enableOptions);
if (enableOptions) {
compound.setInteger("CooldownControl", cooldownControl.ordinal());
compound.setInteger("CompleteControl", completeControl.ordinal());
} else {
if (compound.hasKey("CooldownControl")) {
2025-02-21 06:19:24 -05:00
compound.removeTag("CooldownControl");
}
2025-03-12 20:12:01 -04:00
if (compound.hasKey("CompleteControl")) {
compound.removeTag("CompleteControl");
}
}
2025-02-21 06:19:24 -05:00
2025-03-12 20:12:01 -04:00
return compound;
2025-02-21 06:19:24 -05:00
}
@Override
2025-03-12 20:12:01 -04:00
public boolean hasProfileOptions() {
return enableOptions;
}
2025-02-21 06:19:24 -05:00
@Override
2025-03-12 20:12:01 -04:00
public void setProfileOptions(boolean enable) {
this.enableOptions = enable;
}
2025-02-21 06:19:24 -05:00
@Override
2025-03-12 20:12:01 -04:00
public void setCooldownControl(int profileType) {
if (profileType < 0 || profileType >= EnumProfileSync.values().length) {
return;
}
this.cooldownControl = EnumProfileSync.values()[profileType];
}
2025-02-21 06:19:24 -05:00
@Override
2025-03-12 20:12:01 -04:00
public int getCooldownControl() {
2025-02-21 06:19:24 -05:00
return this.cooldownControl.ordinal();
}
@Override
public void setCompleteControl(int profileType) {
if (profileType < 0 || profileType >= EnumProfileSync.values().length) {
return;
}
this.completeControl = EnumProfileSync.values()[profileType];
}
@Override
2025-03-12 20:12:01 -04:00
public int getCompleteControl() {
2025-02-21 06:19:24 -05:00
return this.completeControl.ordinal();
}
}