mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 21:59:05 +00:00
Moved quest party options to a party options class.
Added a blank subgui for editing a quest's party options.
This commit is contained in:
1 parent
5e5e212c9a
commit
cdb34f4624
8 files changed
+192
-115
No files matched your search
@@ -193,7 +193,7 @@ public class PacketHandlerServer{
|
||||
String questName = Server.readString(buffer);
|
||||
party.setQuest(null);
|
||||
for (Quest quest : QuestController.Instance.quests.values()) {
|
||||
if (quest.allowParty && quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
|
||||
if (quest.partyOptions.allowParty && quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
|
||||
party.setQuest(quest);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class QuestLogData {
|
||||
}
|
||||
}
|
||||
|
||||
if (quest.allowParty) {
|
||||
if (quest.partyOptions.allowParty) {
|
||||
partyAbleQuests.add(category + ":" + quest.title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.FactionOptions;
|
||||
import noppes.npcs.controllers.data.PartyOptions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
public class SubGuiNpcPartyOptions extends SubGuiInterface
|
||||
{
|
||||
private final PartyOptions options;
|
||||
private HashMap<String,Integer> data = new HashMap<>();
|
||||
|
||||
public SubGuiNpcPartyOptions(PartyOptions options)
|
||||
{
|
||||
this.options = options;
|
||||
setBackground("menubg.png");
|
||||
xSize = 256;
|
||||
ySize = 216;
|
||||
closeOnEsc = true;
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done"));
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
|
||||
if(id == 66)
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.controllers.data.PlayerMail;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestCategory;
|
||||
|
||||
public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener, GuiSelectionListener,ITextfieldListener
|
||||
{
|
||||
@@ -64,6 +63,9 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
|
||||
addButton(new GuiNpcButton(6, guiLeft + 240, guiTop + 76, 60, 20, new String[]{"quest.item","quest.dialog","quest.kill","quest.location","quest.areakill"},quest.type.ordinal()));
|
||||
addButton(new GuiNpcButton(7, guiLeft + 303, guiTop + 76,50, 20, "selectServer.edit"));
|
||||
|
||||
addLabel(new GuiNpcLabel(17, "party.options", guiLeft + 180, guiTop + 105));
|
||||
addButton(new GuiNpcButton(18, guiLeft + 303, guiTop + 100, 50, 20, "selectServer.edit"));
|
||||
|
||||
this.addButton(new GuiNpcButton(9, guiLeft + 7, guiTop + 102,90, 20, new String[]{"quest.npc","quest.instant"},quest.completion.ordinal()));
|
||||
if(quest.completerNpc.isEmpty() && npc != null)
|
||||
quest.completerNpc = npc.display.name;
|
||||
@@ -156,6 +158,10 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
|
||||
questSelection.listener = this;
|
||||
NoppesUtil.openGUI(player, questSelection);
|
||||
}
|
||||
if(button.id == 18)
|
||||
{
|
||||
setSubGui(new SubGuiNpcPartyOptions(quest.partyOptions));
|
||||
}
|
||||
if(button.id == 16){
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -194,14 +194,14 @@ public class Party {
|
||||
return false;
|
||||
}
|
||||
|
||||
int partyReq = quest.getPartyRequirements();
|
||||
int partyReq = quest.getPartyOptions().getPartyRequirements();
|
||||
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
|
||||
sendInfoMessage(leader, "Error in quest party requirements");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (partyMembers.size() > quest.getMaxPartySize()) {
|
||||
sendInfoMessage(leader, String.format("Party too large. Max %d members", quest.getMaxPartySize()));
|
||||
if (partyMembers.size() > quest.getPartyOptions().getMaxPartySize()) {
|
||||
sendInfoMessage(leader, String.format("Party too large. Max %d members", quest.getPartyOptions().getMaxPartySize()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import noppes.npcs.api.handler.data.IPartyOptions;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumPartyExchange;
|
||||
import noppes.npcs.constants.EnumPartyRequirements;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
|
||||
public class PartyOptions implements IPartyOptions {
|
||||
|
||||
public boolean allowParty = false;
|
||||
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
|
||||
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
|
||||
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
|
||||
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
// Party Management
|
||||
allowParty = compound.getBoolean("AllowParty");
|
||||
if(allowParty){
|
||||
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
|
||||
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
|
||||
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
|
||||
maxPartySize = compound.getInteger("MaxPartySize");
|
||||
}
|
||||
else {
|
||||
if(compound.hasKey("PartyRequirements")){
|
||||
compound.removeTag("PartyRequirements");
|
||||
}
|
||||
if(compound.hasKey("RewardControl")){
|
||||
compound.removeTag("RewardControl");
|
||||
}
|
||||
if(compound.hasKey("CompleteFor")){
|
||||
compound.removeTag("CompleteFor");
|
||||
}
|
||||
if(compound.hasKey("MaxPartySize")){
|
||||
compound.removeTag("MaxPartySize");
|
||||
}
|
||||
|
||||
partyRequirements = EnumPartyRequirements.Leader;
|
||||
rewardControl = EnumPartyExchange.Leader;
|
||||
completeFor = EnumPartyExchange.Leader;
|
||||
maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
}
|
||||
}
|
||||
public NBTTagCompound writeToNBT()
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("AllowParty", allowParty);
|
||||
if(allowParty){
|
||||
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
|
||||
compound.setInteger("RewardControl", rewardControl.ordinal());
|
||||
compound.setInteger("CompleteFor", completeFor.ordinal());
|
||||
compound.setInteger("MaxPartySize", maxPartySize);
|
||||
}
|
||||
else {
|
||||
if(compound.hasKey("PartyRequirements")){
|
||||
compound.removeTag("PartyRequirements");
|
||||
}
|
||||
if(compound.hasKey("RewardControl")){
|
||||
compound.removeTag("RewardControl");
|
||||
}
|
||||
if(compound.hasKey("CompleteFor")){
|
||||
compound.removeTag("CompleteFor");
|
||||
}
|
||||
if(compound.hasKey("MaxPartySize")){
|
||||
compound.removeTag("MaxPartySize");
|
||||
}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public boolean isAllowParty() {
|
||||
return allowParty;
|
||||
}
|
||||
|
||||
public void setAllowParty(boolean allowParty) {
|
||||
this.allowParty = allowParty;
|
||||
}
|
||||
|
||||
public int getPartyRequirements() {
|
||||
return partyRequirements.ordinal();
|
||||
}
|
||||
|
||||
public void setPartyRequirements(int partyReq) {
|
||||
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
|
||||
return;
|
||||
}
|
||||
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
|
||||
}
|
||||
|
||||
public int getRewardControl() {
|
||||
return rewardControl.ordinal();
|
||||
}
|
||||
|
||||
public void setRewardControl(int rewardCon) {
|
||||
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
|
||||
return;
|
||||
}
|
||||
this.rewardControl = EnumPartyExchange.values()[rewardCon];
|
||||
}
|
||||
|
||||
public int getCompleteFor() {
|
||||
return completeFor.ordinal();
|
||||
}
|
||||
|
||||
public void setCompleteFor(int compFor) {
|
||||
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
|
||||
return;
|
||||
}
|
||||
this.completeFor = EnumPartyExchange.values()[compFor];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPartySize() {
|
||||
return maxPartySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPartySize(int newSize) {
|
||||
maxPartySize = newSize;
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.IContainer;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.api.handler.data.IQuestCategory;
|
||||
import noppes.npcs.api.handler.data.IQuestInterface;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.api.handler.data.*;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
@@ -33,12 +30,6 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
public String nextQuestTitle = "";
|
||||
public PlayerMail mail = new PlayerMail();
|
||||
public String command = "";
|
||||
|
||||
public boolean allowParty = false;
|
||||
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
|
||||
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
|
||||
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
|
||||
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
|
||||
public QuestInterface questInterface = new QuestItem();
|
||||
|
||||
@@ -46,6 +37,7 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
public NpcMiscInventory rewardItems = new NpcMiscInventory(9);
|
||||
public boolean randomReward = false;
|
||||
public FactionOptions factionOptions = new FactionOptions();
|
||||
public PartyOptions partyOptions = new PartyOptions();
|
||||
|
||||
|
||||
public void readNBT(NBTTagCompound compound) {
|
||||
@@ -78,36 +70,9 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
questInterface.readEntityFromNBT(compound);
|
||||
|
||||
factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints"));
|
||||
partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions"));
|
||||
|
||||
mail.readNBT(compound.getCompoundTag("QuestMail"));
|
||||
|
||||
// Party Management
|
||||
allowParty = compound.getBoolean("AllowParty");
|
||||
if(allowParty){
|
||||
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
|
||||
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
|
||||
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
|
||||
maxPartySize = compound.getInteger("MaxPartySize");
|
||||
}
|
||||
else {
|
||||
if(compound.hasKey("PartyRequirements")){
|
||||
compound.removeTag("PartyRequirements");
|
||||
}
|
||||
if(compound.hasKey("RewardControl")){
|
||||
compound.removeTag("RewardControl");
|
||||
}
|
||||
if(compound.hasKey("CompleteFor")){
|
||||
compound.removeTag("CompleteFor");
|
||||
}
|
||||
if(compound.hasKey("MaxPartySize")){
|
||||
compound.removeTag("MaxPartySize");
|
||||
}
|
||||
|
||||
partyRequirements = EnumPartyRequirements.Leader;
|
||||
rewardControl = EnumPartyExchange.Leader;
|
||||
completeFor = EnumPartyExchange.Leader;
|
||||
maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(EnumQuestType questType) {
|
||||
@@ -148,29 +113,9 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
|
||||
this.questInterface.writeEntityToNBT(compound);
|
||||
compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound()));
|
||||
compound.setTag("PartyOptions", partyOptions.writeToNBT());
|
||||
compound.setTag("QuestMail", mail.writeNBT());
|
||||
|
||||
compound.setBoolean("AllowParty", allowParty);
|
||||
if(allowParty){
|
||||
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
|
||||
compound.setInteger("RewardControl", rewardControl.ordinal());
|
||||
compound.setInteger("CompleteFor", completeFor.ordinal());
|
||||
compound.setInteger("MaxPartySize", maxPartySize);
|
||||
}
|
||||
else {
|
||||
if(compound.hasKey("PartyRequirements")){
|
||||
compound.removeTag("PartyRequirements");
|
||||
}
|
||||
if(compound.hasKey("RewardControl")){
|
||||
compound.removeTag("RewardControl");
|
||||
}
|
||||
if(compound.hasKey("CompleteFor")){
|
||||
compound.removeTag("CompleteFor");
|
||||
}
|
||||
if(compound.hasKey("MaxPartySize")){
|
||||
compound.removeTag("MaxPartySize");
|
||||
}
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -327,54 +272,7 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
return this.questInterface;
|
||||
}
|
||||
|
||||
public boolean isAllowParty() {
|
||||
return allowParty;
|
||||
}
|
||||
|
||||
public void setAllowParty(boolean allowParty) {
|
||||
this.allowParty = allowParty;
|
||||
}
|
||||
|
||||
public int getPartyRequirements() {
|
||||
return partyRequirements.ordinal();
|
||||
}
|
||||
|
||||
public void setPartyRequirements(int partyReq) {
|
||||
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
|
||||
return;
|
||||
}
|
||||
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
|
||||
}
|
||||
|
||||
public int getRewardControl() {
|
||||
return rewardControl.ordinal();
|
||||
}
|
||||
|
||||
public void setRewardControl(int rewardCon) {
|
||||
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
|
||||
return;
|
||||
}
|
||||
this.rewardControl = EnumPartyExchange.values()[rewardCon];
|
||||
}
|
||||
|
||||
public int getCompleteFor() {
|
||||
return completeFor.ordinal();
|
||||
}
|
||||
|
||||
public void setCompleteFor(int compFor) {
|
||||
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
|
||||
return;
|
||||
}
|
||||
this.completeFor = EnumPartyExchange.values()[compFor];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPartySize() {
|
||||
return maxPartySize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxPartySize(int newSize) {
|
||||
maxPartySize = newSize;
|
||||
public IPartyOptions getPartyOptions() {
|
||||
return this.partyOptions;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user