Correct share progress level 2

This commit is contained in:
PikaMug 2019-09-11 01:49:23 -04:00
parent 8f147aed46
commit 0d0cd1e27c
2 changed files with 277 additions and 22 deletions

View File

@ -15,6 +15,7 @@ package me.blackvein.quests;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -218,6 +219,18 @@ public abstract class CustomObjective implements Listener {
if (index > -1) { if (index > -1) {
if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= quester.getCurrentStage(quest).customObjectiveCounts.get(index)) { if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= quester.getCurrentStage(quest).customObjectiveCounts.get(index)) {
quester.finishObjective(quest, "customObj", null, null, null, null, null, null, null, null, null, obj); quester.finishObjective(quest, "customObj", null, null, null, null, null, null, null, null, null, obj);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = quester.getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "customObj", null, null, null, null, null, null, null, null, null, obj);
}
}
}
}
} }
} }
} }

View File

@ -1075,6 +1075,18 @@ public class Quester {
getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(broken), newBroken); getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(broken), newBroken);
if (broken.getAmount() == toBreak.getAmount()) { if (broken.getAmount() == toBreak.getAmount()) {
finishObjective(quest, "breakBlock", m, toBreak, null, null, null, null, null, null, null, null); finishObjective(quest, "breakBlock", m, toBreak, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "breakBlock", m, toBreak, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1131,6 +1143,18 @@ public class Quester {
getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged); getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged);
if (damaged.getAmount() == toDamage.getAmount()) { if (damaged.getAmount() == toDamage.getAmount()) {
finishObjective(quest, "damageBlock", m, toDamage, null, null, null, null, null, null, null, null); finishObjective(quest, "damageBlock", m, toDamage, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "damageBlock", m, toDamage, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1187,6 +1211,18 @@ public class Quester {
getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(placed), newplaced); getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(placed), newplaced);
if (placed.getAmount() == toPlace.getAmount()) { if (placed.getAmount() == toPlace.getAmount()) {
finishObjective(quest, "placeBlock", m, toPlace, null, null, null, null, null, null, null, null); finishObjective(quest, "placeBlock", m, toPlace, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "placeBlock", m, toPlace, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1243,6 +1279,18 @@ public class Quester {
getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(used), newUsed); getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(used), newUsed);
if (used.getAmount() == toUse.getAmount()) { if (used.getAmount() == toUse.getAmount()) {
finishObjective(quest, "useBlock", m, toUse, null, null, null, null, null, null, null, null); finishObjective(quest, "useBlock", m, toUse, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "useBlock", m, toUse, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1299,6 +1347,18 @@ public class Quester {
getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(cut), newCut); getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(cut), newCut);
if (cut.getAmount() == toCut.getAmount()) { if (cut.getAmount() == toCut.getAmount()) {
finishObjective(quest, "cutBlock", m, toCut, null, null, null, null, null, null, null, null); finishObjective(quest, "cutBlock", m, toCut, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "cutBlock", m, toCut, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1334,6 +1394,18 @@ public class Quester {
if ((i.getAmount() + amount) >= req) { if ((i.getAmount() + amount) >= req) {
getQuestData(quest).itemsCrafted.put(found, req); getQuestData(quest).itemsCrafted.put(found, req);
finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else { } else {
getQuestData(quest).itemsCrafted.put(found, (amount + i.getAmount())); getQuestData(quest).itemsCrafted.put(found, (amount + i.getAmount()));
} }
@ -1371,6 +1443,18 @@ public class Quester {
if ((i.getAmount() + amount) >= req) { if ((i.getAmount() + amount) >= req) {
getQuestData(quest).itemsSmelted.put(found, req); getQuestData(quest).itemsSmelted.put(found, req);
finishObjective(quest, "smeltItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "smeltItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "smeltItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else { } else {
getQuestData(quest).itemsSmelted.put(found, (amount + i.getAmount())); getQuestData(quest).itemsSmelted.put(found, (amount + i.getAmount()));
} }
@ -1395,6 +1479,18 @@ public class Quester {
getQuestData(quest).itemsEnchanted.put(entry.getKey(), num); getQuestData(quest).itemsEnchanted.put(entry.getKey(), num);
if (num.equals(entry2.getValue())) { if (num.equals(entry2.getValue())) {
finishObjective(quest, "enchantItem", new ItemStack(m, 1), null, e, null, null, null, null, null, null, null); finishObjective(quest, "enchantItem", new ItemStack(m, 1), null, e, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "enchantItem", new ItemStack(m, 1), null, e, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
break; break;
@ -1435,6 +1531,18 @@ public class Quester {
if ((i.getAmount() + amount) >= req) { if ((i.getAmount() + amount) >= req) {
getQuestData(quest).itemsBrewed.put(found, req); getQuestData(quest).itemsBrewed.put(found, req);
finishObjective(quest, "brewItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "brewItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "brewItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else { } else {
getQuestData(quest).itemsBrewed.put(found, (amount + i.getAmount())); getQuestData(quest).itemsBrewed.put(found, (amount + i.getAmount()));
} }
@ -1452,6 +1560,18 @@ public class Quester {
getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1); getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1);
if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) { if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) {
finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null); finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1498,6 +1618,18 @@ public class Quester {
questData.mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled); questData.mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled);
if ((newNumberOfSpecificMobKilled).equals(numberOfSpecificMobNeedsToBeKilledInCurrentStage)) { if ((newNumberOfSpecificMobKilled).equals(numberOfSpecificMobNeedsToBeKilledInCurrentStage)) {
finishObjective(quest, "killMob", null, null, null, e, null, null, null, null, null, null); finishObjective(quest, "killMob", null, null, null, e, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "killMob", null, null, null, e, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1513,6 +1645,18 @@ public class Quester {
getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled() + 1); getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled() + 1);
if (((Integer) getQuestData(quest).getPlayersKilled()).equals(getCurrentStage(quest).playersToKill)) { if (((Integer) getQuestData(quest).getPlayersKilled()).equals(getCurrentStage(quest).playersToKill)) {
finishObjective(quest, "killPlayer", null, null, null, null, null, null, null, null, null, null); finishObjective(quest, "killPlayer", null, null, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "killPlayer", null, null, null, null, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1560,11 +1704,35 @@ public class Quester {
player.getInventory().setItem(index, i); player.getInventory().setItem(index, i);
player.updateInventory(); player.updateInventory();
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else if ((i.getAmount() + amount) == req) { } else if ((i.getAmount() + amount) == req) {
getQuestData(quest).itemsDelivered.put(found, req); getQuestData(quest).itemsDelivered.put(found, req);
player.getInventory().setItem(index, null); player.getInventory().setItem(index, null);
player.updateInventory(); player.updateInventory();
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else { } else {
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount())); getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
player.getInventory().setItem(index, null); player.getInventory().setItem(index, null);
@ -1614,11 +1782,35 @@ public class Quester {
player.getInventory().setItem(index, i); player.getInventory().setItem(index, i);
player.updateInventory(); player.updateInventory();
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else if ((i.getAmount() + amount) == req) { } else if ((i.getAmount() + amount) == req) {
getQuestData(quest).itemsDelivered.put(found, req); getQuestData(quest).itemsDelivered.put(found, req);
player.getInventory().setItem(player.getInventory().first(i), null); player.getInventory().setItem(player.getInventory().first(i), null);
player.updateInventory(); player.updateInventory();
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
}
}
}
}
} else { } else {
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount())); getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
player.getInventory().setItem(player.getInventory().first(i), null); player.getInventory().setItem(player.getInventory().first(i), null);
@ -1644,6 +1836,18 @@ public class Quester {
if (b != null && !b) { if (b != null && !b) {
getQuestData(quest).citizensInteracted.put(n.getId(), true); getQuestData(quest).citizensInteracted.put(n.getId(), true);
finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null); finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1661,6 +1865,18 @@ public class Quester {
getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index) + 1); getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index) + 1);
if (getQuestData(quest).citizenNumKilled.get(index) == getCurrentStage(quest).citizenNumToKill.get(index)) { if (getQuestData(quest).citizenNumKilled.get(index) == getCurrentStage(quest).citizenNumToKill.get(index)) {
finishObjective(quest, "killNPC", null, null, null, null, null, n, null, null, null, null); finishObjective(quest, "killNPC", null, null, null, null, null, n, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "killNPC", null, null, null, null, null, n, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1698,6 +1914,18 @@ public class Quester {
getQuestData(quest).hasReached.set(index, true); getQuestData(quest).hasReached.set(index, true);
} }
finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null); finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null);
}
}
}
}
} }
} }
} }
@ -1726,6 +1954,18 @@ public class Quester {
getQuestData(quest).mobsTamed.put(entity, (getQuestData(quest).mobsTamed.get(entity) + 1)); getQuestData(quest).mobsTamed.put(entity, (getQuestData(quest).mobsTamed.get(entity) + 1));
if (getQuestData(quest).mobsTamed.get(entity).equals(getCurrentStage(quest).mobsToTame.get(entity))) { if (getQuestData(quest).mobsTamed.get(entity).equals(getCurrentStage(quest).mobsToTame.get(entity))) {
finishObjective(quest, "tameMob", null, null, null, entity, null, null, null, null, null, null); finishObjective(quest, "tameMob", null, null, null, entity, null, null, null, null, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "tameMob", null, null, null, entity, null, null, null, null, null, null);
}
}
}
}
} }
} }
} }
@ -1741,6 +1981,18 @@ public class Quester {
getQuestData(quest).sheepSheared.put(color, (getQuestData(quest).sheepSheared.get(color) + 1)); getQuestData(quest).sheepSheared.put(color, (getQuestData(quest).sheepSheared.get(color) + 1));
if (getQuestData(quest).sheepSheared.get(color).equals(getCurrentStage(quest).sheepToShear.get(color))) { if (getQuestData(quest).sheepSheared.get(color).equals(getCurrentStage(quest).sheepToShear.get(color))) {
finishObjective(quest, "shearSheep", null, null, null, null, null, null, null, color, null, null); finishObjective(quest, "shearSheep", null, null, null, null, null, null, null, color, null, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "shearSheep", null, null, null, null, null, null, null, color, null, null);
}
}
}
}
} }
} }
} }
@ -1766,6 +2018,18 @@ public class Quester {
@Override @Override
public void run() { public void run() {
finishObjective(quest, "password", null, null, null, null, null, null, null, null, display, null); finishObjective(quest, "password", null, null, null, null, null, null, null, null, display, null);
// Multiplayer
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
if (mq != null) {
for (Quester q : mq) {
if (q.getCurrentQuests().containsKey(quest)) {
q.finishObjective(quest, "password", null, null, null, null, null, null, null, null, display, null);
}
}
}
}
} }
}); });
break; break;
@ -1975,31 +2239,9 @@ public class Quester {
} }
p.sendMessage(message); p.sendMessage(message);
} }
Stage currentStage = getCurrentStage(quest);
if (testComplete(quest)) { if (testComplete(quest)) {
quest.nextStage(this, true); quest.nextStage(this, true);
} }
// Multiplayer
/* wip new method
if (true && quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(this);
for (Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(quest))) {
completeQuest(qq);
}
}
}
*/
/* old method
if (quest.getOptions().getShareProgressLevel() == 2) {
List<Quester> mq = getMultiplayerQuestersByQuest(quest);
for (Quester q : mq) {
if (q.getCurrentStage(quest).equals(this.getCurrentStage(quest))) {
quest.nextStage(q, false);
}
}
}*/
} }
/** /**