mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-28 21:56:28 +01:00
Merge pull request #940 from PikaMug/untested_v2
Majorly improve party functionality by @AlessioDP
This commit is contained in:
commit
73775e8e42
11
main/pom.xml
11
main/pom.xml
@ -14,10 +14,15 @@
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<!-- Parties, GPS, PhatLoots, CitizensBooks, mcMMO Classic -->
|
||||
<!-- GPS, PhatLoots, CitizensBooks, mcMMO Classic -->
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- Parties repo -->
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
@ -118,9 +123,9 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.AlessioDP.Parties</groupId>
|
||||
<groupId>com.alessiodp.parties</groupId>
|
||||
<artifactId>parties-api</artifactId>
|
||||
<version>2.4.6</version>
|
||||
<version>2.6.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -18,8 +18,10 @@ import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class CustomObjective implements Listener {
|
||||
|
||||
@ -112,8 +114,6 @@ public abstract class CustomObjective implements Listener {
|
||||
|
||||
/**
|
||||
* Check whether to let user set required amount for objective
|
||||
*
|
||||
* @param enableCount
|
||||
*/
|
||||
public boolean canShowCount() {
|
||||
return showCount;
|
||||
@ -122,7 +122,7 @@ public abstract class CustomObjective implements Listener {
|
||||
/**
|
||||
* Set whether to let user set required amount for objective
|
||||
*
|
||||
* @param enableCount
|
||||
* @param showCount
|
||||
*/
|
||||
public void setShowCount(boolean showCount) {
|
||||
this.showCount = showCount;
|
||||
@ -216,8 +216,16 @@ public abstract class CustomObjective implements Listener {
|
||||
}
|
||||
}
|
||||
if (index > -1) {
|
||||
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);
|
||||
int goal = quester.getCurrentStage(quest).customObjectiveCounts.get(index);
|
||||
if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= goal) {
|
||||
quester.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj);
|
||||
|
||||
// Multiplayer
|
||||
quester.dispatchMultiplayerObjectives(quest, quester.getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).customObjectiveCounts.put(obj.getName(), quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()));
|
||||
q.finishObjective(quest, "customObj", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, goal), null, null, null, null, null, null, null, obj);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class Options {
|
||||
private boolean useDungeonsXLPlugin = false;
|
||||
private boolean usePartiesPlugin = true;
|
||||
private int shareProgressLevel = 1;
|
||||
private boolean requireSameQuest = true;
|
||||
|
||||
public boolean getAllowCommands() {
|
||||
return allowCommands;
|
||||
@ -58,4 +59,12 @@ public class Options {
|
||||
public void setShareProgressLevel(int shareProgressLevel) {
|
||||
this.shareProgressLevel = shareProgressLevel;
|
||||
}
|
||||
|
||||
public boolean getRequireSameQuest() {
|
||||
return requireSameQuest;
|
||||
}
|
||||
|
||||
public void setRequireSameQuest(boolean requireSameQuest) {
|
||||
this.requireSameQuest = requireSameQuest;
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
public class Quest {
|
||||
|
||||
protected Quests plugin;
|
||||
protected String id;
|
||||
private String name;
|
||||
protected String description;
|
||||
protected String finished;
|
||||
@ -63,20 +64,8 @@ public class Quest {
|
||||
private Rewards rews = new Rewards();
|
||||
private Options opts = new Options();
|
||||
|
||||
public Requirements getRequirements() {
|
||||
return reqs;
|
||||
}
|
||||
|
||||
public Planner getPlanner() {
|
||||
return pln;
|
||||
}
|
||||
|
||||
public Rewards getRewards() {
|
||||
return rews;
|
||||
}
|
||||
|
||||
public Options getOptions() {
|
||||
return opts;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -155,60 +144,86 @@ public class Quest {
|
||||
this.initialAction = initialAction;
|
||||
}
|
||||
|
||||
public Requirements getRequirements() {
|
||||
return reqs;
|
||||
}
|
||||
|
||||
public Planner getPlanner() {
|
||||
return pln;
|
||||
}
|
||||
|
||||
public Rewards getRewards() {
|
||||
return rews;
|
||||
}
|
||||
|
||||
public Options getOptions() {
|
||||
return opts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force player to proceed to the next ordered stage
|
||||
*
|
||||
* @param q Player to force
|
||||
* @param quester Player to force
|
||||
* @deprecated Use nextStage(Quester, boolean)
|
||||
*/
|
||||
public void nextStage(Quester q) {
|
||||
if (q.getCurrentStage(this) == null) {
|
||||
plugin.getLogger().severe("Current stage was null for quester " + q.getPlayer().getUniqueId());
|
||||
public void nextStage(Quester quester) {
|
||||
nextStage(quester, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force player to proceed to the next ordered stage
|
||||
*
|
||||
* @param quester Player to force
|
||||
* @param allowSharedProgress Whether to distribute progress to fellow questers
|
||||
*/
|
||||
public void nextStage(Quester quester, boolean allowSharedProgress) {
|
||||
Stage currentStage = quester.getCurrentStage(this);
|
||||
if (currentStage == null) {
|
||||
plugin.getLogger().severe("Current stage was null for quester " + quester.getPlayer().getUniqueId());
|
||||
return;
|
||||
}
|
||||
String stageCompleteMessage = q.getCurrentStage(this).completeMessage;
|
||||
String stageCompleteMessage = currentStage.completeMessage;
|
||||
if (stageCompleteMessage != null) {
|
||||
q.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, this, q.getPlayer()));
|
||||
quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, this, quester.getPlayer()));
|
||||
}
|
||||
if (plugin.getSettings().canUseCompass()) {
|
||||
q.resetCompass();
|
||||
q.findCompassTarget();
|
||||
quester.resetCompass();
|
||||
quester.findCompassTarget();
|
||||
}
|
||||
if (q.getCurrentStage(this).delay < 0) {
|
||||
if (q.getCurrentStage(this).finishEvent != null) {
|
||||
q.getCurrentStage(this).finishEvent.fire(q, this);
|
||||
if (currentStage.delay < 0) {
|
||||
if (currentStage.finishEvent != null) {
|
||||
currentStage.finishEvent.fire(quester, this);
|
||||
}
|
||||
if (q.currentQuests.get(this) == (orderedStages.size() - 1)) {
|
||||
if (q.getCurrentStage(this).script != null) {
|
||||
plugin.getDenizenTrigger().runDenizenScript(q.getCurrentStage(this).script, q);
|
||||
if (quester.currentQuests.get(this) == (orderedStages.size() - 1)) {
|
||||
if (currentStage.script != null) {
|
||||
plugin.getDenizenTrigger().runDenizenScript(currentStage.script, quester);
|
||||
}
|
||||
completeQuest(q);
|
||||
completeQuest(quester);
|
||||
} else {
|
||||
try {
|
||||
setStage(q, q.currentQuests.get(this) + 1);
|
||||
|
||||
// Multiplayer
|
||||
if (opts.getShareProgressLevel() == 3) {
|
||||
List<Quester> mq = q.getMultiplayerQuesters(this);
|
||||
if (mq != null) {
|
||||
for (Quester qq : mq) {
|
||||
if (qq.getCurrentQuests().containsKey(this)) {
|
||||
setStage(qq, qq.currentQuests.get(this) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setStage(quester, quester.currentQuests.get(this) + 1);
|
||||
} catch (InvalidStageException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (q.getQuestData(this) != null) {
|
||||
q.getQuestData(this).delayStartTime = 0;
|
||||
q.getQuestData(this).delayTimeLeft = -1;
|
||||
if (quester.getQuestData(this) != null) {
|
||||
quester.getQuestData(this).delayStartTime = 0;
|
||||
quester.getQuestData(this).delayTimeLeft = -1;
|
||||
}
|
||||
|
||||
// Multiplayer
|
||||
if (opts.getShareProgressLevel() == 3) {
|
||||
List<Quester> mq = quester.getMultiplayerQuesters(this);
|
||||
for (Quester qq : mq) {
|
||||
if (currentStage.equals(qq.getCurrentStage(this))) {
|
||||
nextStage(qq, allowSharedProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
q.startStageTimer(this);
|
||||
quester.startStageTimer(this);
|
||||
}
|
||||
q.updateJournal();
|
||||
quester.updateJournal();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,7 +247,7 @@ public class Quest {
|
||||
quester.hardStagePut(this, stage);
|
||||
quester.addEmptiesFor(this, stage);
|
||||
if (currentStage.script != null) {
|
||||
plugin.getDenizenTrigger().runDenizenScript(currentStage.script, quester);
|
||||
plugin.getDenizenTrigger().runDenizenScript(quester.getCurrentStage(this).script, quester);
|
||||
}
|
||||
/*
|
||||
* if (quester.getCurrentStage(this).finishEvent != null) { quester.getCurrentStage(this).finishEvent.fire(quester); }
|
||||
@ -685,15 +700,11 @@ public class Quest {
|
||||
// Multiplayer
|
||||
if (opts.getShareProgressLevel() == 4) {
|
||||
List<Quester> mq = q.getMultiplayerQuesters(this);
|
||||
if (mq != null) {
|
||||
for (Quester qq : mq) {
|
||||
if (qq.getCurrentQuests().containsKey(this)) {
|
||||
completeQuest(qq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force player to quit quest and inform them of their failure
|
||||
|
@ -999,6 +999,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
boolean useDungeonsXLPluginOpt = false;
|
||||
boolean usePartiesPluginOpt = true;
|
||||
Integer shareProgressLevelOpt = 1;
|
||||
boolean requireSameQuestOpt = true;
|
||||
if (cc.getSessionData(CK.Q_START_NPC) != null) {
|
||||
npcStart = (Integer) cc.getSessionData(CK.Q_START_NPC);
|
||||
}
|
||||
@ -1129,6 +1130,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
if (cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null) {
|
||||
shareProgressLevelOpt = (Integer) cc.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
|
||||
}
|
||||
if (cc.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null) {
|
||||
requireSameQuestOpt = (Boolean) cc.getSessionData(CK.OPT_REQUIRE_SAME_QUEST);
|
||||
}
|
||||
cs.set("name", name);
|
||||
cs.set("npc-giver-id", npcStart);
|
||||
cs.set("block-start", blockStart);
|
||||
@ -1593,6 +1597,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
sch.set("use-dungeonsxl-plugin", useDungeonsXLPluginOpt);
|
||||
sch.set("use-parties-plugin", usePartiesPluginOpt);
|
||||
sch.set("share-progress-level", shareProgressLevelOpt);
|
||||
sch.set("require-same-quest", requireSameQuestOpt);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -1713,6 +1718,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cc.setSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN, opt.getUseDungeonsXLPlugin());
|
||||
cc.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.getUsePartiesPlugin());
|
||||
cc.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel());
|
||||
cc.setSessionData(CK.OPT_REQUIRE_SAME_QUEST, opt.getRequireSameQuest());
|
||||
// Stages (Objectives)
|
||||
int index = 1;
|
||||
for (Stage stage : q.getStages()) {
|
||||
|
@ -26,6 +26,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -932,8 +933,9 @@ public class Quester {
|
||||
* Check if player's current stage has the specified objective<p>
|
||||
*
|
||||
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
||||
* cutBlock, catchFish, enchantItem, killMob, deliverItem, killPlayer,
|
||||
* talkToNPC, killNPC, tameMob, shearSheep, password, reachLocation
|
||||
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, catchFish,
|
||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
||||
* shearSheep, password, reachLocation
|
||||
*
|
||||
* @deprecated Use containsObjective() instead
|
||||
* @param quest The quest to check objectives of
|
||||
@ -948,8 +950,9 @@ public class Quester {
|
||||
* Check if player's current stage has the specified objective<p>
|
||||
*
|
||||
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
||||
* cutBlock, catchFish, enchantItem, killMob, deliverItem, killPlayer,
|
||||
* talkToNPC, killNPC, tameMob, shearSheep, password, reachLocation
|
||||
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, catchFish,
|
||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
||||
* shearSheep, password, reachLocation
|
||||
*
|
||||
* @param quest The quest to check objectives of
|
||||
* @param s The type of objective to check for
|
||||
@ -1068,24 +1071,21 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
if (broken.getAmount() < toBreak.getAmount()) {
|
||||
ItemStack newBroken = broken;
|
||||
final ItemStack newBroken = broken;
|
||||
newBroken.setAmount(broken.getAmount() + 1);
|
||||
if (getQuestData(quest).blocksBroken.contains(broken)) {
|
||||
getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(broken), newBroken);
|
||||
if (broken.getAmount() == toBreak.getAmount()) {
|
||||
finishObjective(quest, "breakBlock", m, toBreak, null, null, null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Multiplayer
|
||||
if (quest.getOptions().getShareProgressLevel() == 1) {
|
||||
List<Quester> mq = getMultiplayerQuesters(quest);
|
||||
if (mq != null) {
|
||||
for (Quester q : mq) {
|
||||
if (q.getCurrentQuests().containsKey(quest)) {
|
||||
q.breakBlock(quest, m);
|
||||
}
|
||||
final ItemStack finalBroken = broken;
|
||||
final ItemStack finalToBreak = toBreak;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(finalBroken), newBroken);
|
||||
q.finishObjective(quest, "breakBlock", m, finalToBreak, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1136,12 +1136,21 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
if (damaged.getAmount() < toDamage.getAmount()) {
|
||||
ItemStack newDamaged = damaged;
|
||||
final ItemStack newDamaged = damaged;
|
||||
newDamaged.setAmount(damaged.getAmount() + 1);
|
||||
if (getQuestData(quest).blocksDamaged.contains(damaged)) {
|
||||
getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged);
|
||||
if (damaged.getAmount() == toDamage.getAmount()) {
|
||||
finishObjective(quest, "damageBlock", m, toDamage, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalDamaged = damaged;
|
||||
final ItemStack finalToDamage = toDamage;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(finalDamaged), newDamaged);
|
||||
q.finishObjective(quest, "damageBlock", m, finalToDamage, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1192,12 +1201,21 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
if (placed.getAmount() < toPlace.getAmount()) {
|
||||
ItemStack newplaced = placed;
|
||||
final ItemStack newplaced = placed;
|
||||
newplaced.setAmount(placed.getAmount() + 1);
|
||||
if (getQuestData(quest).blocksPlaced.contains(placed)) {
|
||||
getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(placed), newplaced);
|
||||
if (placed.getAmount() == toPlace.getAmount()) {
|
||||
finishObjective(quest, "placeBlock", m, toPlace, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalPlaced = placed;
|
||||
final ItemStack finalToPlace = toPlace;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(finalPlaced), newplaced);
|
||||
q.finishObjective(quest, "damageBlock", m, finalToPlace, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1248,12 +1266,21 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
if (used.getAmount() < toUse.getAmount()) {
|
||||
ItemStack newUsed = used;
|
||||
final ItemStack newUsed = used;
|
||||
newUsed.setAmount(used.getAmount() + 1);
|
||||
if (getQuestData(quest).blocksUsed.contains(used)) {
|
||||
getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(used), newUsed);
|
||||
if (used.getAmount() == toUse.getAmount()) {
|
||||
finishObjective(quest, "useBlock", m, toUse, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalUsed = used;
|
||||
final ItemStack finalToUse = toUse;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(finalUsed), newUsed);
|
||||
q.finishObjective(quest, "useBlock", m, finalToUse, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1304,12 +1331,21 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
if (cut.getAmount() < toCut.getAmount()) {
|
||||
ItemStack newCut = cut;
|
||||
final ItemStack newCut = cut;
|
||||
newCut.setAmount(cut.getAmount() + 1);
|
||||
if (getQuestData(quest).blocksCut.contains(cut)) {
|
||||
getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(cut), newCut);
|
||||
if (cut.getAmount() == toCut.getAmount()) {
|
||||
finishObjective(quest, "cutBlock", m, toCut, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalCut = cut;
|
||||
final ItemStack finalToCut = toCut;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(finalCut), newCut);
|
||||
q.finishObjective(quest, "cutBlock", m, finalToCut, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1345,6 +1381,14 @@ public class Quester {
|
||||
if ((i.getAmount() + amount) >= req) {
|
||||
getQuestData(quest).itemsCrafted.put(found, req);
|
||||
finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalFound = found;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).itemsCrafted.put(finalFound, req);
|
||||
q.finishObjective(quest, "craftItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
getQuestData(quest).itemsCrafted.put(found, (amount + i.getAmount()));
|
||||
}
|
||||
@ -1382,6 +1426,14 @@ public class Quester {
|
||||
if ((i.getAmount() + amount) >= req) {
|
||||
getQuestData(quest).itemsSmelted.put(found, req);
|
||||
finishObjective(quest, "smeltItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalFound = found;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).itemsSmelted.put(finalFound, req);
|
||||
q.finishObjective(quest, "smeltItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
getQuestData(quest).itemsSmelted.put(found, (amount + i.getAmount()));
|
||||
}
|
||||
@ -1405,7 +1457,16 @@ public class Quester {
|
||||
Integer num = entry.getValue() + 1;
|
||||
getQuestData(quest).itemsEnchanted.put(entry.getKey(), num);
|
||||
if (num.equals(entry2.getValue())) {
|
||||
finishObjective(quest, "enchantItem", new ItemStack(m, 1), null, e, null, null, null, null, null, null, null);
|
||||
final ItemStack finalToEnchant = new ItemStack(m, entry.getValue());
|
||||
|
||||
finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, e, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).itemsEnchanted.put(entry.getKey(), num);
|
||||
q.finishObjective(quest, "enchantItem", new ItemStack(m, 1), finalToEnchant, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1446,6 +1507,14 @@ public class Quester {
|
||||
if ((i.getAmount() + amount) >= req) {
|
||||
getQuestData(quest).itemsBrewed.put(found, req);
|
||||
finishObjective(quest, "brewItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalFound = found;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).itemsBrewed.put(finalFound, req);
|
||||
q.finishObjective(quest, "brewItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
getQuestData(quest).itemsBrewed.put(found, (amount + i.getAmount()));
|
||||
}
|
||||
@ -1459,10 +1528,19 @@ public class Quester {
|
||||
* @param quest The quest for which the fish is being caught
|
||||
*/
|
||||
public void catchFish(Quest quest) {
|
||||
if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) {
|
||||
final int fishToCatch = getCurrentStage(quest).fishToCatch;
|
||||
if (getQuestData(quest).getFishCaught() < fishToCatch) {
|
||||
getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1);
|
||||
if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) {
|
||||
finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null);
|
||||
|
||||
if (getQuestData(quest).getFishCaught() == fishToCatch) {
|
||||
finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).setFishCaught(fishToCatch);
|
||||
q.finishObjective(quest, "catchFish", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch), null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1479,10 +1557,10 @@ public class Quester {
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
if (questData.mobsKilled.contains(e) == false) {
|
||||
Stage currentStage = getCurrentStage(quest);
|
||||
if (currentStage.mobsToKill.contains(e) == false) {
|
||||
return;
|
||||
}
|
||||
Stage currentStage = getCurrentStage(quest);
|
||||
int indexOfMobKilled = questData.mobsKilled.indexOf(e);
|
||||
int numberOfSpecificMobKilled = questData.mobNumKilled.get(indexOfMobKilled);
|
||||
int numberOfSpecificMobNeedsToBeKilledInCurrentStage = currentStage.mobNumToKill.get(indexOfMobKilled);
|
||||
@ -1505,10 +1583,19 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
if (numberOfSpecificMobKilled < numberOfSpecificMobNeedsToBeKilledInCurrentStage) {
|
||||
Integer newNumberOfSpecificMobKilled = numberOfSpecificMobKilled + 1;
|
||||
int newNumberOfSpecificMobKilled = numberOfSpecificMobKilled + 1;
|
||||
questData.mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled);
|
||||
if ((newNumberOfSpecificMobKilled).equals(numberOfSpecificMobNeedsToBeKilledInCurrentStage)) {
|
||||
finishObjective(quest, "killMob", null, null, null, e, null, null, null, null, null, null);
|
||||
if (newNumberOfSpecificMobKilled == numberOfSpecificMobNeedsToBeKilledInCurrentStage) {
|
||||
finishObjective(quest, "killMob", new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, currentStage, (Quester q) -> {
|
||||
q.getQuestData(quest).mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled);
|
||||
q.finishObjective(quest, "killMob", new ItemStack(Material.AIR, 1),
|
||||
new ItemStack(Material.AIR, numberOfSpecificMobNeedsToBeKilledInCurrentStage), null, e, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1520,10 +1607,18 @@ public class Quester {
|
||||
* @param player The player to be killed
|
||||
*/
|
||||
public void killPlayer(Quest quest, Player player) {
|
||||
if (getQuestData(quest).getPlayersKilled() < getCurrentStage(quest).playersToKill) {
|
||||
final int playersToKill = getCurrentStage(quest).playersToKill;
|
||||
if (getQuestData(quest).getPlayersKilled() < playersToKill) {
|
||||
getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled() + 1);
|
||||
if (((Integer) getQuestData(quest).getPlayersKilled()).equals(getCurrentStage(quest).playersToKill)) {
|
||||
finishObjective(quest, "killPlayer", null, null, null, null, null, null, null, null, null, null);
|
||||
if (getQuestData(quest).getPlayersKilled() == playersToKill) {
|
||||
finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled());
|
||||
q.finishObjective(quest, "killPlayer", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill), null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1565,17 +1660,23 @@ public class Quester {
|
||||
+ " when delivering for quest " + quest.getName());
|
||||
return;
|
||||
}
|
||||
if ((i.getAmount() + amount) > req) {
|
||||
if ((i.getAmount() + amount) >= req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
if ((i.getAmount() + amount) >= req) {
|
||||
i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered
|
||||
player.getInventory().setItem(index, i);
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else if ((i.getAmount() + amount) == req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
} else {
|
||||
player.getInventory().setItem(index, null);
|
||||
}
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).itemsDelivered.put(found, req);
|
||||
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
|
||||
player.getInventory().setItem(index, null);
|
||||
@ -1620,16 +1721,23 @@ public class Quester {
|
||||
if (amount < req) {
|
||||
if ((i.getAmount() + amount) > req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
if ((i.getAmount() + amount) > req) {
|
||||
int index = player.getInventory().first(i);
|
||||
i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered
|
||||
player.getInventory().setItem(index, i);
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else if ((i.getAmount() + amount) == req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
} else {
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
}
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final ItemStack finalFound = found;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).itemsDelivered.put(finalFound, req);
|
||||
q.finishObjective(quest, "deliverItem", new ItemStack(m, 1), finalFound, null, null, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
@ -1654,7 +1762,14 @@ public class Quester {
|
||||
Boolean b = getQuestData(quest).citizensInteracted.get(n.getId());
|
||||
if (b != null && !b) {
|
||||
getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
||||
finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null);
|
||||
finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
||||
q.finishObjective(quest, "talkToNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, n, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1668,10 +1783,18 @@ public class Quester {
|
||||
public void killNPC(Quest quest, NPC n) {
|
||||
if (getQuestData(quest).citizensKilled.contains(n.getId())) {
|
||||
int index = getQuestData(quest).citizensKilled.indexOf(n.getId());
|
||||
if (getQuestData(quest).citizenNumKilled.get(index) < getCurrentStage(quest).citizenNumToKill.get(index)) {
|
||||
final int npcsToKill = getCurrentStage(quest).citizenNumToKill.get(index);
|
||||
if (getQuestData(quest).citizenNumKilled.get(index) < npcsToKill) {
|
||||
getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index) + 1);
|
||||
if (getQuestData(quest).citizenNumKilled.get(index) == getCurrentStage(quest).citizenNumToKill.get(index)) {
|
||||
finishObjective(quest, "killNPC", null, null, null, null, null, n, null, null, null, null);
|
||||
if (getQuestData(quest).citizenNumKilled.get(index).equals(npcsToKill)) {
|
||||
finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index));
|
||||
q.finishObjective(quest, "killNPC", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, npcsToKill), null, null, null, n, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1681,7 +1804,7 @@ public class Quester {
|
||||
* Mark location as reached if the Quester has such an objective
|
||||
*
|
||||
* @param quest The quest for which the location is being reached
|
||||
* @param n The location being reached
|
||||
* @param l The location being reached
|
||||
*/
|
||||
public void reachLocation(Quest quest, Location l) {
|
||||
if (getQuestData(quest).locationsReached == null) {
|
||||
@ -1708,7 +1831,19 @@ public class Quester {
|
||||
} else {
|
||||
getQuestData(quest).hasReached.set(index, true);
|
||||
}
|
||||
finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null);
|
||||
finishObjective(quest, "reachLocation", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, location, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
final int finalIndex = index;
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
if (finalIndex >= getQuestData(quest).hasReached.size()) {
|
||||
q.getQuestData(quest).hasReached.add(true);
|
||||
} else {
|
||||
q.getQuestData(quest).hasReached.set(finalIndex, true);
|
||||
}
|
||||
q.finishObjective(quest, "reachLocation", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, location, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1735,8 +1870,16 @@ public class Quester {
|
||||
public void tameMob(Quest quest, EntityType entity) {
|
||||
if (getQuestData(quest).mobsTamed.containsKey(entity)) {
|
||||
getQuestData(quest).mobsTamed.put(entity, (getQuestData(quest).mobsTamed.get(entity) + 1));
|
||||
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);
|
||||
final int mobsToTame = getCurrentStage(quest).mobsToTame.get(entity);
|
||||
if (getQuestData(quest).mobsTamed.get(entity).equals(mobsToTame)) {
|
||||
finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).mobsTamed.put(entity, getQuestData(quest).mobsTamed.get(entity));
|
||||
q.finishObjective(quest, "tameMob", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame), null, entity, null, null, null, null, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1750,8 +1893,16 @@ public class Quester {
|
||||
public void shearSheep(Quest quest, DyeColor color) {
|
||||
if (getQuestData(quest).sheepSheared.containsKey(color)) {
|
||||
getQuestData(quest).sheepSheared.put(color, (getQuestData(quest).sheepSheared.get(color) + 1));
|
||||
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);
|
||||
final int sheepToShear = getCurrentStage(quest).sheepToShear.get(color);
|
||||
if (getQuestData(quest).sheepSheared.get(color).equals(sheepToShear)) {
|
||||
finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null);
|
||||
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).sheepSheared.put(color, getQuestData(quest).sheepSheared.get(color));
|
||||
q.finishObjective(quest, "shearSheep", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear), null, null, null, null, null, color, null, null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1772,12 +1923,15 @@ public class Quester {
|
||||
String display = getCurrentStage(quest).passwordDisplays.get(getCurrentStage(quest).passwordPhrases.indexOf(passes));
|
||||
getQuestData(quest).passwordsSaid.put(display, true);
|
||||
done = true;
|
||||
plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
|
||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||
finishObjective(quest, "password", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
finishObjective(quest, "password", null, null, null, null, null, null, null, null, display, null);
|
||||
}
|
||||
// Multiplayer
|
||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||
q.getQuestData(quest).passwordsSaid.put(display, true);
|
||||
q.finishObjective(quest, "password", new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1), null, null, null, null, null, null, display, null);
|
||||
return null;
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
@ -1891,7 +2045,7 @@ public class Quester {
|
||||
ench.put(enchantment, enchantment.getStartLevel());
|
||||
for (Map<Enchantment, Material> map : getCurrentStage(quest).itemsToEnchant.keySet()) {
|
||||
if (map.containsKey(enchantment)) {
|
||||
message = message + " " + getCurrentStage(quest).itemsToEnchant.get(map) + "/" + getCurrentStage(quest).itemsToEnchant.get(map);
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1922,11 +2076,11 @@ public class Quester {
|
||||
}
|
||||
} else if (objective.equalsIgnoreCase("catchFish")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " ";
|
||||
message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch;
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
p.sendMessage(message);
|
||||
} else if (objective.equalsIgnoreCase("killMob")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " <mob>";
|
||||
message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob));
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
if (plugin.getSettings().canTranslateItems()) {
|
||||
plugin.getLocaleQuery().sendMessage(p, message, mob, extra);
|
||||
} else {
|
||||
@ -1934,7 +2088,7 @@ public class Quester {
|
||||
}
|
||||
} else if (objective.equalsIgnoreCase("killPlayer")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "killPlayer");
|
||||
message = message + " " + getCurrentStage(quest).playersToKill + "/" + getCurrentStage(quest).playersToKill;
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
p.sendMessage(message);
|
||||
} else if (objective.equalsIgnoreCase("talkToNPC")) {
|
||||
String obj = Lang.get(p, "talkTo");
|
||||
@ -1943,11 +2097,11 @@ public class Quester {
|
||||
p.sendMessage(message);
|
||||
} else if (objective.equalsIgnoreCase("killNPC")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " " + npc.getName();
|
||||
message = message + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())) + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId()));
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
p.sendMessage(message);
|
||||
} else if (objective.equalsIgnoreCase("tameMob")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame") + " <mob>";
|
||||
message = message + " " + getCurrentStage(quest).mobsToTame.get(mob) + "/" + getCurrentStage(quest).mobsToTame.get(mob);
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
if (plugin.getSettings().canTranslateItems()) {
|
||||
plugin.getLocaleQuery().sendMessage(p, message, mob, extra);
|
||||
} else {
|
||||
@ -1957,7 +2111,7 @@ public class Quester {
|
||||
String obj = Lang.get(p, "shearSheep");
|
||||
obj = obj.replace("<color>", color.name().toLowerCase());
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
|
||||
message = message + " " + getCurrentStage(quest).sheepToShear.get(color) + "/" + getCurrentStage(quest).sheepToShear.get(color);
|
||||
message = message + " " + goal.getAmount() + "/" + goal.getAmount();
|
||||
p.sendMessage(message);
|
||||
} else if (objective.equalsIgnoreCase("reachLocation")) {
|
||||
String obj = Lang.get(p, "goTo");
|
||||
@ -1982,24 +2136,12 @@ public class Quester {
|
||||
}
|
||||
|
||||
if (co.canShowCount()) {
|
||||
message = message.replace("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index));
|
||||
message = message.replace("%count%", goal.getAmount() + "/" + goal.getAmount());
|
||||
}
|
||||
p.sendMessage(message);
|
||||
}
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
|
||||
// Multiplayer
|
||||
if (quest.getOptions().getShareProgressLevel() == 2) {
|
||||
List<Quester> mq = getMultiplayerQuesters(quest);
|
||||
if (mq != null) {
|
||||
for (Quester q : mq) {
|
||||
if (q.getCurrentQuests().containsKey(quest)) {
|
||||
quest.nextStage(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
quest.nextStage(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3124,21 +3266,67 @@ public class Quester {
|
||||
return playerAmount >= is.getAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch player event to fellow questers<p>
|
||||
*
|
||||
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
||||
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, catchFish,
|
||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
||||
* shearSheep, password, reachLocation
|
||||
*
|
||||
* @param objectiveType The type of objective to progress
|
||||
* @param fun The function to execute, the event call
|
||||
*/
|
||||
public void dispatchMultiplayerEverything(Quest quest, String objectiveType, Function<Quester, Void> fun) {
|
||||
if (quest.getOptions().getShareProgressLevel() == 1) {
|
||||
List<Quester> mq = getMultiplayerQuesters(quest);
|
||||
if (mq == null) {
|
||||
return;
|
||||
}
|
||||
for (Quester q : mq) {
|
||||
if (q.containsObjective(quest, objectiveType)) {
|
||||
if (!quest.getOptions().getRequireSameQuest() || this.containsObjective(quest, objectiveType)) {
|
||||
fun.apply(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch finish objective to fellow questers
|
||||
*
|
||||
* @param quest The current quest
|
||||
* @param currentStage The current stage of the quest
|
||||
* @param fun The function to execute, the event call
|
||||
*/
|
||||
public void dispatchMultiplayerObjectives(Quest quest, Stage currentStage, Function<Quester, Void> fun) {
|
||||
if (quest.getOptions().getShareProgressLevel() == 2) {
|
||||
List<Quester> mq = getMultiplayerQuesters(quest);
|
||||
for (Quester q : mq) {
|
||||
if ((q.getCurrentQuests().containsKey(quest) && currentStage.equals(q.getCurrentStage(quest)))
|
||||
|| !quest.getOptions().getRequireSameQuest()) {
|
||||
fun.apply(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of follow Questers in a party or group
|
||||
*
|
||||
* @param quest The quest which uses a linked plugin, i.e. Parties or DungeonsXL
|
||||
* @return null if quest is null, no linked plugins, or party/group is null
|
||||
* @return Potentially empty list of Questers or null for invalid quest
|
||||
*/
|
||||
public List<Quester> getMultiplayerQuesters(Quest quest) {
|
||||
if (quest == null) {
|
||||
return null;
|
||||
}
|
||||
List<Quester> mq = new LinkedList<Quester>();
|
||||
if (plugin.getDependencies().getPartiesApi() != null) {
|
||||
if (quest.getOptions().getUsePartiesPlugin()) {
|
||||
Party party = plugin.getDependencies().getPartiesApi().getParty(plugin.getDependencies().getPartiesApi().getPartyPlayer(getUUID()).getPartyName());
|
||||
if (party != null) {
|
||||
List<Quester> mq = new LinkedList<Quester>();
|
||||
for (UUID id : party.getMembers()) {
|
||||
if (!id.equals(getUUID())) {
|
||||
mq.add(plugin.getQuester(id));
|
||||
@ -3152,7 +3340,6 @@ public class Quester {
|
||||
if (quest.getOptions().getUseDungeonsXLPlugin()) {
|
||||
DGroup group = DGroup.getByPlayer(getPlayer());
|
||||
if (group != null) {
|
||||
List<Quester> mq = new LinkedList<Quester>();
|
||||
for (UUID id : group.getPlayers()) {
|
||||
if (!id.equals(getUUID())) {
|
||||
mq.add(plugin.getQuester(id));
|
||||
@ -3162,7 +3349,7 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mq;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1339,9 +1339,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload quests, player data, actions, config settings, lang and modules, in that order
|
||||
* Reload quests, actions, config settings, lang and modules, and player data
|
||||
*/
|
||||
public void reloadQuests() {
|
||||
for (Quester quester : questers) {
|
||||
quester.saveData();
|
||||
}
|
||||
quests.clear();
|
||||
events.clear();
|
||||
|
||||
@ -1360,6 +1363,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
loadModules();
|
||||
for (Quester quester : questers) {
|
||||
quester.loadData();
|
||||
for (Quest q : quester.currentQuests.keySet()) {
|
||||
quester.checkQuest(q);
|
||||
}
|
||||
@ -1465,6 +1469,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
try { // main "skip quest" try/catch block
|
||||
Quest quest = new Quest();
|
||||
failedToLoad = false;
|
||||
quest.id = questKey;
|
||||
if (config.contains("quests." + questKey + ".name")) {
|
||||
quest.setName(parseString(config.getString("quests." + questKey + ".name"), quest));
|
||||
} else {
|
||||
@ -1946,6 +1951,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
if (config.contains("quests." + questKey + ".options.share-progress-level")) {
|
||||
opts.setShareProgressLevel(config.getInt("quests." + questKey + ".options.share-progress-level"));
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".options.require-same-quest")) {
|
||||
opts.setRequireSameQuest(config.getBoolean("quests." + questKey + ".options.require-same-quest"));
|
||||
}
|
||||
}
|
||||
|
||||
private void skipQuestProcess(String[] msgs) throws SkipQuest {
|
||||
|
@ -671,10 +671,16 @@ public class CmdExecutor implements CommandExecutor {
|
||||
if (args.length == 1) {
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
|
||||
} else {
|
||||
Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (questToFind != null) {
|
||||
final Quest q = questToFind;
|
||||
plugin.getQuester(player.getUniqueId()).offerQuest(q, true);
|
||||
for (Quest q : quester.getCurrentQuests().keySet()) {
|
||||
if (q.getId().equals(questToFind.getId())) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "questAlreadyOn"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
quester.offerQuest(questToFind, true);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questNotFound"));
|
||||
}
|
||||
@ -1119,7 +1125,7 @@ public class CmdExecutor implements CommandExecutor {
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
target.sendMessage(ChatColor.GREEN + msg2);
|
||||
quest.nextStage(quester);
|
||||
quest.nextStage(quester, false);
|
||||
quester.saveData();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*******************************************************************************************************
|
||||
|
||||
* Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
@ -203,12 +204,17 @@ public class PlayerListener implements Listener {
|
||||
final Player player = evt.getPlayer();
|
||||
boolean hasObjective = false;
|
||||
if (evt.isCancelled() == false) {
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "useBlock")) {
|
||||
ItemStack i = new ItemStack(evt.getClickedBlock().getType(), 1, evt.getClickedBlock().getState().getData().toItemStack().getDurability());
|
||||
quester.useBlock(quest, i);
|
||||
final ItemStack blockItemStack = new ItemStack(evt.getClickedBlock().getType(), 1, evt.getClickedBlock().getState().getData().toItemStack().getDurability());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "useBlock")) {
|
||||
quester.useBlock(quest, blockItemStack);
|
||||
hasObjective = true;
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "useBlock", (Quester q) -> {
|
||||
q.useBlock(quest, blockItemStack);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!hasObjective) {
|
||||
@ -332,8 +338,8 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerChat(AsyncPlayerChatEvent evt) {
|
||||
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
if (quester.getCurrentQuests().isEmpty() == false) {
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
for (final Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest)) {
|
||||
final Stage currentStage = quester.getCurrentStage(quest);
|
||||
if (currentStage == null) {
|
||||
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() + " on chat for quest " + quest.getName());
|
||||
@ -360,6 +366,11 @@ public class PlayerListener implements Listener {
|
||||
quester.sayPassword(quest, evt);
|
||||
}
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "password", (Quester q) -> {
|
||||
q.sayPassword(quest, evt);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -404,12 +415,17 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockDamage(BlockDamageEvent evt) {
|
||||
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
|
||||
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "damageBlock")) {
|
||||
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
quester.damageBlock(quest, i);
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "damageBlock")) {
|
||||
quester.damageBlock(quest, blockItemStack);
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> {
|
||||
q.placeBlock(quest, blockItemStack);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -418,13 +434,18 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockPlace(BlockPlaceEvent evt) {
|
||||
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
|
||||
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "placeBlock")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (evt.isCancelled() == false) {
|
||||
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
quester.placeBlock(quest, i);
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "placeBlock")) {
|
||||
quester.placeBlock(quest, blockItemStack);
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> {
|
||||
q.placeBlock(quest, blockItemStack);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,16 +455,22 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent evt) {
|
||||
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
|
||||
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (evt.isCancelled() == false) {
|
||||
if (quester.containsObjective(quest, "breakBlock")) {
|
||||
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false) {
|
||||
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
quester.breakBlock(quest, i);
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "breakBlock")) {
|
||||
if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
quester.breakBlock(quest, blockItemStack);
|
||||
}
|
||||
}
|
||||
if (quester.containsObjective(quest, "placeBlock")) {
|
||||
quester.dispatchMultiplayerEverything(quest, "breakBlock", (Quester q) -> {
|
||||
if (!evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
q.breakBlock(quest, blockItemStack);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "placeBlock")) {
|
||||
for (ItemStack is : quester.getQuestData(quest).blocksPlaced) {
|
||||
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
|
||||
int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
|
||||
@ -452,12 +479,27 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (quester.containsObjective(quest, "cutBlock")) {
|
||||
quester.dispatchMultiplayerEverything(quest, "placeBlock", (Quester q) -> {
|
||||
for (ItemStack is : q.getQuestData(quest).blocksPlaced) {
|
||||
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
|
||||
int index = q.getQuestData(quest).blocksPlaced.indexOf(is);
|
||||
is.setAmount(is.getAmount() - 1);
|
||||
q.getQuestData(quest).blocksPlaced.set(index, is);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "cutBlock")) {
|
||||
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) {
|
||||
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
|
||||
quester.cutBlock(quest, i);
|
||||
quester.cutBlock(quest, blockItemStack);
|
||||
}
|
||||
}
|
||||
quester.dispatchMultiplayerEverything(quest, "cutBlock", (Quester q) -> {
|
||||
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS)) {
|
||||
q.cutBlock(quest, blockItemStack);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -465,13 +507,20 @@ public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShearEntity(PlayerShearEntityEvent evt) {
|
||||
if (evt.getEntity().getType() == EntityType.SHEEP) {
|
||||
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (evt.getEntity().getType() == EntityType.SHEEP && quester.containsObjective(quest, "shearSheep")) {
|
||||
Sheep sheep = (Sheep) evt.getEntity();
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "shearSheep")) {
|
||||
quester.shearSheep(quest, sheep.getColor());
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "shearSheep", (Quester q) -> {
|
||||
q.shearSheep(quest, sheep.getColor());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -482,10 +531,15 @@ public class PlayerListener implements Listener {
|
||||
Player p = (Player) evt.getOwner();
|
||||
if (plugin.canUseQuests(p.getUniqueId())) {
|
||||
Quester quester = plugin.getQuester(p.getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "tameMob")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "tameMob")) {
|
||||
quester.tameMob(quest, evt.getEntityType());
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "tameMob", (Quester q) -> {
|
||||
q.tameMob(quest, evt.getEntityType());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -497,13 +551,29 @@ public class PlayerListener implements Listener {
|
||||
public void onCraftItem(CraftItemEvent evt) {
|
||||
if (evt.getWhoClicked() instanceof Player) {
|
||||
if (plugin.checkQuester(evt.getWhoClicked().getUniqueId()) == false) {
|
||||
final ItemStack craftedItem = getCraftedItem(evt);
|
||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "craftItem")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "craftItem")) {
|
||||
quester.craftItem(quest, craftedItem);
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "craftItem", (Quester q) -> {
|
||||
q.craftItem(quest, craftedItem);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private ItemStack getCraftedItem(CraftItemEvent evt) {
|
||||
if (evt.isShiftClick()) {
|
||||
ItemStack result = evt.getRecipe().getResult();
|
||||
int numberOfItems = result.getAmount();
|
||||
if (evt.isShiftClick()) {
|
||||
int itemsChecked = 0;
|
||||
|
||||
for (ItemStack item : evt.getInventory().getMatrix()) {
|
||||
if (item != null && !item.getType().equals(Material.AIR)) {
|
||||
if (itemsChecked == 0) {
|
||||
@ -514,35 +584,41 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
quester.craftItem(quest, new ItemStack(result.getType(), numberOfItems, result.getDurability()));
|
||||
} else {
|
||||
quester.craftItem(quest, evt.getCurrentItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ItemStack(result.getType(), numberOfItems, result.getDurability());
|
||||
}
|
||||
return evt.getCurrentItem();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent evt) {
|
||||
if (evt.getWhoClicked() instanceof Player) {
|
||||
if (evt.getInventory().getType() == InventoryType.FURNACE) {
|
||||
if (evt.getSlotType() == SlotType.RESULT) {
|
||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "smeltItem")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "smeltItem")) {
|
||||
quester.smeltItem(quest, evt.getCurrentItem());
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "smeltItem", (Quester q) -> {
|
||||
q.smeltItem(quest, evt.getCurrentItem());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (evt.getInventory().getType() == InventoryType.BREWING) {
|
||||
if (evt.getSlotType() == SlotType.CRAFTING) {
|
||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "brewItem")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "brewItem")) {
|
||||
quester.brewItem(quest, evt.getCurrentItem());
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "brewItem", (Quester q) -> {
|
||||
q.brewItem(quest, evt.getCurrentItem());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -553,12 +629,19 @@ public class PlayerListener implements Listener {
|
||||
public void onEnchantItem(EnchantItemEvent evt) {
|
||||
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
|
||||
Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "enchantItem")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "enchantItem")) {
|
||||
for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
|
||||
quester.enchantItem(quest, e, evt.getItem().getType());
|
||||
}
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "enchantItem", (Quester q) -> {
|
||||
for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
|
||||
q.enchantItem(quest, e, evt.getItem().getType());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -573,24 +656,24 @@ public class PlayerListener implements Listener {
|
||||
if (damager instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) damager;
|
||||
if (projectile.getShooter() != null && projectile.getShooter() instanceof Entity) {
|
||||
killMob((Entity)projectile.getShooter(), evt.getEntity());
|
||||
preKillMob((Entity)projectile.getShooter(), evt.getEntity());
|
||||
}
|
||||
} else if (damager instanceof TNTPrimed) {
|
||||
TNTPrimed tnt = (TNTPrimed) damager;
|
||||
Entity source = tnt.getSource();
|
||||
if (source != null && source.isValid()) {
|
||||
killMob(source, evt.getEntity());
|
||||
preKillMob(source, evt.getEntity());
|
||||
}
|
||||
} else if (damager instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) damager;
|
||||
if (wolf.isTamed() && wolf.getOwner() != null) {
|
||||
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
|
||||
if (quester != null) {
|
||||
killPlayer(quester.getPlayer(), evt.getEntity());
|
||||
preKillPlayer(quester.getPlayer(), evt.getEntity());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
killMob(damager, evt.getEntity());
|
||||
preKillMob(damager, evt.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -603,27 +686,34 @@ public class PlayerListener implements Listener {
|
||||
* @param target the entity being attacked
|
||||
* @since 3.1.4
|
||||
*/
|
||||
public void killMob(Entity damager, Entity target) {
|
||||
public void preKillMob(Entity damager, Entity target) {
|
||||
if (!plugin.canUseQuests(damager.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
if (damager instanceof Player) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
if (CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "killNPC")) {
|
||||
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killNPC")) {
|
||||
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "killNPC", (Quester q) -> {
|
||||
q.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "killMob")) {
|
||||
} else {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killMob")) {
|
||||
quester.killMob(quest, target.getLocation(), target.getType());
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "killMob", (Quester q) -> {
|
||||
q.killMob(quest, target.getLocation(), target.getType());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -642,24 +732,24 @@ public class PlayerListener implements Listener {
|
||||
if (damager instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) damager;
|
||||
if (projectile.getShooter() != null && projectile.getShooter() instanceof Entity) {
|
||||
killPlayer((Entity)projectile.getShooter(), evt.getEntity());
|
||||
preKillPlayer((Entity)projectile.getShooter(), evt.getEntity());
|
||||
}
|
||||
} else if (damager instanceof TNTPrimed) {
|
||||
TNTPrimed tnt = (TNTPrimed) damager;
|
||||
Entity source = tnt.getSource();
|
||||
if (source != null) {
|
||||
if (source.isValid()) {
|
||||
killPlayer(source, evt.getEntity());
|
||||
preKillPlayer(source, evt.getEntity());
|
||||
}
|
||||
}
|
||||
} else if (damager instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) damager;
|
||||
if (wolf.isTamed()) {
|
||||
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
|
||||
killPlayer(quester.getPlayer(), evt.getEntity());
|
||||
preKillPlayer(quester.getPlayer(), evt.getEntity());
|
||||
}
|
||||
} else {
|
||||
killPlayer(damager, evt.getEntity());
|
||||
preKillPlayer(damager, evt.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -695,7 +785,7 @@ public class PlayerListener implements Listener {
|
||||
* @param target the entity being attacked
|
||||
* @since 3.1.4
|
||||
*/
|
||||
public void killPlayer(Entity damager, Entity target) {
|
||||
public void preKillPlayer(Entity damager, Entity target) {
|
||||
if (damager == null) {
|
||||
return;
|
||||
}
|
||||
@ -709,10 +799,15 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "killPlayer")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "killPlayer")) {
|
||||
quester.killPlayer(quest, (Player)target);
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "killPlayer", (Quester q) -> {
|
||||
q.killPlayer(quest, (Player)target);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -722,10 +817,15 @@ public class PlayerListener implements Listener {
|
||||
Player player = evt.getPlayer();
|
||||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
|
||||
quester.catchFish(quest);
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "catchFish", (Quester q) -> {
|
||||
q.catchFish(quest);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -848,10 +948,15 @@ public class PlayerListener implements Listener {
|
||||
if (plugin.getQuester(evt.getPlayer().getUniqueId()) != null) {
|
||||
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "reachLocation")) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quester.getCurrentQuests().containsKey(quest) && quester.containsObjective(quest, "reachLocation")) {
|
||||
quester.reachLocation(quest, evt.getTo());
|
||||
}
|
||||
|
||||
quester.dispatchMultiplayerEverything(quest, "reachLocation", (Quester q) -> {
|
||||
q.reachLocation(quest, evt.getTo());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
|
||||
public class MultiplayerPrompt extends NumericPrompt {
|
||||
|
||||
private final int size = 4;
|
||||
private final int size = 5;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
@ -358,6 +358,8 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
case 3:
|
||||
return ChatColor.BLUE;
|
||||
case 4:
|
||||
return ChatColor.BLUE;
|
||||
case 5:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
@ -397,6 +399,16 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")";
|
||||
}
|
||||
case 4:
|
||||
if (context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST) == null) {
|
||||
boolean defaultOpt = new Options().getRequireSameQuest();
|
||||
return ChatColor.YELLOW + Lang.get("optRequireSameQuest") + " ("
|
||||
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
|
||||
} else {
|
||||
boolean requireOpt = (Boolean) context.getSessionData(CK.OPT_REQUIRE_SAME_QUEST);
|
||||
return ChatColor.YELLOW + Lang.get("optRequireSameQuest") + " ("
|
||||
+ (requireOpt ? ChatColor.GREEN + String.valueOf(requireOpt) : ChatColor.RED + String.valueOf(requireOpt)) + ChatColor.YELLOW + ")";
|
||||
}
|
||||
case 5:
|
||||
return ChatColor.YELLOW + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
@ -431,6 +443,10 @@ public class OptionsPrompt extends NumericPrompt {
|
||||
tempPrompt = new MultiplayerPrompt();
|
||||
return new LevelPrompt();
|
||||
case 4:
|
||||
tempKey = CK.OPT_REQUIRE_SAME_QUEST;
|
||||
tempPrompt = new MultiplayerPrompt();
|
||||
return new TrueFalsePrompt();
|
||||
case 5:
|
||||
tempKey = null;
|
||||
tempPrompt = null;
|
||||
try {
|
||||
|
@ -137,6 +137,7 @@ public class CK {
|
||||
public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
|
||||
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
|
||||
public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt";
|
||||
public static final String OPT_REQUIRE_SAME_QUEST = "requireSameQuestOpt";
|
||||
// Events
|
||||
public static final String E_OLD_EVENT = "oldEvent";
|
||||
public static final String E_NAME = "evtName";
|
||||
|
@ -475,6 +475,7 @@ optCommandsDenied: "You cannot use commands during <quest>."
|
||||
optUseDungeonsXLPlugin: "Use DungeonsXL plugin"
|
||||
optUsePartiesPlugin: "Use Parties plugin"
|
||||
optShareProgressLevel: "Level of progress sharing"
|
||||
optRequireSameQuest: "Require same quest"
|
||||
rewSetMoney: "Set money reward"
|
||||
rewSetQuestPoints: "Set Quest Points reward"
|
||||
rewSetItems: "Set item rewards"
|
||||
|
Loading…
Reference in New Issue
Block a user