mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-25 03:55:35 +01:00
Finished Updating to 1.7.2
Added number of times completed of redoable Quests in /quests stats
This commit is contained in:
parent
69b883b408
commit
f68521c691
BIN
lib/Heroes.jar
BIN
lib/Heroes.jar
Binary file not shown.
@ -38,6 +38,7 @@ public class Quester {
|
||||
Quests plugin;
|
||||
public LinkedList<String> completedQuests = new LinkedList<String>();
|
||||
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> blocksBroken = new EnumMap<Material, Integer>(Material.class);
|
||||
Map<Material, Integer> blocksPlaced = new EnumMap<Material, Integer>(Material.class);
|
||||
@ -78,27 +79,34 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
public void takeQuest(Quest q) {
|
||||
public void takeQuest(Quest q, boolean override) {
|
||||
|
||||
Player player = plugin.getServer().getPlayer(name);
|
||||
|
||||
if (q.testRequirements(player) == true) {
|
||||
if (q.testRequirements(player) == true || override) {
|
||||
|
||||
currentQuest = q;
|
||||
currentStage = q.orderedStages.getFirst();
|
||||
addEmpties();
|
||||
if (q.moneyReq > 0) {
|
||||
Quests.economy.withdrawPlayer(name, q.moneyReq);
|
||||
}
|
||||
|
||||
for (ItemStack is : q.items) {
|
||||
if (q.removeItems.get(q.items.indexOf(is)) == true) {
|
||||
Quests.removeItem(player.getInventory(), is);
|
||||
|
||||
if(!override){
|
||||
|
||||
if (q.moneyReq > 0) {
|
||||
Quests.economy.withdrawPlayer(name, q.moneyReq);
|
||||
}
|
||||
|
||||
for (ItemStack is : q.items) {
|
||||
if (q.removeItems.get(q.items.indexOf(is)) == true) {
|
||||
Quests.removeItem(player.getInventory(), is);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
|
||||
player.sendMessage("");
|
||||
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
|
||||
player.sendMessage("");
|
||||
|
||||
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for (String s : getObjectives()) {
|
||||
player.sendMessage(s);
|
||||
@ -124,6 +132,8 @@ public class Quester {
|
||||
if(currentStage.startEvent != null)
|
||||
currentStage.startEvent.fire(this);
|
||||
|
||||
saveData();
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(q.failRequirements);
|
||||
@ -992,7 +1002,7 @@ public class Quester {
|
||||
|
||||
} 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);
|
||||
if (testComplete()) {
|
||||
currentQuest.nextStage(this);
|
||||
@ -1529,23 +1539,6 @@ public class Quester {
|
||||
|
||||
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) {
|
||||
|
||||
data.set("currentQuest", currentQuest.name);
|
||||
@ -1870,6 +1863,40 @@ public class Quester {
|
||||
data.set("completed-Quests", completed);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -1906,6 +1933,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");
|
||||
|
||||
|
@ -335,7 +335,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
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;
|
||||
|
||||
} else if (s.equalsIgnoreCase("No")) {
|
||||
@ -983,10 +983,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
completed = PURPLE + "";
|
||||
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)) {
|
||||
completed = completed + s + ", ";
|
||||
} else {
|
||||
completed = completed + s;
|
||||
completed += ", ";
|
||||
}
|
||||
|
||||
}
|
||||
@ -1387,16 +1391,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
if (failCount < 4) {
|
||||
if (failCount < 10) {
|
||||
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping..");
|
||||
failCount++;
|
||||
} else if (suppressed == false) {
|
||||
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors.");
|
||||
suppressed = true;
|
||||
}
|
||||
|
||||
} catch (InvalidConfigurationException e) {
|
||||
if (failCount < 4) {
|
||||
if (failCount < 10) {
|
||||
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping..");
|
||||
failCount++;
|
||||
} else if (suppressed == false) {
|
||||
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors.");
|
||||
suppressed = true;
|
||||
@ -1506,20 +1512,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else {
|
||||
|
||||
Quester quester = getQuester(target.getName());
|
||||
|
||||
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 + ".");
|
||||
target.sendMessage(GREEN + cs.getName() + GOLD + " has forced you to take the Quest " + PURPLE + questToGive.name + GOLD + ".");
|
||||
target.sendMessage(GOLD + "---(Objectives)---");
|
||||
for (String s : quester.getObjectives()) {
|
||||
target.sendMessage(s);
|
||||
}
|
||||
|
||||
quester.saveData();
|
||||
target.sendMessage(GREEN + "You have been forced to take the Quest " + PURPLE + questToGive.name + GOLD + ".");
|
||||
quester.takeQuest(questToGive, true);
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user