mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-22 17:17:38 +01:00
Refactoring begun (UNSTABLE)
This commit is contained in:
parent
453cf15f8f
commit
063b8fdd6d
@ -134,7 +134,9 @@ public class NpcListener implements Listener {
|
||||
|
||||
} else if (quester.currentQuest.equals(q) == false) {
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("questOneActive"));
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
@ -164,7 +166,9 @@ public class NpcListener implements Listener {
|
||||
|
||||
} else if (quester.currentQuest.equals(q) == false) {
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("questOneActive"));
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,9 @@ public class PlayerListener implements Listener, ColorUtil {
|
||||
|
||||
if (quester.currentQuest != null) {
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("questOneActive"));
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
|
||||
} else {
|
||||
|
||||
@ -194,7 +196,11 @@ public class PlayerListener implements Listener, ColorUtil {
|
||||
if(ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
|
||||
|
||||
if (quester.currentQuest != null) {
|
||||
player.sendMessage(YELLOW + Lang.get("questOneActive"));
|
||||
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(YELLOW + msg);
|
||||
|
||||
} else if (quester.completedQuests.contains(quest.name) && quest.redoDelay < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
|
||||
|
@ -75,84 +75,89 @@ public class Quest {
|
||||
List<String> phatLootRewards = new LinkedList<String>();
|
||||
//
|
||||
|
||||
public Stage getStage(int index) {
|
||||
try {
|
||||
return orderedStages.get(index);
|
||||
}catch (IndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void nextStage(Quester q) {
|
||||
|
||||
String stageCompleteMessage = q.currentStage.completeMessage;
|
||||
String stageCompleteMessage = q.getCurrentStage(this).completeMessage;
|
||||
if (stageCompleteMessage != null) {
|
||||
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, q.currentQuest));
|
||||
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, this));
|
||||
}
|
||||
|
||||
if (q.currentStage.delay < 0) {
|
||||
if (q.getCurrentStage(this).delay < 0) {
|
||||
|
||||
Player player = q.getPlayer();
|
||||
if (q.currentStageIndex == (q.currentQuest.orderedStages.size() - 1)) {
|
||||
if (q.currentQuests.get(this) == (orderedStages.size() - 1)) {
|
||||
|
||||
if (q.currentStage.script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
|
||||
if (q.getCurrentStage(this).script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(q.getCurrentStage(this).script, player);
|
||||
}
|
||||
if (q.currentStage.finishEvent != null) {
|
||||
q.currentStage.finishEvent.fire(q);
|
||||
if (q.getCurrentStage(this).finishEvent != null) {
|
||||
q.getCurrentStage(this).finishEvent.fire(q);
|
||||
}
|
||||
|
||||
completeQuest(q);
|
||||
|
||||
} else {
|
||||
|
||||
q.currentStageIndex++;
|
||||
q.currentQuests.put(this, q.currentQuests.get(this) + 1);
|
||||
try {
|
||||
setStage(q, q.currentStageIndex);
|
||||
setStage(q, q.currentQuests.get(this));
|
||||
} catch (InvalidStageException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
q.delayStartTime = 0;
|
||||
q.delayTimeLeft = -1;
|
||||
q.getQuestData(this).delayStartTime = 0;
|
||||
q.getQuestData(this).delayTimeLeft = -1;
|
||||
|
||||
} else {
|
||||
q.startStageTimer();
|
||||
|
||||
q.startStageTimer(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setStage(Quester quester, int stage) throws InvalidStageException {
|
||||
|
||||
quester.currentStageIndex = stage;
|
||||
quester.currentQuests.put(this, stage);
|
||||
|
||||
if (orderedStages.size() - 1 < stage) {
|
||||
throw new InvalidStageException(this, stage);
|
||||
}
|
||||
|
||||
quester.resetObjectives();
|
||||
quester.resetObjectives(this);
|
||||
|
||||
if (quester.currentStage.script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, quester.getPlayer());
|
||||
if (quester.getCurrentStage(this).script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(quester.getCurrentStage(this).script, quester.getPlayer());
|
||||
}
|
||||
|
||||
/*if (quester.currentStage.finishEvent != null) {
|
||||
quester.currentStage.finishEvent.fire(quester);
|
||||
/*if (quester.getCurrentStage(this).finishEvent != null) {
|
||||
quester.getCurrentStage(this).finishEvent.fire(quester);
|
||||
}*/
|
||||
|
||||
quester.currentStage = orderedStages.get(stage);
|
||||
|
||||
if (quester.currentStage.startEvent != null) {
|
||||
quester.currentStage.startEvent.fire(quester);
|
||||
if (quester.getCurrentStage(this).startEvent != null) {
|
||||
quester.getCurrentStage(this).startEvent.fire(quester);
|
||||
}
|
||||
|
||||
quester.addEmpties();
|
||||
quester.addEmpties(this);
|
||||
|
||||
quester.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questObjectivesTitle"));
|
||||
for (String s : quester.getObjectivesReal()) {
|
||||
for (String s : quester.getObjectivesReal(this)) {
|
||||
|
||||
quester.getPlayer().sendMessage(s);
|
||||
|
||||
}
|
||||
|
||||
String stageStartMessage = quester.currentStage.startMessage;
|
||||
String stageStartMessage = quester.getCurrentStage(this).startMessage;
|
||||
if (stageStartMessage != null) {
|
||||
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, quester.currentQuest));
|
||||
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, this));
|
||||
}
|
||||
|
||||
}
|
||||
@ -270,11 +275,11 @@ public class Quest {
|
||||
public void completeQuest(Quester q) {
|
||||
|
||||
Player player = plugin.getServer().getPlayer(q.id);
|
||||
q.resetObjectives();
|
||||
q.resetObjectives(this);
|
||||
q.completedQuests.add(name);
|
||||
String none = ChatColor.GRAY + "- (" + Lang.get("none") + ")";
|
||||
|
||||
String ps = Quests.parseString(finished, q.currentQuest);
|
||||
String ps = Quests.parseString(finished, this);
|
||||
|
||||
for (String msg : ps.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
@ -366,7 +371,7 @@ public class Quest {
|
||||
}
|
||||
|
||||
String complete = Lang.get("questCompleteTitle");
|
||||
complete = complete.replaceAll("<quest>", ChatColor.YELLOW + q.currentQuest.name + ChatColor.GOLD);
|
||||
complete = complete.replaceAll("<quest>", ChatColor.YELLOW + name + ChatColor.GOLD);
|
||||
player.sendMessage(ChatColor.GOLD + complete);
|
||||
player.sendMessage(ChatColor.GREEN + Lang.get("questRewardsTitle"));
|
||||
|
||||
@ -499,10 +504,8 @@ public class Quest {
|
||||
player.sendMessage(none);
|
||||
}
|
||||
|
||||
q.currentQuest = null;
|
||||
|
||||
q.currentStage = null;
|
||||
q.currentStageIndex = 0;
|
||||
q.currentQuests.remove(this);
|
||||
q.questData.remove(this);
|
||||
|
||||
q.saveData();
|
||||
player.updateInventory();
|
||||
@ -512,17 +515,15 @@ public class Quest {
|
||||
public void failQuest(Quester q) {
|
||||
|
||||
Player player = plugin.getServer().getPlayer(q.id);
|
||||
q.resetObjectives();
|
||||
q.resetObjectives(this);
|
||||
|
||||
String title = Lang.get("questTitle");
|
||||
title = title.replaceAll("<quest>", ChatColor.DARK_PURPLE + q.currentQuest.name + ChatColor.AQUA);
|
||||
title = title.replaceAll("<quest>", ChatColor.DARK_PURPLE + name + ChatColor.AQUA);
|
||||
player.sendMessage(ChatColor.AQUA + title);
|
||||
player.sendMessage(ChatColor.RED + Lang.get("questFailed"));
|
||||
|
||||
q.currentQuest = null;
|
||||
|
||||
q.currentStage = null;
|
||||
q.currentStageIndex = 0;
|
||||
q.currentQuests.remove(this);
|
||||
q.questData.remove(this);
|
||||
|
||||
q.saveData();
|
||||
player.updateInventory();
|
||||
|
45
src/main/java/me/blackvein/quests/QuestData.java
Normal file
45
src/main/java/me/blackvein/quests/QuestData.java
Normal file
@ -0,0 +1,45 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class QuestData {
|
||||
|
||||
public Map<Material, Integer> blocksDamaged = new EnumMap<Material, Integer>(Material.class);
|
||||
public Map<Material, Integer> blocksBroken = new EnumMap<Material, Integer>(Material.class);
|
||||
public Map<Material, Integer> blocksPlaced = new EnumMap<Material, Integer>(Material.class);
|
||||
public Map<Material, Integer> blocksUsed = new EnumMap<Material, Integer>(Material.class);
|
||||
public Map<Material, Integer> blocksCut = new EnumMap<Material, Integer>(Material.class);
|
||||
public Map<Integer, Integer> potionsBrewed = new HashMap<Integer, Integer>();
|
||||
public Map<ItemStack, Integer> itemsDelivered = new HashMap<ItemStack, Integer>();
|
||||
public int fishCaught = 0;
|
||||
public int playersKilled = 0;
|
||||
public long delayStartTime = 0;
|
||||
public long delayTimeLeft = -1;
|
||||
public Map<String, Long> playerKillTimes = new HashMap<String, Long>();
|
||||
public Map<Map<Enchantment, Material>, Integer> itemsEnchanted = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
public LinkedList<EntityType> mobsKilled = new LinkedList<EntityType>();
|
||||
public LinkedList<Integer> mobNumKilled = new LinkedList<Integer>();
|
||||
public LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
public LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
public Map<Integer, Boolean> citizensInteracted = new HashMap<Integer, Boolean>();
|
||||
public LinkedList<Integer> citizensKilled = new LinkedList<Integer>();
|
||||
public LinkedList<Integer> citizenNumKilled = new LinkedList<Integer>();
|
||||
public LinkedList<Location> locationsReached = new LinkedList<Location>();
|
||||
public LinkedList<Boolean> hasReached = new LinkedList<Boolean>();
|
||||
public LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
|
||||
public Map<EntityType, Integer> mobsTamed = new EnumMap<EntityType, Integer>(EntityType.class);
|
||||
public Map<DyeColor, Integer> sheepSheared = new EnumMap<DyeColor, Integer>(DyeColor.class);
|
||||
public Map<String, Boolean> passwordsSaid = new HashMap<String, Boolean>();
|
||||
public Map<String, Integer> customObjectiveCounts = new HashMap<String, Integer>();
|
||||
public Map<String, Boolean> eventFired = new HashMap<String, Boolean>();
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -104,12 +104,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
public static PhatLoots phatLoots = null;
|
||||
public static boolean snoop = true;
|
||||
public static boolean npcEffects = true;
|
||||
public static boolean broadcastPartyCreation = true;
|
||||
public static boolean ignoreLockedQuests = false;
|
||||
public static boolean genFilesOnJoin = true;
|
||||
public static int maxPartySize = 0;
|
||||
public static int acceptTimeout = 20;
|
||||
public static int inviteTimeout = 20;
|
||||
public static int maxQuests = 0;
|
||||
public static String effect = "note";
|
||||
public final Map<UUID, Quester> questers = new HashMap<UUID, Quester>();
|
||||
public final List<String> questerBlacklist = new LinkedList<String>();
|
||||
@ -454,23 +452,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
config.set("ignore-locked-quests", false);
|
||||
}
|
||||
|
||||
if (config.contains("broadcast-party-creation")) {
|
||||
broadcastPartyCreation = config.getBoolean("broadcast-party-creation");
|
||||
|
||||
if (config.contains("max-quests")) {
|
||||
maxQuests = config.getInt("max-quests");
|
||||
} else {
|
||||
config.set("broadcast-party-creation", true);
|
||||
}
|
||||
|
||||
if (config.contains("max-party-size")) {
|
||||
maxPartySize = config.getInt("max-party-size");
|
||||
} else {
|
||||
config.set("max-party-size", 0);
|
||||
}
|
||||
|
||||
if (config.contains("party-invite-timeout")) {
|
||||
inviteTimeout = config.getInt("party-invite-timeout");
|
||||
} else {
|
||||
config.set("party-invite-timeout", 20);
|
||||
config.set("max-quests", maxQuests);
|
||||
}
|
||||
|
||||
for (String s : config.getStringList("quester-blacklist")) {
|
||||
@ -643,7 +629,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
player.sendMessage(PINK + "/quests party invite <player> - Invite a player to your party");
|
||||
player.sendMessage(PINK + "/quests party kick <player> - Kick a member from the party");
|
||||
player.sendMessage(PINK + "/quests party setleader <player> - Set a party member as the new leader");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1030,15 +1016,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
|
||||
Quester quester = getQuester(target.getUniqueId());
|
||||
quester.resetObjectives();
|
||||
quester.resetObjectives(questToGive);
|
||||
|
||||
String msg1 = Lang.get("questForceTake");
|
||||
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + questToGive.name + GOLD);
|
||||
cs.sendMessage(GOLD + msg1);
|
||||
String msg2 = Lang.get("questForcedTake");
|
||||
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + questToGive.name + GOLD);
|
||||
target.sendMessage(GREEN + msg2);
|
||||
quester.takeQuest(questToGive, true);
|
||||
|
||||
@ -1152,6 +1138,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
private void adminFinish(final CommandSender cs, String[] args) {
|
||||
|
||||
if (cs.hasPermission("quests.admin.finish")) {
|
||||
|
||||
Player target = null;
|
||||
@ -1172,7 +1159,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
|
||||
Quester quester = getQuester(target.getUniqueId());
|
||||
if (quester.currentQuest == null) {
|
||||
if (quester.currentQuests.isEmpty()) {
|
||||
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replaceAll("<player>", target.getName());
|
||||
@ -1180,15 +1167,22 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
} else {
|
||||
|
||||
Quest found = getQuest(args[2]);
|
||||
|
||||
if(found == null) {
|
||||
cs.sendMessage(RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
String msg1 = Lang.get("questForceFinish");
|
||||
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + found.name + GOLD);
|
||||
cs.sendMessage(GOLD + msg1);
|
||||
String msg2 = Lang.get("questForcedFinish");
|
||||
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + found.name + GOLD);
|
||||
target.sendMessage(GREEN + msg2);
|
||||
quester.currentQuest.completeQuest(quester);
|
||||
found.completeQuest(quester);
|
||||
|
||||
quester.saveData();
|
||||
|
||||
@ -1229,7 +1223,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
}
|
||||
int stage = -1;
|
||||
if (args.length > 2) {
|
||||
if (args.length > 3) {
|
||||
try {
|
||||
stage = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -1247,7 +1241,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
|
||||
Quester quester = getQuester(target.getUniqueId());
|
||||
if (quester.currentQuest == null) {
|
||||
if (quester.currentQuests.isEmpty()) {
|
||||
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replaceAll("<player>", target.getName());
|
||||
@ -1255,11 +1249,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
} else {
|
||||
|
||||
Quest found = getQuest(args[2]);
|
||||
|
||||
if(found == null) {
|
||||
cs.sendMessage(RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
quester.currentQuest.setStage(quester, stage);
|
||||
found.setStage(quester, stage);
|
||||
} catch (InvalidStageException e) {
|
||||
String msg = Lang.get("invalidStageNum");
|
||||
msg = msg.replaceAll("<quest>", PURPLE + quester.currentQuest.name + RED);
|
||||
msg = msg.replaceAll("<quest>", PURPLE + found.name + RED);
|
||||
cs.sendMessage(ChatColor.RED + msg);
|
||||
}
|
||||
|
||||
@ -1277,6 +1278,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
private void adminNextStage(final CommandSender cs, String[] args) {
|
||||
|
||||
if (cs.hasPermission("quests.admin.nextstage")) {
|
||||
|
||||
Player target = null;
|
||||
@ -1297,7 +1299,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
|
||||
Quester quester = getQuester(target.getUniqueId());
|
||||
if (quester.currentQuest == null) {
|
||||
if (quester.currentQuests.isEmpty()) {
|
||||
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replaceAll("<player>", target.getName());
|
||||
@ -1305,15 +1307,22 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
} else {
|
||||
|
||||
Quest found = getQuest(args[2]);
|
||||
|
||||
if(found == null) {
|
||||
cs.sendMessage(RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
String msg1 = Lang.get("questForceNextStage");
|
||||
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + found.name + GOLD);
|
||||
cs.sendMessage(GOLD + msg1);
|
||||
String msg2 = Lang.get("questForcedNextStage");
|
||||
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + found.name + GOLD);
|
||||
target.sendMessage(GREEN + msg2);
|
||||
quester.currentQuest.nextStage(quester);
|
||||
found.nextStage(quester);
|
||||
|
||||
quester.saveData();
|
||||
|
||||
@ -1329,6 +1338,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
private void adminQuit(final CommandSender cs, String[] args) {
|
||||
|
||||
if (cs.hasPermission("quests.admin.quit")) {
|
||||
|
||||
Player target = null;
|
||||
@ -1349,7 +1359,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
|
||||
Quester quester = getQuester(target.getUniqueId());
|
||||
if (quester.currentQuest == null) {
|
||||
if (quester.currentQuests.isEmpty()) {
|
||||
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replaceAll("<player>", target.getName());
|
||||
@ -1357,18 +1367,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
} else {
|
||||
|
||||
quester.resetObjectives();
|
||||
quester.currentStage = null;
|
||||
quester.currentStageIndex = 0;
|
||||
Quest found = getQuest(args[2]);
|
||||
|
||||
if(found == null) {
|
||||
cs.sendMessage(RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
quester.resetObjectives(found);
|
||||
quester.currentQuests.remove(found);
|
||||
quester.questData.remove(found);
|
||||
String msg1 = Lang.get("questForceQuit");
|
||||
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg1 = msg1.replaceAll("<quest>", PURPLE + found.name + GOLD);
|
||||
cs.sendMessage(GOLD + msg1);
|
||||
String msg2 = Lang.get("questForcedQuit");
|
||||
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
|
||||
msg2 = msg2.replaceAll("<quest>", PURPLE + found.name + GOLD);
|
||||
target.sendMessage(GREEN + msg2);
|
||||
quester.currentQuest = null;
|
||||
|
||||
quester.saveData();
|
||||
|
||||
@ -1384,6 +1400,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
private boolean questActionsCommandHandler(final CommandSender cs, String[] args) {
|
||||
|
||||
if (cs instanceof Player) {
|
||||
|
||||
if (args.length == 0) {
|
||||
@ -1402,7 +1419,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUIT"))) {
|
||||
|
||||
questsQuit((Player) cs);
|
||||
questsQuit((Player) cs, args);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_STATS"))) {
|
||||
|
||||
@ -1563,13 +1580,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
private void questsStats(final Player player) {
|
||||
|
||||
Quester quester = getQuester(player.getUniqueId());
|
||||
player.sendMessage(GOLD + "- " + player.getName() + " -");
|
||||
player.sendMessage(YELLOW + Lang.get("questPointsDisplay") + " " + PURPLE + quester.questPoints + "/" + totalQuestPoints);
|
||||
if (quester.currentQuest == null) {
|
||||
if (quester.currentQuests.isEmpty()) {
|
||||
player.sendMessage(YELLOW + Lang.get("currentQuest") + " " + PURPLE + Lang.get("none"));
|
||||
} else {
|
||||
player.sendMessage(YELLOW + Lang.get("currentQuest") + " " + PURPLE + quester.currentQuest.name);
|
||||
player.sendMessage(YELLOW + Lang.get("currentQuest"));
|
||||
for(Quest q : quester.currentQuests.keySet())
|
||||
player.sendMessage(PINK + " - " + PURPLE + q.name);
|
||||
}
|
||||
|
||||
String completed;
|
||||
@ -1599,21 +1619,28 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
player.sendMessage(completed);
|
||||
}
|
||||
|
||||
private boolean questsQuit(final Player player) {
|
||||
private boolean questsQuit(final Player player, String[] args) {
|
||||
|
||||
if (allowQuitting == true) {
|
||||
|
||||
if (((Player) player).hasPermission("quests.quit")) {
|
||||
|
||||
Quester quester = getQuester(player.getUniqueId());
|
||||
if (quester.currentQuest != null) {
|
||||
if (quester.currentQuests.isEmpty() == false) {
|
||||
|
||||
quester.resetObjectives();
|
||||
quester.currentStage = null;
|
||||
quester.currentStageIndex = 0;
|
||||
Quest found = getQuest(args[1]);
|
||||
|
||||
if(found == null) {
|
||||
player.sendMessage(RED + Lang.get("questNotFound"));
|
||||
return true;
|
||||
}
|
||||
|
||||
quester.resetObjectives(found);
|
||||
quester.currentQuests.remove(found);
|
||||
quester.questData.remove(found);
|
||||
String msg = Lang.get("questQuit");
|
||||
msg = msg.replaceAll("<quest>", PURPLE + quester.currentQuest.name + YELLOW);
|
||||
msg = msg.replaceAll("<quest>", PURPLE + found.name + YELLOW);
|
||||
player.sendMessage(YELLOW + msg);
|
||||
quester.currentQuest = null;
|
||||
quester.saveData();
|
||||
quester.loadData();
|
||||
return true;
|
||||
@ -1694,8 +1721,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
final Quest q = questToFind;
|
||||
final Quester quester = getQuester(player.getUniqueId());
|
||||
|
||||
if (quester.currentQuest != null) {
|
||||
player.sendMessage(YELLOW + Lang.get("questOneActive"));
|
||||
if (quester.currentQuests.size() >= maxQuests) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(maxQuests));
|
||||
player.sendMessage(YELLOW + msg);
|
||||
} else if (quester.completedQuests.contains(q.name) && q.redoDelay < 0) {
|
||||
String msg = Lang.get("questAlreadyCompleted");
|
||||
msg = msg.replaceAll("<quest>", PURPLE + q.name + YELLOW);
|
||||
@ -2077,6 +2106,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
|
||||
private void showObjectives(final Player player) {
|
||||
|
||||
if (getQuester(player.getUniqueId()).currentQuest != null) {
|
||||
|
||||
if (getQuester(player.getUniqueId()).delayStartTime == 0) {
|
||||
@ -2094,6 +2124,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
player.sendMessage(YELLOW + Lang.get("noActiveQuest"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void printAdminHelp(CommandSender cs) {
|
||||
|
21
src/main/java/me/blackvein/quests/lang_modified
Normal file
21
src/main/java/me/blackvein/quests/lang_modified
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
-MODIFIED-
|
||||
|
||||
COMMAND_QUIT_HELP
|
||||
COMMAND_QUESTADMIN_NEXTSTAGE_HELP
|
||||
COMMAND_QUESTADMIN_SETSTAGE_HELP
|
||||
COMMAND_QUESTADMIN_SETSTAGE_USAGE
|
||||
COMMAND_QUESTADMIN_QUIT_HELP
|
||||
|
||||
currentQuest
|
||||
noCurrentQuest
|
||||
noActiveQuest
|
||||
|
||||
|
||||
-REMOVED-
|
||||
|
||||
questOneActive
|
||||
|
||||
-ADDED-
|
||||
|
||||
questMaxAllowed
|
@ -128,7 +128,9 @@ public class QuestAcceptPrompt extends StringPrompt implements ColorUtil {
|
||||
|
||||
} else if (quester.currentQuest.equals(q) == false) {
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("questOneActive"));
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
@ -158,7 +160,9 @@ public class QuestAcceptPrompt extends StringPrompt implements ColorUtil {
|
||||
|
||||
} else if (quester.currentQuest.equals(q) == false) {
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("questOneActive"));
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class Lang {
|
||||
//Quests
|
||||
|
||||
langMap.put("questFailed", "*QUEST FAILED*");
|
||||
langMap.put("questOneActive", "You may only have one active Quest.");
|
||||
langMap.put("questMaxAllowed", "You may only have up to <number> Quests.");
|
||||
langMap.put("questTooEarly", "You may not take <quest> again for another <time>.");
|
||||
langMap.put("questAlreadyCompleted", "You have already completed <quest>.");
|
||||
langMap.put("questInvalidLocation", "You may not take <quest> at this location.");
|
||||
@ -88,7 +88,7 @@ public class Lang {
|
||||
langMap.put("COMMAND_TAKE_USAGE", "Usage: /quests take [quest]");
|
||||
|
||||
langMap.put("COMMAND_QUIT", "quit");
|
||||
langMap.put("COMMAND_QUIT_HELP", "quit - Quit your current Quest");
|
||||
langMap.put("COMMAND_QUIT_HELP", "quit [quest] - Quit a current Quest");
|
||||
|
||||
langMap.put("COMMAND_EDITOR", "editor");
|
||||
langMap.put("COMMAND_EDITOR_HELP", "editor - Create/Edit Quests");
|
||||
@ -115,7 +115,7 @@ public class Lang {
|
||||
langMap.put("COMMAND_QUESTADMIN_GIVE_HELP", "give [player] [quest] - Force a player to take a Quest");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_QUIT", "quit");
|
||||
langMap.put("COMMAND_QUESTADMIN_QUIT_HELP", "quit [player] - Force a player to quit their Quest");
|
||||
langMap.put("COMMAND_QUESTADMIN_QUIT_HELP", "quit [player] [quest] - Force a player to quit their Quest");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_POINTS", "points");
|
||||
langMap.put("COMMAND_QUESTADMIN_POINTS_HELP", "points [player] [amount] - Set a players Quest Points");
|
||||
@ -130,14 +130,14 @@ public class Lang {
|
||||
langMap.put("COMMAND_QUESTADMIN_POINTSALL_HELP", "pointsall [amount] - Set ALL players' Quest Points");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_FINISH", "finish");
|
||||
langMap.put("COMMAND_QUESTADMIN_FINISH_HELP", "finish [player] - Immediately force Quest completion for a player");
|
||||
langMap.put("COMMAND_QUESTADMIN_FINISH_HELP", "finish [player] [quest] - Immediately force Quest completion for a player");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_NEXTSTAGE", "nextstage");
|
||||
langMap.put("COMMAND_QUESTADMIN_NEXTSTAGE_HELP", "nextstage [player] - Immediately force Stage completion for a player");
|
||||
langMap.put("COMMAND_QUESTADMIN_NEXTSTAGE_HELP", "nextstage [player] [quest] - Immediately force Stage completion for a player");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE", "setstage");
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_HELP", "setstage [player] [stage] - Set the current Stage for a player");
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_USAGE", "Usage: /questadmin setstage [player] [stage]");
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_HELP", "setstage [player] [quest] [stage] - Set the current Stage for a player");
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_USAGE", "Usage: /questadmin setstage [player] [quest] [stage]");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_TOGGLEGUI", "togglegui");
|
||||
langMap.put("COMMAND_QUESTADMIN_TOGGLEGUI_HELP", "togglegui [npc id] - Toggle GUI Quest Display on an NPC");
|
||||
@ -812,7 +812,7 @@ public class Lang {
|
||||
langMap.put("acceptQuest", "Accept Quest?");
|
||||
langMap.put("enterAnOption", "Enter an option");
|
||||
langMap.put("questAccepted", "Quest accepted: <quest>");
|
||||
langMap.put("currentQuest", "Current Quest:");
|
||||
langMap.put("currentQuest", "Current Quests:");
|
||||
|
||||
//Objectives
|
||||
langMap.put("damage", "Damage");
|
||||
@ -835,7 +835,7 @@ public class Lang {
|
||||
//
|
||||
|
||||
langMap.put("invalidSelection", "Invalid selection!");
|
||||
langMap.put("noActiveQuest", "You do not currently have an active Quest.");
|
||||
langMap.put("noActiveQuest", "You do not currently have any active Quests.");
|
||||
langMap.put("speakTo", "Start: Speak to <npc>");
|
||||
langMap.put("mustSpeakTo", "You must speak to <npc> to start this Quest.");
|
||||
langMap.put("noCommandStart", "<quest> may not be started via command.");
|
||||
@ -913,7 +913,7 @@ public class Lang {
|
||||
langMap.put("disableNPCGUI", "<npc> will no longer provide a GUI Quest Display.");
|
||||
|
||||
langMap.put("invalidNumber", "Invalid number.");
|
||||
langMap.put("noCurrentQuest", "<player> does not currently have an active Quest.");
|
||||
langMap.put("noCurrentQuest", "<player> does not currently have any active Quests.");
|
||||
langMap.put("playerNotFound", "Player not found.");
|
||||
langMap.put("invalidStageNum", "Invalid stage number for Quest <quest>");
|
||||
langMap.put("errorNPCID", "Error: There is no NPC with ID <number>");
|
||||
|
@ -10,9 +10,7 @@ accept-timeout: 20
|
||||
snoop: true
|
||||
show-npc-effects: true
|
||||
npc-effect: "note"
|
||||
max-party-size: 0
|
||||
party-invite-timeout: 20
|
||||
broadcast-party-creation: true
|
||||
max-quests: 0
|
||||
quester-blacklist:
|
||||
- "SomeGuy12345"
|
||||
- "somePrefix*"
|
||||
|
Loading…
Reference in New Issue
Block a user