mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-23 11:05:38 +01:00
Address duplicate delivery messages for complex stages, fixes #1383
This commit is contained in:
parent
b635532109
commit
1dea19f86d
@ -1980,7 +1980,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
List<Integer> npcIdsToTalkTo = new LinkedList<Integer>();
|
List<Integer> npcIdsToTalkTo = new LinkedList<Integer>();
|
||||||
List<ItemStack> itemsToDeliver= new LinkedList<ItemStack>();
|
List<ItemStack> itemsToDeliver= new LinkedList<ItemStack>();
|
||||||
List<Integer> itemDeliveryTargetIds = new LinkedList<Integer>();
|
List<Integer> itemDeliveryTargetIds = new LinkedList<Integer>();
|
||||||
final List<String> deliveryMessages = new LinkedList<String>();
|
List<String> deliveryMessages = new LinkedList<String>();
|
||||||
List<Integer> npcIdsToKill = new LinkedList<Integer>();
|
List<Integer> npcIdsToKill = new LinkedList<Integer>();
|
||||||
List<Integer> npcAmountsToKill = new LinkedList<Integer>();
|
List<Integer> npcAmountsToKill = new LinkedList<Integer>();
|
||||||
// Legacy Denizen script load
|
// Legacy Denizen script load
|
||||||
@ -2449,13 +2449,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
+ stageNum + ".items-to-deliver");
|
+ stageNum + ".items-to-deliver");
|
||||||
itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".npc-delivery-ids");
|
+ stageNum + ".npc-delivery-ids");
|
||||||
deliveryMessages.addAll(config.getStringList("quests." + questKey + ".stages.ordered."
|
deliveryMessages = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".delivery-messages"));
|
+ stageNum + ".delivery-messages");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (ConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
|
if (ConfigUtil.checkList(itemsToDeliver, ItemStack.class)) {
|
||||||
for (final ItemStack stack : itemsToDeliver) {
|
for (final ItemStack stack : itemsToDeliver) {
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
final int npcId = itemDeliveryTargetIds.get(index);
|
final int npcId = itemDeliveryTargetIds.get(index);
|
||||||
|
final String msg = deliveryMessages.size() > index
|
||||||
|
? deliveryMessages.get(index)
|
||||||
|
: deliveryMessages.get(deliveryMessages.size() - 1);
|
||||||
index++;
|
index++;
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
if (getDependencies().getCitizens() != null) {
|
if (getDependencies().getCitizens() != null) {
|
||||||
@ -2463,7 +2466,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
oStage.itemsToDeliver.add(stack);
|
oStage.itemsToDeliver.add(stack);
|
||||||
oStage.itemDeliveryTargets.add(npcId);
|
oStage.itemDeliveryTargets.add(npcId);
|
||||||
oStage.deliverMessages.addAll(deliveryMessages);
|
oStage.deliverMessages.add(msg);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException(
|
throw new StageFormatException(
|
||||||
"Citizens not found for npc-delivery-ids", quest, stageNum);
|
"Citizens not found for npc-delivery-ids", quest, stageNum);
|
||||||
@ -2479,14 +2482,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final List<String> items = config.getStringList("quests." + questKey + ".stages.ordered."
|
final List<String> items = config.getStringList("quests." + questKey
|
||||||
+ stageNum + ".items-to-deliver");
|
+ ".stages.ordered." + stageNum + ".items-to-deliver");
|
||||||
if (ConfigUtil.checkList(items, String.class)) {
|
if (ConfigUtil.checkList(items, String.class)) {
|
||||||
// Legacy
|
// Legacy
|
||||||
for (final String item : items) {
|
for (final String item : items) {
|
||||||
final ItemStack is = ItemUtil.readItemStack("" + item);
|
final ItemStack is = ItemUtil.readItemStack("" + item);
|
||||||
if (index <= itemDeliveryTargetIds.size()) {
|
if (index <= itemDeliveryTargetIds.size()) {
|
||||||
final int npcId = itemDeliveryTargetIds.get(index);
|
final int npcId = itemDeliveryTargetIds.get(index);
|
||||||
|
final String msg = deliveryMessages.size() > index
|
||||||
|
? deliveryMessages.get(index)
|
||||||
|
: deliveryMessages.get(deliveryMessages.size() - 1);
|
||||||
index++;
|
index++;
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
if (getDependencies().getCitizens() != null) {
|
if (getDependencies().getCitizens() != null) {
|
||||||
@ -2494,16 +2500,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
oStage.itemsToDeliver.add(is);
|
oStage.itemsToDeliver.add(is);
|
||||||
oStage.itemDeliveryTargets.add(npcId);
|
oStage.itemDeliveryTargets.add(npcId);
|
||||||
oStage.deliverMessages.addAll(deliveryMessages);
|
oStage.deliverMessages.add(msg);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException(
|
throw new StageFormatException(
|
||||||
"npc-delivery-ids has invalid NPC ID of " + npcId, quest,
|
"npc-delivery-ids has invalid NPC ID of " + npcId,
|
||||||
stageNum);
|
quest, stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException(
|
throw new StageFormatException(
|
||||||
"Citizens was not found installed for npc-delivery-ids", quest,
|
"Citizens was not found installed for npc-delivery-ids",
|
||||||
stageNum);
|
quest, stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-deliver has invalid formatting "
|
throw new StageFormatException("items-to-deliver has invalid formatting "
|
||||||
@ -2566,8 +2572,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-kill")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-kill")) {
|
||||||
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".mobs-to-kill"), String.class)) {
|
+ ".mobs-to-kill"), String.class)) {
|
||||||
final List<String> mobNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
final List<String> mobNames = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||||
+ ".mobs-to-kill");
|
+ stageNum + ".mobs-to-kill");
|
||||||
for (final String mob : mobNames) {
|
for (final String mob : mobNames) {
|
||||||
final EntityType type = MiscUtil.getProperMobType(mob);
|
final EntityType type = MiscUtil.getProperMobType(mob);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
@ -59,8 +59,8 @@ public class NpcListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) {
|
if (plugin.getQuestFactory().getSelectingNpcs().contains(evt.getClicker().getUniqueId())) {
|
||||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID "
|
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + " " + Lang.get("id") + ": "
|
||||||
+ evt.getNPC().getId());
|
+ ChatColor.DARK_GREEN + evt.getNPC().getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (evt.getClicker().isConversing() == false) {
|
if (evt.getClicker().isConversing() == false) {
|
||||||
@ -121,7 +121,6 @@ public class NpcListener implements Listener {
|
|||||||
.replace("<data>", "one item is null"));
|
.replace("<data>", "one item is null"));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// Should never happen
|
|
||||||
player.sendMessage(ChatColor.GRAY + Lang.get(player, "difference")
|
player.sendMessage(ChatColor.GRAY + Lang.get(player, "difference")
|
||||||
.replace("<data>", "ERROR"));
|
.replace("<data>", "ERROR"));
|
||||||
break;
|
break;
|
||||||
|
@ -749,7 +749,7 @@ noIdsSet: "No IDs set"
|
|||||||
noNamesSet: "No names set"
|
noNamesSet: "No names set"
|
||||||
worlds: "Worlds"
|
worlds: "Worlds"
|
||||||
points: "points"
|
points: "points"
|
||||||
npcHint: "Note: You can left or right click on NPCs to get their ID."
|
npcHint: "Note: You can click on NPCs to get their ID."
|
||||||
listsNotSameSize: "All required lists must have the same number of entries!"
|
listsNotSameSize: "All required lists must have the same number of entries!"
|
||||||
listDuplicate: "List contains duplicates!"
|
listDuplicate: "List contains duplicates!"
|
||||||
id: "ID"
|
id: "ID"
|
||||||
|
Loading…
Reference in New Issue
Block a user