mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 01:27:27 +00:00
Min/Max Party Size, Execute Command for, Lang Updates
This commit is contained in:
1 parent
6e59aa3a27
commit
64d8d00fad
7 files changed
+169
-41
No files matched your search
@@ -471,6 +471,7 @@ public class NoppesUtilPlayer {
|
||||
PartyOptions partyOptions = quest.partyOptions;
|
||||
EnumPartyExchange complete = partyOptions.completeFor;
|
||||
EnumPartyExchange reward = partyOptions.rewardControl;
|
||||
EnumPartyExchange command = partyOptions.executeCommand;
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer player = NoppesUtilServer.getPlayerByName(name);
|
||||
if(player == null)
|
||||
@@ -487,6 +488,7 @@ public class NoppesUtilPlayer {
|
||||
|
||||
boolean meetsComplete = meetsPartyExchange(complete, hasActiveQuest, hasFinishedQuest, isLeader);
|
||||
boolean meetsReward = meetsPartyExchange(reward, hasActiveQuest, hasFinishedQuest, isLeader);
|
||||
boolean meetsCommand = meetsPartyExchange(command, hasActiveQuest, hasFinishedQuest, isLeader);
|
||||
|
||||
if(meetsComplete){
|
||||
if (data.quest.completion == EnumQuestCompletion.Instant) {
|
||||
@@ -547,19 +549,22 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
if(meetsComplete){
|
||||
if(meetsCommand){
|
||||
if(!data.quest.command.isEmpty()){
|
||||
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
|
||||
}
|
||||
PlayerQuestController.setQuestPartyFinished(data.quest, player, data);
|
||||
}
|
||||
|
||||
if (data.quest.hasNewQuest()) {
|
||||
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
|
||||
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
|
||||
PlayerQuestController.addActiveQuest(nextQuest, player);
|
||||
// questData.trackQuest(nextQuest.quest);
|
||||
if(meetsComplete){
|
||||
PlayerQuestController.setQuestPartyFinished(data.quest, player, data);
|
||||
if (data.quest.hasNewQuest()) {
|
||||
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
|
||||
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
|
||||
PlayerQuestController.addActiveQuest(nextQuest, player);
|
||||
// questData.trackQuest(nextQuest.quest);
|
||||
}
|
||||
}
|
||||
|
||||
playerData.save();
|
||||
|
||||
if(meetsComplete){
|
||||
|
||||
@@ -24,42 +24,68 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int y = 0;
|
||||
//Allow party - T/F button
|
||||
addButton(new GuiNpcButton(0, guiLeft + 130, guiTop + 10, 60, 20,
|
||||
addButton(new GuiNpcButton(0, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
new String[]{"gui.no", "gui.yes"}, options.allowParty ? 1 : 0));
|
||||
addLabel(new GuiNpcLabel(1, "party.allowParty", guiLeft + 10, guiTop + 17));
|
||||
addLabel(new GuiNpcLabel(1, "party.allowParty", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
if (options.allowParty) {
|
||||
y += 23;
|
||||
//Only party - enum button
|
||||
addButton(new GuiNpcButton(24, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
new String[]{"gui.no", "gui.yes"}, options.onlyParty ? 1 : 0));
|
||||
addLabel(new GuiNpcLabel(24, "party.only", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
y += 23;
|
||||
//Party requirements - enum button
|
||||
addButton(new GuiNpcButton(5, guiLeft + 130, guiTop + 35, 60, 20,
|
||||
addButton(new GuiNpcButton(5, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
EnumPartyRequirements.values(), options.partyRequirements.ordinal()));
|
||||
addLabel(new GuiNpcLabel(6, "party.partyRequirements", guiLeft + 10, guiTop + 42));
|
||||
|
||||
//Party rewards - enum button
|
||||
addButton(new GuiNpcButton(10, guiLeft + 130, guiTop + 60, 60, 20,
|
||||
EnumPartyExchange.values(), options.rewardControl.ordinal()));
|
||||
addLabel(new GuiNpcLabel(11, "party.partyRewards", guiLeft + 10, guiTop + 67));
|
||||
|
||||
//Complete for - enum button
|
||||
addButton(new GuiNpcButton(15, guiLeft + 130, guiTop + 85, 60, 20,
|
||||
EnumPartyExchange.values(), options.completeFor.ordinal()));
|
||||
addLabel(new GuiNpcLabel(16, "party.completeFor", guiLeft + 10, guiTop + 92));
|
||||
addLabel(new GuiNpcLabel(6, "party.partyRequirements", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
y += 23;
|
||||
//Objective Requirement - enum button
|
||||
addButton(new GuiNpcButton(18, guiLeft + 130, guiTop + 110, 60, 20,
|
||||
addButton(new GuiNpcButton(18, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
EnumPartyObjectives.values(), options.objectiveRequirement.ordinal()));
|
||||
addLabel(new GuiNpcLabel(19, "party.objectiveRequirement", guiLeft + 10, guiTop + 117));
|
||||
addLabel(new GuiNpcLabel(19, "quest.objectives", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
y += 23;
|
||||
//Party rewards - enum button
|
||||
addButton(new GuiNpcButton(10, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
EnumPartyExchange.values(), options.rewardControl.ordinal()));
|
||||
addLabel(new GuiNpcLabel(11, "quest.reward", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
y += 23;
|
||||
//Complete for - enum button
|
||||
addButton(new GuiNpcButton(15, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
EnumPartyExchange.values(), options.completeFor.ordinal()));
|
||||
addLabel(new GuiNpcLabel(16, "party.completeFor", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
y += 23;
|
||||
//Commmand for - enum button
|
||||
addButton(new GuiNpcButton(25, guiLeft + 130, guiTop + 10 + y, 60, 20,
|
||||
EnumPartyExchange.values(), options.executeCommand.ordinal()));
|
||||
addLabel(new GuiNpcLabel(25, "party.commandFor", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
y += 23;
|
||||
//min party size - number field
|
||||
GuiNpcTextField minField = new GuiNpcTextField(21, this, guiLeft + 60, guiTop + 10 + y,
|
||||
30, 20, String.valueOf(options.minPartySize));
|
||||
minField.integersOnly = true;
|
||||
minField.setMinMaxDefault(1, Integer.MAX_VALUE, 1);
|
||||
addTextField(minField);
|
||||
addLabel(new GuiNpcLabel(21, "party.minPartySize", guiLeft + 10, guiTop + 17 + y));
|
||||
|
||||
//max party size - number field
|
||||
GuiNpcTextField textField = new GuiNpcTextField(20, this, guiLeft + 130, guiTop + 135,
|
||||
40, 20, String.valueOf(options.maxPartySize));
|
||||
textField.integersOnly = true;
|
||||
textField.setMinMaxDefault(1, Integer.MAX_VALUE, 4);
|
||||
addTextField(textField);
|
||||
addLabel(new GuiNpcLabel(20, "party.maxPartySize", guiLeft + 10, guiTop + 142));
|
||||
GuiNpcTextField maxField = new GuiNpcTextField(20, this, guiLeft + 160, guiTop + 10 + y,
|
||||
30, 20, String.valueOf(options.maxPartySize));
|
||||
maxField.integersOnly = true;
|
||||
maxField.setMinMaxDefault(1, Integer.MAX_VALUE, 4);
|
||||
addTextField(maxField);
|
||||
addLabel(new GuiNpcLabel(20, "party.maxPartySize", guiLeft + 110, guiTop + 17 + y));
|
||||
}
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 20, guiTop + 192, 90, 20, "gui.done"));
|
||||
addButton(new GuiNpcButton(66, guiLeft + 200, guiTop + 192, 50, 20, "gui.done"));
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
@@ -81,6 +107,12 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield
|
||||
case 18:
|
||||
options.objectiveRequirement = EnumPartyObjectives.valueOf(guibutton.displayString);
|
||||
break;
|
||||
case 24:
|
||||
options.onlyParty = !options.onlyParty;
|
||||
break;
|
||||
case 25:
|
||||
options.executeCommand = EnumPartyExchange.valueOf(guibutton.displayString);
|
||||
break;
|
||||
case 66:
|
||||
close();
|
||||
break;
|
||||
@@ -91,7 +123,12 @@ public class SubGuiNpcPartyOptions extends SubGuiInterface implements ITextfield
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if (textfield.id == 20) {
|
||||
options.maxPartySize = textfield.getInteger();
|
||||
options.setMaxPartySize(textfield.getInteger());
|
||||
initGui();
|
||||
}
|
||||
if (textfield.id == 21) {
|
||||
options.setMinPartySize(textfield.getInteger());
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,8 +66,10 @@ public class ConfigMain
|
||||
public static Property MarketDatFormatProperty;
|
||||
public static boolean MarketDatFormat = false;
|
||||
|
||||
public static Property DefaultMinPartySizeProperty;
|
||||
public static int DefaultMinPartySize = 1;
|
||||
|
||||
public static Property DefaultMaxPartySizetProperty;
|
||||
public static Property DefaultMaxPartySizeProperty;
|
||||
public static int DefaultMaxPartySize = 4;
|
||||
|
||||
/**
|
||||
@@ -159,8 +161,11 @@ public class ConfigMain
|
||||
MarketDatFormatProperty = config.get(GENERAL, "Dat Format for Market", false, "You need to use '/kamkeel config market' to convert existing market to new format.");
|
||||
MarketDatFormat = MarketDatFormatProperty.getBoolean(false);
|
||||
|
||||
DefaultMaxPartySizetProperty = config.get(GENERAL, "Default Max Party Size", 4, "When creating a new Quest sets the default max party size");
|
||||
DefaultMaxPartySize = DefaultMaxPartySizetProperty.getInt(4);
|
||||
DefaultMinPartySizeProperty = config.get(GENERAL, "Default Min Party Size", 1, "When creating a new Quest sets the default min party size");
|
||||
DefaultMinPartySize = DefaultMinPartySizeProperty.getInt(4);
|
||||
|
||||
DefaultMaxPartySizeProperty = config.get(GENERAL, "Default Max Party Size", 4, "When creating a new Quest sets the default max party size");
|
||||
DefaultMaxPartySize = DefaultMaxPartySizeProperty.getInt(4);
|
||||
|
||||
// NPC
|
||||
NpcNavRangeProperty = config.get(NPC, "NPC Navigation Range", 32, "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.");
|
||||
|
||||
@@ -230,6 +230,11 @@ public class Party {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (partyMembers.size() < quest.getPartyOptions().getMinPartySize()) {
|
||||
sendInfoMessage(leader, String.format("Party too small. Min %d members", quest.getPartyOptions().getMaxPartySize()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (partyMembers.size() > quest.getPartyOptions().getMaxPartySize()) {
|
||||
sendInfoMessage(leader, String.format("Party too large. Max %d members", quest.getPartyOptions().getMaxPartySize()));
|
||||
return false;
|
||||
|
||||
@@ -9,13 +9,17 @@ import noppes.npcs.constants.EnumPartyRequirements;
|
||||
|
||||
public class PartyOptions implements IPartyOptions {
|
||||
public boolean allowParty = false;
|
||||
public boolean onlyParty = false;
|
||||
|
||||
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
|
||||
|
||||
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
|
||||
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
|
||||
public EnumPartyExchange executeCommand = EnumPartyExchange.Leader;
|
||||
|
||||
public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared;
|
||||
|
||||
public int minPartySize = ConfigMain.DefaultMinPartySize;
|
||||
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
@@ -23,13 +27,19 @@ public class PartyOptions implements IPartyOptions {
|
||||
// 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");
|
||||
objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")];
|
||||
}
|
||||
else {
|
||||
if(compound.hasKey("OnlyParty")){
|
||||
compound.removeTag("OnlyParty");
|
||||
}
|
||||
if(compound.hasKey("PartyRequirements")){
|
||||
compound.removeTag("PartyRequirements");
|
||||
}
|
||||
@@ -39,6 +49,12 @@ public class PartyOptions implements IPartyOptions {
|
||||
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");
|
||||
}
|
||||
@@ -46,9 +62,12 @@ public class PartyOptions implements IPartyOptions {
|
||||
compound.removeTag("ObjectiveRequirement");
|
||||
}
|
||||
|
||||
onlyParty = false;
|
||||
partyRequirements = EnumPartyRequirements.Leader;
|
||||
rewardControl = EnumPartyExchange.Leader;
|
||||
completeFor = EnumPartyExchange.Leader;
|
||||
executeCommand = EnumPartyExchange.Leader;
|
||||
minPartySize = ConfigMain.DefaultMinPartySize;
|
||||
maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
objectiveRequirement = EnumPartyObjectives.Shared;
|
||||
}
|
||||
@@ -58,13 +77,19 @@ public class PartyOptions implements IPartyOptions {
|
||||
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);
|
||||
compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal());
|
||||
}
|
||||
else {
|
||||
if(compound.hasKey("OnlyParty")){
|
||||
compound.removeTag("OnlyParty");
|
||||
}
|
||||
if(compound.hasKey("PartyRequirements")){
|
||||
compound.removeTag("PartyRequirements");
|
||||
}
|
||||
@@ -74,6 +99,12 @@ public class PartyOptions implements IPartyOptions {
|
||||
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");
|
||||
}
|
||||
@@ -95,6 +126,16 @@ public class PartyOptions implements IPartyOptions {
|
||||
this.allowParty = allowParty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyParty() {
|
||||
return onlyParty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnlyParty(boolean onlyParty) {
|
||||
this.onlyParty = onlyParty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartyRequirements() {
|
||||
return partyRequirements.ordinal();
|
||||
@@ -134,10 +175,25 @@ public class PartyOptions implements IPartyOptions {
|
||||
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
|
||||
public int getObjectiveRequirement() {
|
||||
return objectiveRequirement.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObjectiveRequirement(int requirement) {
|
||||
if (requirement < 0 || requirement >= EnumPartyObjectives.values().length) {
|
||||
return;
|
||||
@@ -145,13 +201,32 @@ public class PartyOptions implements IPartyOptions {
|
||||
this.objectiveRequirement = EnumPartyObjectives.values()[requirement];
|
||||
}
|
||||
|
||||
@Override
|
||||
@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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user