2024-02-13 14:14:21 -06:00
|
|
|
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;
|
2024-02-13 14:14:21 -06:00
|
|
|
import noppes.npcs.constants.EnumPartyRequirements;
|
2024-03-05 00:40:48 -05:00
|
|
|
|
|
|
|
|
import java.util.Vector;
|
2024-02-13 14:14:21 -06:00
|
|
|
|
|
|
|
|
public class PartyOptions implements IPartyOptions {
|
2025-03-12 20:12:01 -04:00
|
|
|
public boolean allowParty = false;
|
2024-03-04 05:15:50 -05:00
|
|
|
public boolean onlyParty = false;
|
2024-03-03 17:38:15 -05:00
|
|
|
|
|
|
|
|
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
|
|
|
|
|
|
|
|
|
|
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
|
2025-03-12 20:12:01 -04:00
|
|
|
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
|
2024-03-04 05:15:50 -05:00
|
|
|
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;
|
2024-03-04 05:15:50 -05:00
|
|
|
|
|
|
|
|
public int minPartySize = ConfigMain.DefaultMinPartySize;
|
2025-03-12 20:12:01 -04:00
|
|
|
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
|
2024-02-13 17:30:01 -06:00
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
public void readFromNBT(NBTTagCompound compound) {
|
|
|
|
|
// Party Management
|
|
|
|
|
allowParty = compound.getBoolean("AllowParty");
|
|
|
|
|
if (allowParty) {
|
2024-03-04 05:15:50 -05:00
|
|
|
onlyParty = compound.getBoolean("OnlyParty");
|
2025-03-12 20:12:01 -04:00
|
|
|
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
|
|
|
|
|
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
|
|
|
|
|
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
|
2024-03-04 05:15:50 -05:00
|
|
|
executeCommand = EnumPartyExchange.values()[compound.getInteger("ExecuteCommand")];
|
|
|
|
|
minPartySize = compound.getInteger("MinPartySize");
|
2025-03-12 20:12:01 -04:00
|
|
|
maxPartySize = compound.getInteger("MaxPartySize");
|
2024-03-03 17:38:15 -05:00
|
|
|
objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")];
|
2025-03-12 20:12:01 -04:00
|
|
|
} else {
|
|
|
|
|
if (compound.hasKey("OnlyParty")) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.removeTag("OnlyParty");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
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")) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.removeTag("ExecuteCommand");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
if (compound.hasKey("MinPartySize")) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.removeTag("MinPartySize");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
if (compound.hasKey("MaxPartySize")) {
|
|
|
|
|
compound.removeTag("MaxPartySize");
|
|
|
|
|
}
|
|
|
|
|
if (compound.hasKey("ObjectiveRequirement")) {
|
2024-03-03 17:38:15 -05:00
|
|
|
compound.removeTag("ObjectiveRequirement");
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-04 05:15:50 -05:00
|
|
|
onlyParty = false;
|
2024-03-03 17:38:15 -05:00
|
|
|
partyRequirements = EnumPartyRequirements.Leader;
|
2025-03-12 20:12:01 -04:00
|
|
|
rewardControl = EnumPartyExchange.Leader;
|
|
|
|
|
completeFor = EnumPartyExchange.Leader;
|
2024-03-04 05:15:50 -05:00
|
|
|
executeCommand = EnumPartyExchange.Leader;
|
|
|
|
|
minPartySize = ConfigMain.DefaultMinPartySize;
|
2025-03-12 20:12:01 -04:00
|
|
|
maxPartySize = ConfigMain.DefaultMaxPartySize;
|
2024-03-03 20:27:24 -05:00
|
|
|
objectiveRequirement = EnumPartyObjectives.Shared;
|
2025-03-12 20:12:01 -04:00
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
|
|
|
|
|
public NBTTagCompound writeToNBT() {
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
compound.setBoolean("AllowParty", allowParty);
|
|
|
|
|
if (allowParty) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.setBoolean("OnlyParty", onlyParty);
|
2025-03-12 20:12:01 -04:00
|
|
|
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
|
|
|
|
|
compound.setInteger("RewardControl", rewardControl.ordinal());
|
|
|
|
|
compound.setInteger("CompleteFor", completeFor.ordinal());
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.setInteger("ExecuteCommand", executeCommand.ordinal());
|
|
|
|
|
compound.setInteger("MinPartySize", minPartySize);
|
2025-03-12 20:12:01 -04:00
|
|
|
compound.setInteger("MaxPartySize", maxPartySize);
|
2024-03-03 17:38:15 -05:00
|
|
|
compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal());
|
2025-03-12 20:12:01 -04:00
|
|
|
} else {
|
|
|
|
|
if (compound.hasKey("OnlyParty")) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.removeTag("OnlyParty");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
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")) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.removeTag("ExecuteCommand");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
if (compound.hasKey("MinPartySize")) {
|
2024-03-04 05:15:50 -05:00
|
|
|
compound.removeTag("MinPartySize");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
if (compound.hasKey("MaxPartySize")) {
|
|
|
|
|
compound.removeTag("MaxPartySize");
|
|
|
|
|
}
|
|
|
|
|
if (compound.hasKey("ObjectiveRequirement")) {
|
2024-03-03 17:38:15 -05:00
|
|
|
compound.removeTag("ObjectiveRequirement");
|
|
|
|
|
}
|
2025-03-12 20:12:01 -04:00
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
return compound;
|
2024-02-13 14:14:21 -06:00
|
|
|
}
|
|
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public boolean isAllowParty() {
|
|
|
|
|
return allowParty;
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void setAllowParty(boolean allowParty) {
|
|
|
|
|
this.allowParty = allowParty;
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-04 05:15:50 -05:00
|
|
|
@Override
|
|
|
|
|
public boolean isOnlyParty() {
|
|
|
|
|
return onlyParty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setOnlyParty(boolean onlyParty) {
|
|
|
|
|
this.onlyParty = onlyParty;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public int getPartyRequirements() {
|
|
|
|
|
return partyRequirements.ordinal();
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void setPartyRequirements(int partyReq) {
|
|
|
|
|
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public int getRewardControl() {
|
|
|
|
|
return rewardControl.ordinal();
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void setRewardControl(int rewardCon) {
|
|
|
|
|
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.rewardControl = EnumPartyExchange.values()[rewardCon];
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public int getCompleteFor() {
|
|
|
|
|
return completeFor.ordinal();
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-03 17:38:15 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void setCompleteFor(int compFor) {
|
|
|
|
|
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.completeFor = EnumPartyExchange.values()[compFor];
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2024-03-04 05:15:50 -05:00
|
|
|
@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();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-04 05:15:50 -05:00
|
|
|
@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];
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-04 05:15:50 -05:00
|
|
|
@Override
|
|
|
|
|
public int getMinPartySize() {
|
|
|
|
|
return minPartySize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setMinPartySize(int newSize) {
|
2025-03-12 20:12:01 -04:00
|
|
|
if (newSize < 1)
|
2024-03-04 05:15:50 -05:00
|
|
|
newSize = 1;
|
|
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
if (newSize > maxPartySize)
|
2024-03-04 05:15:50 -05:00
|
|
|
newSize = maxPartySize;
|
|
|
|
|
|
|
|
|
|
minPartySize = newSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public int getMaxPartySize() {
|
|
|
|
|
return maxPartySize;
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
@Override
|
|
|
|
|
public void setMaxPartySize(int newSize) {
|
|
|
|
|
if (newSize < minPartySize)
|
2024-03-04 05:15:50 -05:00
|
|
|
newSize = minPartySize;
|
|
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
maxPartySize = newSize;
|
|
|
|
|
}
|
2024-03-05 00:40:48 -05:00
|
|
|
|
|
|
|
|
public Vector<String> getPartyOptionsList() {
|
|
|
|
|
Vector<String> vec = new Vector<String>();
|
2025-03-12 20:12:01 -04:00
|
|
|
if (onlyParty) {
|
2024-03-05 00:40:48 -05:00
|
|
|
vec.add("party.only" + ":" + "gui.yes");
|
|
|
|
|
}
|
|
|
|
|
vec.add("party.partyRequirements" + ":" + partyRequirements.name);
|
|
|
|
|
vec.add("quest.objectives" + ":" + objectiveRequirement.name);
|
|
|
|
|
vec.add("party.completeFor" + ":" + completeFor.name);
|
|
|
|
|
vec.add("quest.reward" + ":" + rewardControl.name);
|
|
|
|
|
vec.add("party.minPartySize" + ":" + minPartySize);
|
|
|
|
|
vec.add("party.maxPartySize" + ":" + maxPartySize);
|
|
|
|
|
return vec;
|
|
|
|
|
}
|
2024-02-13 14:14:21 -06:00
|
|
|
}
|