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

232 lines
6.9 KiB
Java
Raw Normal View History

package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.IPartyOptions;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumPartyExchange;
2024-03-03 17:38:15 -05:00
import noppes.npcs.constants.EnumPartyObjectives;
import noppes.npcs.constants.EnumPartyRequirements;
public class PartyOptions implements IPartyOptions {
public boolean allowParty = false;
public boolean onlyParty = false;
2024-03-03 17:38:15 -05:00
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
public EnumPartyExchange executeCommand = EnumPartyExchange.Leader;
2024-03-03 17:38:15 -05:00
2024-03-03 20:19:08 -05:00
public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared;
public int minPartySize = ConfigMain.DefaultMinPartySize;
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
public void readFromNBT(NBTTagCompound compound)
{
// Party Management
allowParty = compound.getBoolean("AllowParty");
if(allowParty){
onlyParty = compound.getBoolean("OnlyParty");
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
executeCommand = EnumPartyExchange.values()[compound.getInteger("ExecuteCommand")];
minPartySize = compound.getInteger("MinPartySize");
maxPartySize = compound.getInteger("MaxPartySize");
2024-03-03 17:38:15 -05:00
objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")];
}
else {
if(compound.hasKey("OnlyParty")){
compound.removeTag("OnlyParty");
}
if(compound.hasKey("PartyRequirements")){
compound.removeTag("PartyRequirements");
}
if(compound.hasKey("RewardControl")){
compound.removeTag("RewardControl");
}
if(compound.hasKey("CompleteFor")){
compound.removeTag("CompleteFor");
}
if(compound.hasKey("ExecuteCommand")){
compound.removeTag("ExecuteCommand");
}
if(compound.hasKey("MinPartySize")){
compound.removeTag("MinPartySize");
}
if(compound.hasKey("MaxPartySize")){
compound.removeTag("MaxPartySize");
}
2024-03-03 17:38:15 -05:00
if(compound.hasKey("ObjectiveRequirement")){
compound.removeTag("ObjectiveRequirement");
}
onlyParty = false;
2024-03-03 17:38:15 -05:00
partyRequirements = EnumPartyRequirements.Leader;
rewardControl = EnumPartyExchange.Leader;
completeFor = EnumPartyExchange.Leader;
executeCommand = EnumPartyExchange.Leader;
minPartySize = ConfigMain.DefaultMinPartySize;
maxPartySize = ConfigMain.DefaultMaxPartySize;
objectiveRequirement = EnumPartyObjectives.Shared;
}
}
public NBTTagCompound writeToNBT()
{
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("AllowParty", allowParty);
if(allowParty){
compound.setBoolean("OnlyParty", onlyParty);
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
compound.setInteger("RewardControl", rewardControl.ordinal());
compound.setInteger("CompleteFor", completeFor.ordinal());
compound.setInteger("ExecuteCommand", executeCommand.ordinal());
compound.setInteger("MinPartySize", minPartySize);
compound.setInteger("MaxPartySize", maxPartySize);
2024-03-03 17:38:15 -05:00
compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal());
}
else {
if(compound.hasKey("OnlyParty")){
compound.removeTag("OnlyParty");
}
if(compound.hasKey("PartyRequirements")){
compound.removeTag("PartyRequirements");
}
if(compound.hasKey("RewardControl")){
compound.removeTag("RewardControl");
}
if(compound.hasKey("CompleteFor")){
compound.removeTag("CompleteFor");
}
if(compound.hasKey("ExecuteCommand")){
compound.removeTag("ExecuteCommand");
}
if(compound.hasKey("MinPartySize")){
compound.removeTag("MinPartySize");
}
if(compound.hasKey("MaxPartySize")){
compound.removeTag("MaxPartySize");
}
2024-03-03 17:38:15 -05:00
if(compound.hasKey("ObjectiveRequirement")){
compound.removeTag("ObjectiveRequirement");
}
}
return compound;
}
2024-03-03 17:38:15 -05:00
@Override
public boolean isAllowParty() {
return allowParty;
}
2024-03-03 17:38:15 -05:00
@Override
public void setAllowParty(boolean allowParty) {
this.allowParty = allowParty;
}
@Override
public boolean isOnlyParty() {
return onlyParty;
}
@Override
public void setOnlyParty(boolean onlyParty) {
this.onlyParty = onlyParty;
}
2024-03-03 17:38:15 -05:00
@Override
public int getPartyRequirements() {
return partyRequirements.ordinal();
}
2024-03-03 17:38:15 -05:00
@Override
public void setPartyRequirements(int partyReq) {
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
return;
}
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
}
2024-03-03 17:38:15 -05:00
@Override
public int getRewardControl() {
return rewardControl.ordinal();
}
2024-03-03 17:38:15 -05:00
@Override
public void setRewardControl(int rewardCon) {
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
return;
}
this.rewardControl = EnumPartyExchange.values()[rewardCon];
}
2024-03-03 17:38:15 -05:00
@Override
public int getCompleteFor() {
return completeFor.ordinal();
}
2024-03-03 17:38:15 -05:00
@Override
public void setCompleteFor(int compFor) {
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
return;
}
this.completeFor = EnumPartyExchange.values()[compFor];
}
@Override
public int getExecuteCommandFor() {
return executeCommand.ordinal();
}
@Override
public void setExecuteCommandFor(int commandFor) {
if (commandFor < 0 || commandFor >= EnumPartyExchange.values().length) {
return;
}
this.executeCommand = EnumPartyExchange.values()[commandFor];
}
@Override
2024-03-03 17:38:15 -05:00
public int getObjectiveRequirement() {
return objectiveRequirement.ordinal();
}
@Override
2024-03-03 17:38:15 -05:00
public void setObjectiveRequirement(int requirement) {
if (requirement < 0 || requirement >= EnumPartyObjectives.values().length) {
return;
}
this.objectiveRequirement = EnumPartyObjectives.values()[requirement];
}
@Override
public int getMinPartySize() {
return minPartySize;
}
@Override
public void setMinPartySize(int newSize) {
if(newSize < 1)
newSize = 1;
if(newSize > maxPartySize)
newSize = maxPartySize;
minPartySize = newSize;
}
@Override
public int getMaxPartySize() {
return maxPartySize;
}
@Override
public void setMaxPartySize(int newSize) {
if(newSize < minPartySize)
newSize = minPartySize;
maxPartySize = newSize;
}
}