Finished Updating to 1.7.2

Added number of times completed of redoable Quests in /quests stats
This commit is contained in:
Blackvein 2013-12-30 16:11:41 -08:00
parent 69b883b408
commit f68521c691
5 changed files with 2088 additions and 2049 deletions

Binary file not shown.

View File

@ -38,6 +38,7 @@ public class Quester {
Quests plugin; Quests plugin;
public LinkedList<String> completedQuests = new LinkedList<String>(); public LinkedList<String> completedQuests = new LinkedList<String>();
Map<String, Long> completedTimes = new HashMap<String, Long>(); Map<String, Long> completedTimes = new HashMap<String, Long>();
Map<String, Integer> amountsCompleted = new HashMap<String, Integer>();
Map<Material, Integer> blocksDamaged = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksDamaged = new EnumMap<Material, Integer>(Material.class);
Map<Material, Integer> blocksBroken = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksBroken = new EnumMap<Material, Integer>(Material.class);
Map<Material, Integer> blocksPlaced = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksPlaced = new EnumMap<Material, Integer>(Material.class);
@ -78,15 +79,18 @@ public class Quester {
} }
public void takeQuest(Quest q) { public void takeQuest(Quest q, boolean override) {
Player player = plugin.getServer().getPlayer(name); Player player = plugin.getServer().getPlayer(name);
if (q.testRequirements(player) == true) { if (q.testRequirements(player) == true || override) {
currentQuest = q; currentQuest = q;
currentStage = q.orderedStages.getFirst(); currentStage = q.orderedStages.getFirst();
addEmpties(); addEmpties();
if(!override){
if (q.moneyReq > 0) { if (q.moneyReq > 0) {
Quests.economy.withdrawPlayer(name, q.moneyReq); Quests.economy.withdrawPlayer(name, q.moneyReq);
} }
@ -99,6 +103,10 @@ public class Quester {
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name); player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
player.sendMessage(""); player.sendMessage("");
}
player.sendMessage(ChatColor.GOLD + "---(Objectives)---"); player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
for (String s : getObjectives()) { for (String s : getObjectives()) {
player.sendMessage(s); player.sendMessage(s);
@ -124,6 +132,8 @@ public class Quester {
if(currentStage.startEvent != null) if(currentStage.startEvent != null)
currentStage.startEvent.fire(this); currentStage.startEvent.fire(this);
saveData();
} else { } else {
player.sendMessage(q.failRequirements); player.sendMessage(q.failRequirements);
@ -992,7 +1002,7 @@ public class Quester {
} else if (objective.equalsIgnoreCase("deliverItem")) { } else if (objective.equalsIgnoreCase("deliverItem")) {
String message = ChatColor.GREEN + "(Completed) Deliver " + ItemUtil.getString(currentStage.itemsToDeliver.get(currentStage.itemsToDeliver.indexOf(itemstack))) + " " + ItemUtil.getName(itemstack) + " to " + plugin.getNPCName(currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(itemstack))); String message = ChatColor.GREEN + "(Completed) Deliver " + ItemUtil.getString(currentStage.itemsToDeliver.get(currentStage.itemsToDeliver.indexOf(itemstack))) + " to " + plugin.getNPCName(currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(itemstack)));
p.sendMessage(message); p.sendMessage(message);
if (testComplete()) { if (testComplete()) {
currentQuest.nextStage(this); currentQuest.nextStage(this);
@ -1529,23 +1539,6 @@ public class Quester {
FileConfiguration data = new YamlConfiguration(); FileConfiguration data = new YamlConfiguration();
if (completedTimes.isEmpty() == false) {
List<String> questTimeNames = new LinkedList<String>();
List<Long> questTimes = new LinkedList<Long>();
for (String s : completedTimes.keySet()) {
questTimeNames.add(s);
questTimes.add(completedTimes.get(s));
}
data.set("completedRedoableQuests", questTimeNames);
data.set("completedQuestTimes", questTimes);
}
if (currentQuest != null) { if (currentQuest != null) {
data.set("currentQuest", currentQuest.name); data.set("currentQuest", currentQuest.name);
@ -1871,6 +1864,40 @@ public class Quester {
} }
if (completedTimes.isEmpty() == false) {
List<String> questTimeNames = new LinkedList<String>();
List<Long> questTimes = new LinkedList<Long>();
for (String s : completedTimes.keySet()) {
questTimeNames.add(s);
questTimes.add(completedTimes.get(s));
}
data.set("completedRedoableQuests", questTimeNames);
data.set("completedQuestTimes", questTimes);
}
if (amountsCompleted.isEmpty() == false) {
List<String> list1 = new LinkedList<String>();
List<Integer> list2 = new LinkedList<Integer>();
for(Entry<String, Integer> entry : amountsCompleted.entrySet()){
list1.add(entry.getKey());
list2.add(entry.getValue());
}
data.set("amountsCompletedQuests", list1);
data.set("amountsCompleted", list2);
}
return data; return data;
} }
@ -1907,6 +1934,21 @@ public class Quester {
} }
amountsCompleted.clear();
if (data.contains("amountsCompletedQuests")) {
List<String> list1 = data.getStringList("amountsCompletedQuests");
List<Integer> list2 = data.getIntegerList("amountsCompleted");
for(int i = 0; i < list1.size(); i++){
amountsCompleted.put(list1.get(i), list2.get(i));
}
}
questPoints = data.getInt("quest-points"); questPoints = data.getInt("quest-points");
if (data.isList("completed-Quests")) { if (data.isList("completed-Quests")) {

View File

@ -335,7 +335,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (s.equalsIgnoreCase("Yes")) { if (s.equalsIgnoreCase("Yes")) {
getQuester(player.getName()).takeQuest(getQuest(getQuester(player.getName()).questToTake)); getQuester(player.getName()).takeQuest(getQuest(getQuester(player.getName()).questToTake), false);
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} else if (s.equalsIgnoreCase("No")) { } else if (s.equalsIgnoreCase("No")) {
@ -983,10 +983,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
completed = PURPLE + ""; completed = PURPLE + "";
for (String s : quester.completedQuests) { for (String s : quester.completedQuests) {
completed += s;
if (quester.amountsCompleted.containsKey(s) && quester.amountsCompleted.get(s) > 1){
completed += PINK + " (x" + quester.amountsCompleted.get(s) + ")";
}
if (quester.completedQuests.indexOf(s) < (quester.completedQuests.size() - 1)) { if (quester.completedQuests.indexOf(s) < (quester.completedQuests.size() - 1)) {
completed = completed + s + ", "; completed += ", ";
} else {
completed = completed + s;
} }
} }
@ -1387,16 +1391,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} catch (IOException e) { } catch (IOException e) {
if (failCount < 4) { if (failCount < 10) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping.."); cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping..");
failCount++;
} else if (suppressed == false) { } else if (suppressed == false) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors."); cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors.");
suppressed = true; suppressed = true;
} }
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
if (failCount < 4) { if (failCount < 10) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping.."); cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping..");
failCount++;
} else if (suppressed == false) { } else if (suppressed == false) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors."); cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors.");
suppressed = true; suppressed = true;
@ -1506,20 +1512,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getName());
quester.resetObjectives(); quester.resetObjectives();
quester.currentQuest = questToGive;
quester.currentStage = questToGive.orderedStages.getFirst();
quester.addEmpties();
cs.sendMessage(GREEN + target.getName() + GOLD + " has forcibly started the Quest " + PURPLE + questToGive.name + GOLD + "."); cs.sendMessage(GREEN + target.getName() + GOLD + " has forcibly started the Quest " + PURPLE + questToGive.name + GOLD + ".");
target.sendMessage(GREEN + cs.getName() + GOLD + " has forced you to take the Quest " + PURPLE + questToGive.name + GOLD + "."); target.sendMessage(GREEN + "You have been forced to take the Quest " + PURPLE + questToGive.name + GOLD + ".");
target.sendMessage(GOLD + "---(Objectives)---"); quester.takeQuest(questToGive, true);
for (String s : quester.getObjectives()) {
target.sendMessage(s);
}
quester.saveData();
} }

View File

@ -750,7 +750,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
} }
if (list.isEmpty()) { if (list.isEmpty()) {
text += GRAY + "(None)"; text += GRAY + "(None)\n";
} else { } else {
Collections.sort(list); Collections.sort(list);
@ -818,7 +818,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
} }
if (list.isEmpty()) { if (list.isEmpty()) {
text += GRAY + "(None)"; text += GRAY + "(None)\n";
} else { } else {
Collections.sort(list); Collections.sort(list);

View File

@ -957,7 +957,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil {
} }
if (list.isEmpty()) { if (list.isEmpty()) {
text += GRAY + "(None)"; text += GRAY + "(None)\n";
} else { } else {
Collections.sort(list); Collections.sort(list);