Finished catches for (hopefully) all quest-reading errors.

This commit is contained in:
Blackvein 2012-10-12 07:20:39 -07:00
parent 92bf724fe6
commit 2fae0182a6
6 changed files with 1311 additions and 523 deletions

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -239,6 +240,9 @@ public class Event {
public static Event getEvent(String name, Quests plugin, Quest quest){ public static Event getEvent(String name, Quests plugin, Quest quest){
if(name == null || plugin == null || quest == null)
return null;
Event event = new Event(); Event event = new Event();
FileConfiguration data = new YamlConfiguration(); FileConfiguration data = new YamlConfiguration();
@ -254,96 +258,324 @@ public class Event {
if(data.contains(eventKey + "message")) if(data.contains(eventKey + "message"))
event.message = plugin.parseString(data.getString(eventKey + "message"), quest); event.message = plugin.parseString(data.getString(eventKey + "message"), quest);
if(data.contains(eventKey + "clear-inventory")) if(data.contains(eventKey + "clear-inventory")){
event.clearInv = data.getBoolean(eventKey + "clear-inventory");
if(data.isBoolean(eventKey + "clear-inventory"))
event.clearInv = data.getBoolean(eventKey + "clear-inventory");
else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "clear-inventory: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!");
return null;
}
}
if(data.contains(eventKey + "explosions")){ if(data.contains(eventKey + "explosions")){
for(String s : data.getStringList(eventKey + "explosions")){ if(Quests.checkList(data.getList(eventKey + "explosions"), String.class)){
Location loc = Quests.getLocation(s); for(String s : data.getStringList(eventKey + "explosions")){
event.explosions.add(loc); Location loc = Quests.getLocation(s);
if(loc == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + loc + ChatColor.GOLD + " inside " + ChatColor.GREEN + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.log.severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
event.explosions.add(loc);
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
} }
} }
if(data.contains(eventKey + "effects")){ if(data.contains(eventKey + "effects")){
List<String> effectList = data.getStringList(eventKey + "effects"); if(Quests.checkList(data.getList(eventKey + "effects"), String.class)){
List<String> effectLocs = data.getStringList(eventKey + "effect-locations");
for(String s : effectLocs) if(data.contains(eventKey + "effect-locations")){
event.effects.put(Quests.getLocation(s), Quests.getEffect(effectList.get(effectLocs.indexOf(s))));
if(Quests.checkList(data.getList(eventKey + "effect-locations"), String.class)){
List<String> effectList = data.getStringList(eventKey + "effects");
List<String> effectLocs = data.getStringList(eventKey + "effect-locations");
for(String s : effectList){
Effect effect = Quests.getEffect(s);
Location l = Quests.getLocation(effectLocs.get(effectList.indexOf(s)));
if(effect == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid effect name!");
return null;
}
if(l == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + effectLocs.get(effectList.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.log.severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
event.effects.put(l, effect);
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "effect-locations:");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of effects!");
return null;
}
} }
if(data.contains(eventKey + "item-ids")){ if(data.contains(eventKey + "item-ids")){
List<Material> itemIds = new LinkedList<Material>(); if(Quests.checkList(data.getList(eventKey + "item-ids"), Integer.class)){
for(Integer i : data.getIntegerList(eventKey + "item-ids")) if(data.contains(eventKey + "item-amounts")){
itemIds.add(Material.getMaterial(i));
List<Integer> itemAmounts = data.getIntegerList(eventKey + "item-amounts"); if(Quests.checkList(data.getList(eventKey + "item-amounts"), Integer.class)){
for(Material m : itemIds) List<Material> itemIds = new LinkedList<Material>();
event.items.put(m, itemAmounts.get(itemIds.indexOf(m)));
for(Integer i : data.getIntegerList(eventKey + "item-ids")){
Material m = Material.getMaterial(i);
if(m != null)
itemIds.add(m);
else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + i + ChatColor.GOLD + " inside " + ChatColor.GREEN + " item-ids: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid item id!");
return null;
}
}
List<Integer> itemAmounts = data.getIntegerList(eventKey + "item-amounts");
for(Material m : itemIds)
event.items.put(m, itemAmounts.get(itemIds.indexOf(m)));
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "item-amounts: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "item-amounts:");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "item-ids: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of item ids!");
return null;
}
} }
if(data.contains(eventKey + "storm-world")){ if(data.contains(eventKey + "storm-world")){
event.stormDuration = data.getInt(eventKey + "storm-duration");
event.stormWorld = plugin.getServer().getWorld(data.getString(eventKey + "storm-world")); World w = plugin.getServer().getWorld(data.getString(eventKey + "storm-world"));
if(w == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!");
return null;
}
if(data.contains(eventKey + "storm-duration")){
if (data.getInt(eventKey + "storm-duration", -999) != -999) {
event.stormDuration = data.getInt(eventKey + "storm-duration");
} else {
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
event.stormWorld = w;
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "storm-duration:");
return null;
}
} }
if(data.contains(eventKey + "thunder-world")){ if(data.contains(eventKey + "thunder-world")){
event.thunderDuration = data.getInt(eventKey + "thunder-duration");
event.thunderWorld = plugin.getServer().getWorld(data.getString(eventKey + "thunder-world")); World w = plugin.getServer().getWorld(data.getString(eventKey + "thunder-world"));
if(w == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!");
return null;
}
if(data.contains(eventKey + "thunder-duration")){
if (data.getInt(eventKey + "thunder-duration", -999) != -999) {
event.thunderDuration = data.getInt(eventKey + "thunder-duration");
} else {
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
event.thunderWorld = w;
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "thunder-duration:");
return null;
}
} }
if(data.contains(eventKey + "mob-spawn-locations")){ if(data.contains(eventKey + "mob-spawn-locations")){
List<String> mobLocs = data.getStringList(eventKey + "mob-spawn-locations"); if(Quests.checkList(data.getList(eventKey + "mob-spawn-locations"), String.class)){
List<String> mobTypes = data.getStringList(eventKey + "mob-spawn-types");
List<Integer> mobAmounts = data.getIntegerList(eventKey + "mob-spawn-amounts");
for(String s : mobLocs){ if(data.contains(eventKey + "mob-spawn-types")){
Location location = Quests.getLocation(s); if(Quests.checkList(data.getList(eventKey + "mob-spawn-types"), String.class)){
EntityType type = Quests.getMobType(mobTypes.get(mobLocs.indexOf(s)));
int amount = mobAmounts.get(mobLocs.indexOf(s));
event.mobSpawnLocs.add(location); if(data.contains(eventKey + "mob-spawn-amounts")){
event.mobSpawnTypes.add(type);
event.mobSpawnAmounts.add(amount);
if(Quests.checkList(data.getList(eventKey + "mob-spawn-amounts"), Integer.class)){
List<String> mobLocs = data.getStringList(eventKey + "mob-spawn-locations");
List<String> mobTypes = data.getStringList(eventKey + "mob-spawn-types");
List<Integer> mobAmounts = data.getIntegerList(eventKey + "mob-spawn-amounts");
for(String s : mobLocs){
Location location = Quests.getLocation(s);
if(location == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.log.severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
EntityType type = Quests.getMobType(mobTypes.get(mobLocs.indexOf(s)));
if(type == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + mobTypes.get(mobLocs.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid mob name!");
return null;
}
int amount = mobAmounts.get(mobLocs.indexOf(s));
event.mobSpawnLocs.add(location);
event.mobSpawnTypes.add(type);
event.mobSpawnAmounts.add(amount);
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-amounts: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "mob-spawn-amounts:");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of mob names!");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "mob-spawn-types:");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
} }
} }
if(data.contains(eventKey + "lightning-strikes")){ if(data.contains(eventKey + "lightning-strikes")){
for(String s : data.getStringList(eventKey + "lightning-strikes")){ if(Quests.checkList(data.getList(eventKey + "lightning-strikes"), String.class)){
Location loc = Quests.getLocation(s); for(String s : data.getStringList(eventKey + "lightning-strikes")){
event.lightningStrikes.add(loc);
Location loc = Quests.getLocation(s);
if(loc == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.log.severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
event.lightningStrikes.add(loc);
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
} }
} }
if(data.contains(eventKey + "potion-effect-types")){ if(data.contains(eventKey + "potion-effect-types")){
List<String> types = data.getStringList(eventKey + "potion-effect-types"); if(Quests.checkList(data.getList(eventKey + "potion-effect-types"), String.class)){
List<Integer> durations = data.getIntegerList(eventKey + "potion-effect-durations");
List<Integer> amplifiers = data.getIntegerList(eventKey + "potion-effect-amplifiers");
for(String s : types){ if(data.contains(eventKey + "potion-effect-durations")){
PotionEffect effect = Quests.getPotionEffect(s, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s))); if(Quests.checkList(data.getList(eventKey + "potion-effect-durations"), Integer.class)){
event.potionEffects.add(effect);
if(data.contains(eventKey + "potion-effect-amplifiers")){
if(Quests.checkList(data.getList(eventKey + "potion-effect-amplifiers"), Integer.class)){
List<String> types = data.getStringList(eventKey + "potion-effect-types");
List<Integer> durations = data.getIntegerList(eventKey + "potion-effect-durations");
List<Integer> amplifiers = data.getIntegerList(eventKey + "potion-effect-amplifiers");
for(String s : types){
PotionEffect effect = Quests.getPotionEffect(s, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s)));
if(effect == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid potion effect name!");
return null;
}
event.potionEffects.add(effect);
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-amplifiers: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-amplifiers:");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-durations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-durations:");
return null;
}
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of potion effects!");
return null;
} }
@ -351,25 +583,53 @@ public class Event {
if(data.contains(eventKey + "hunger")){ if(data.contains(eventKey + "hunger")){
event.hunger = data.getInt(eventKey + "hunger"); if (data.getInt(eventKey + "hunger", -999) != -999) {
event.hunger = data.getInt(eventKey + "hunger");
} else {
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "hunger: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
} }
if(data.contains(eventKey + "saturation")){ if(data.contains(eventKey + "saturation")){
event.saturation = data.getInt(eventKey + "saturation"); if (data.getInt(eventKey + "saturation", -999) != -999) {
event.saturation = data.getInt(eventKey + "saturation");
} else {
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "saturation: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
} }
if(data.contains(eventKey + "health")){ if(data.contains(eventKey + "health")){
event.health = data.getInt(eventKey + "health"); if (data.getInt(eventKey + "health", -999) != -999) {
event.health = data.getInt(eventKey + "health");
} else {
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "health: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
} }
if(data.contains(eventKey + "teleport-location")){ if(data.contains(eventKey + "teleport-location")){
event.teleport = Quests.getLocation(data.getString(eventKey + "teleport-location")); if(data.isString(eventKey + "teleport-location")){
Location l = Quests.getLocation(data.getString(eventKey + "teleport-location"));
if(l == null){
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + data.getString(eventKey + "teleport-location") + ChatColor.GOLD + "for " + ChatColor.GREEN + " teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.log.severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
event.teleport = l;
}else{
Quests.log.severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a location!");
return null;
}
} }

View File

@ -10,7 +10,6 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class NpcListener implements Listener{ public class NpcListener implements Listener{

View File

@ -247,7 +247,6 @@ public class PlayerListener implements Listener {
Sheep sheep = (Sheep) evt.getEntity(); Sheep sheep = (Sheep) evt.getEntity();
quester.shearSheep(sheep.getColor()); quester.shearSheep(sheep.getColor());
} }
} }
@ -473,9 +472,20 @@ public class PlayerListener implements Listener {
} }
plugin.questers.add(quester); plugin.questers.add(quester);
for(Quest q : quester.completedQuests){ for(String s : quester.completedQuests){
if(quester.completedTimes.containsKey(q) == false && q.redoDelay > -1)
quester.completedTimes.put(q, System.currentTimeMillis()); for(Quest q : plugin.quests){
if(q.name.equalsIgnoreCase(s)){
if(quester.completedTimes.containsKey(q.name) == false && q.redoDelay > -1)
quester.completedTimes.put(q.name, System.currentTimeMillis());
}
}
} }
quester.checkQuest(); quester.checkQuest();
@ -494,7 +504,13 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent evt){ public void onPlayerMove(PlayerMoveEvent evt){
if(plugin.citizens.getNPCRegistry().isNPC(evt.getPlayer()) == false){ boolean isPlayer = true;
if(plugin.getServer().getPluginManager().getPlugin("Citizens") != null){
if(plugin.citizens.getNPCRegistry().isNPC(evt.getPlayer()))
isPlayer = false;
}
if(isPlayer){
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getName());

View File

@ -34,7 +34,7 @@ public class Quest {
List<Integer> itemAmounts = new LinkedList<Integer>(); List<Integer> itemAmounts = new LinkedList<Integer>();
List<Boolean> removeItems = new LinkedList<Boolean>(); List<Boolean> removeItems = new LinkedList<Boolean>();
List<Quest> neededQuests = new LinkedList<Quest>(); List<String> neededQuests = new LinkedList<String>();
List<String> permissionReqs = new LinkedList<String>(); List<String> permissionReqs = new LinkedList<String>();
@ -142,12 +142,12 @@ public class Quest {
Player player = plugin.getServer().getPlayerExact(q.name); Player player = plugin.getServer().getPlayerExact(q.name);
q.reset(); q.reset();
q.completedQuests.add(this); q.completedQuests.add(name);
String none = ChatColor.GRAY + "- (None)"; String none = ChatColor.GRAY + "- (None)";
player.sendMessage(plugin.parseString(finished, q.currentQuest)); player.sendMessage(plugin.parseString(finished, q.currentQuest));
Quests.economy.depositPlayer(q.name, moneyReward); Quests.economy.depositPlayer(q.name, moneyReward);
if(redoDelay > -1) if(redoDelay > -1)
q.completedTimes.put(this, System.currentTimeMillis()); q.completedTimes.put(this.name, System.currentTimeMillis());
for(ItemStack i : itemRewards){ for(ItemStack i : itemRewards){
Quests.addItem(player, i); Quests.addItem(player, i);

View File

@ -26,9 +26,9 @@ public class Quester{
Quests plugin; Quests plugin;
boolean isTalking = false; boolean isTalking = false;
LinkedList<Quest> completedQuests = new LinkedList<Quest>(); LinkedList<String> completedQuests = new LinkedList<String>();
Map<Quest, Long> completedTimes = new HashMap<Quest, Long>(); Map<String, Long> completedTimes = new HashMap<String, Long>();
Map<Material, Integer> blocksDamaged = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksDamaged = new EnumMap<Material, Integer>(Material.class);
@ -1406,11 +1406,11 @@ public class Quester{
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long lastTime; long lastTime;
if(completedTimes.containsKey(q) == false){ if(completedTimes.containsKey(q.name) == false){
lastTime = System.currentTimeMillis(); lastTime = System.currentTimeMillis();
completedTimes.put(q, System.currentTimeMillis()); completedTimes.put(q.name, System.currentTimeMillis());
}else{ }else{
lastTime = completedTimes.get(q); lastTime = completedTimes.get(q.name);
} }
long comparator = q.redoDelay; long comparator = q.redoDelay;
long difference = (comparator - (currentTime - lastTime)); long difference = (comparator - (currentTime - lastTime));
@ -1429,10 +1429,10 @@ public class Quester{
List<String> questTimeNames = new LinkedList<String>(); List<String> questTimeNames = new LinkedList<String>();
List<Long> questTimes = new LinkedList<Long>(); List<Long> questTimes = new LinkedList<Long>();
for(Quest q : completedTimes.keySet()){ for(String s : completedTimes.keySet()){
questTimeNames.add(q.name); questTimeNames.add(s);
questTimes.add(completedTimes.get(q)); questTimes.add(completedTimes.get(s));
} }
@ -1737,9 +1737,9 @@ public class Quester{
}else { }else {
String[] completed = new String[completedQuests.size()]; String[] completed = new String[completedQuests.size()];
for(Quest q : completedQuests){ for(String s : completedQuests){
completed[completedQuests.indexOf(q)] = q.name; completed[completedQuests.indexOf(s)] = s;
} }
data.set("completed-Quests", completed); data.set("completed-Quests", completed);
@ -1768,7 +1768,7 @@ public class Quester{
for(Quest q : plugin.quests){ for(Quest q : plugin.quests){
if(q.name.equalsIgnoreCase(s)){ if(q.name.equalsIgnoreCase(s)){
completedTimes.put(q, (Long) o); completedTimes.put(q.name, (Long) o);
break; break;
} }
@ -1789,7 +1789,7 @@ public class Quester{
for(Quest q : plugin.quests){ for(Quest q : plugin.quests){
if(q.name.equalsIgnoreCase(s)){ if(q.name.equalsIgnoreCase(s)){
completedQuests.add(q); completedQuests.add(q.name);
break; break;
} }

File diff suppressed because it is too large Load Diff