diff --git a/src/me/blackvein/quests/Event.java b/src/me/blackvein/quests/Event.java index ce0d1db95..63cf16162 100644 --- a/src/me/blackvein/quests/Event.java +++ b/src/me/blackvein/quests/Event.java @@ -6,6 +6,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -239,6 +240,9 @@ public class Event { public static Event getEvent(String name, Quests plugin, Quest quest){ + if(name == null || plugin == null || quest == null) + return null; + Event event = new Event(); FileConfiguration data = new YamlConfiguration(); @@ -254,96 +258,324 @@ public class Event { if(data.contains(eventKey + "message")) event.message = plugin.parseString(data.getString(eventKey + "message"), quest); - if(data.contains(eventKey + "clear-inventory")) - event.clearInv = data.getBoolean(eventKey + "clear-inventory"); + if(data.contains(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")){ - 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")){ - List effectList = data.getStringList(eventKey + "effects"); - List effectLocs = data.getStringList(eventKey + "effect-locations"); + if(Quests.checkList(data.getList(eventKey + "effects"), String.class)){ - for(String s : effectLocs) - event.effects.put(Quests.getLocation(s), Quests.getEffect(effectList.get(effectLocs.indexOf(s)))); + if(data.contains(eventKey + "effect-locations")){ + + if(Quests.checkList(data.getList(eventKey + "effect-locations"), String.class)){ + + List effectList = data.getStringList(eventKey + "effects"); + List 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")){ - List itemIds = new LinkedList(); + if(Quests.checkList(data.getList(eventKey + "item-ids"), Integer.class)){ - for(Integer i : data.getIntegerList(eventKey + "item-ids")) - itemIds.add(Material.getMaterial(i)); + if(data.contains(eventKey + "item-amounts")){ - List itemAmounts = data.getIntegerList(eventKey + "item-amounts"); + if(Quests.checkList(data.getList(eventKey + "item-amounts"), Integer.class)){ - for(Material m : itemIds) - event.items.put(m, itemAmounts.get(itemIds.indexOf(m))); + List itemIds = new LinkedList(); + + 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 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")){ - 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")){ - 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")){ - List mobLocs = data.getStringList(eventKey + "mob-spawn-locations"); - List mobTypes = data.getStringList(eventKey + "mob-spawn-types"); - List mobAmounts = data.getIntegerList(eventKey + "mob-spawn-amounts"); + if(Quests.checkList(data.getList(eventKey + "mob-spawn-locations"), String.class)){ - for(String s : mobLocs){ + if(data.contains(eventKey + "mob-spawn-types")){ - Location location = Quests.getLocation(s); - EntityType type = Quests.getMobType(mobTypes.get(mobLocs.indexOf(s))); - int amount = mobAmounts.get(mobLocs.indexOf(s)); + if(Quests.checkList(data.getList(eventKey + "mob-spawn-types"), String.class)){ - event.mobSpawnLocs.add(location); - event.mobSpawnTypes.add(type); - event.mobSpawnAmounts.add(amount); + if(data.contains(eventKey + "mob-spawn-amounts")){ + if(Quests.checkList(data.getList(eventKey + "mob-spawn-amounts"), Integer.class)){ + + List mobLocs = data.getStringList(eventKey + "mob-spawn-locations"); + List mobTypes = data.getStringList(eventKey + "mob-spawn-types"); + List 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")){ - for(String s : data.getStringList(eventKey + "lightning-strikes")){ + if(Quests.checkList(data.getList(eventKey + "lightning-strikes"), String.class)){ - Location loc = Quests.getLocation(s); - event.lightningStrikes.add(loc); + for(String s : data.getStringList(eventKey + "lightning-strikes")){ + 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")){ - List types = data.getStringList(eventKey + "potion-effect-types"); - List durations = data.getIntegerList(eventKey + "potion-effect-durations"); - List amplifiers = data.getIntegerList(eventKey + "potion-effect-amplifiers"); + if(Quests.checkList(data.getList(eventKey + "potion-effect-types"), String.class)){ - 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))); - event.potionEffects.add(effect); + if(Quests.checkList(data.getList(eventKey + "potion-effect-durations"), Integer.class)){ + if(data.contains(eventKey + "potion-effect-amplifiers")){ + + if(Quests.checkList(data.getList(eventKey + "potion-effect-amplifiers"), Integer.class)){ + + List types = data.getStringList(eventKey + "potion-effect-types"); + List durations = data.getIntegerList(eventKey + "potion-effect-durations"); + List 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")){ - 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")){ - 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")){ - 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")){ - 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; + } } diff --git a/src/me/blackvein/quests/NpcListener.java b/src/me/blackvein/quests/NpcListener.java index 82637b803..37f29667b 100644 --- a/src/me/blackvein/quests/NpcListener.java +++ b/src/me/blackvein/quests/NpcListener.java @@ -10,7 +10,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; public class NpcListener implements Listener{ diff --git a/src/me/blackvein/quests/PlayerListener.java b/src/me/blackvein/quests/PlayerListener.java index 04a8c1d9a..cd83d1b9b 100644 --- a/src/me/blackvein/quests/PlayerListener.java +++ b/src/me/blackvein/quests/PlayerListener.java @@ -247,7 +247,6 @@ public class PlayerListener implements Listener { Sheep sheep = (Sheep) evt.getEntity(); quester.shearSheep(sheep.getColor()); - } } @@ -473,9 +472,20 @@ public class PlayerListener implements Listener { } plugin.questers.add(quester); - for(Quest q : quester.completedQuests){ - if(quester.completedTimes.containsKey(q) == false && q.redoDelay > -1) - quester.completedTimes.put(q, System.currentTimeMillis()); + for(String s : quester.completedQuests){ + + 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(); @@ -494,7 +504,13 @@ public class PlayerListener implements Listener { @EventHandler 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()); diff --git a/src/me/blackvein/quests/Quest.java b/src/me/blackvein/quests/Quest.java index 0016062f9..7770b8fdf 100644 --- a/src/me/blackvein/quests/Quest.java +++ b/src/me/blackvein/quests/Quest.java @@ -34,7 +34,7 @@ public class Quest { List itemAmounts = new LinkedList(); List removeItems = new LinkedList(); - List neededQuests = new LinkedList(); + List neededQuests = new LinkedList(); List permissionReqs = new LinkedList(); @@ -142,12 +142,12 @@ public class Quest { Player player = plugin.getServer().getPlayerExact(q.name); q.reset(); - q.completedQuests.add(this); + q.completedQuests.add(name); String none = ChatColor.GRAY + "- (None)"; player.sendMessage(plugin.parseString(finished, q.currentQuest)); Quests.economy.depositPlayer(q.name, moneyReward); if(redoDelay > -1) - q.completedTimes.put(this, System.currentTimeMillis()); + q.completedTimes.put(this.name, System.currentTimeMillis()); for(ItemStack i : itemRewards){ Quests.addItem(player, i); diff --git a/src/me/blackvein/quests/Quester.java b/src/me/blackvein/quests/Quester.java index 5d4ffba45..38906a8da 100644 --- a/src/me/blackvein/quests/Quester.java +++ b/src/me/blackvein/quests/Quester.java @@ -26,9 +26,9 @@ public class Quester{ Quests plugin; boolean isTalking = false; - LinkedList completedQuests = new LinkedList(); + LinkedList completedQuests = new LinkedList(); - Map completedTimes = new HashMap(); + Map completedTimes = new HashMap(); Map blocksDamaged = new EnumMap(Material.class); @@ -1406,11 +1406,11 @@ public class Quester{ long currentTime = System.currentTimeMillis(); long lastTime; - if(completedTimes.containsKey(q) == false){ + if(completedTimes.containsKey(q.name) == false){ lastTime = System.currentTimeMillis(); - completedTimes.put(q, System.currentTimeMillis()); + completedTimes.put(q.name, System.currentTimeMillis()); }else{ - lastTime = completedTimes.get(q); + lastTime = completedTimes.get(q.name); } long comparator = q.redoDelay; long difference = (comparator - (currentTime - lastTime)); @@ -1429,10 +1429,10 @@ public class Quester{ List questTimeNames = new LinkedList(); List questTimes = new LinkedList(); - for(Quest q : completedTimes.keySet()){ + for(String s : completedTimes.keySet()){ - questTimeNames.add(q.name); - questTimes.add(completedTimes.get(q)); + questTimeNames.add(s); + questTimes.add(completedTimes.get(s)); } @@ -1737,9 +1737,9 @@ public class Quester{ }else { 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); @@ -1768,7 +1768,7 @@ public class Quester{ for(Quest q : plugin.quests){ if(q.name.equalsIgnoreCase(s)){ - completedTimes.put(q, (Long) o); + completedTimes.put(q.name, (Long) o); break; } @@ -1789,7 +1789,7 @@ public class Quester{ for(Quest q : plugin.quests){ if(q.name.equalsIgnoreCase(s)){ - completedQuests.add(q); + completedQuests.add(q.name); break; } diff --git a/src/me/blackvein/quests/Quests.java b/src/me/blackvein/quests/Quests.java index 97c15e42d..b8f9243b4 100644 --- a/src/me/blackvein/quests/Quests.java +++ b/src/me/blackvein/quests/Quests.java @@ -225,7 +225,7 @@ public class Quests extends JavaPlugin { if (cmd.getName().equalsIgnoreCase("quest")) { - if (cs instanceof Player){ + if (cs instanceof Player) { if (((Player) cs).hasPermission("quests.quest")) { @@ -290,11 +290,11 @@ public class Quests extends JavaPlugin { cs.sendMessage(ChatColor.GOLD + "- " + quest.name + " -"); cs.sendMessage(" "); - if(quest.redoDelay > -1){ + if (quest.redoDelay > -1) { - if(quest.redoDelay == 0){ + if (quest.redoDelay == 0) { cs.sendMessage(ChatColor.DARK_AQUA + "Redoable"); - }else { + } else { cs.sendMessage(ChatColor.DARK_AQUA + "Redoable every " + ChatColor.AQUA + getTime(quest.redoDelay) + ChatColor.DARK_AQUA + "."); } @@ -311,14 +311,15 @@ public class Quests extends JavaPlugin { cs.sendMessage(ChatColor.GOLD + "Requirements"); - if(quest.permissionReqs.isEmpty() == false) { + if (quest.permissionReqs.isEmpty() == false) { - for(String perm : quest.permissionReqs){ + for (String perm : quest.permissionReqs) { - if(permission.has(player, perm)) + if (permission.has(player, perm)) { cs.sendMessage(ChatColor.GREEN + "Permission: " + perm); - else + } else { cs.sendMessage(ChatColor.RED + "Permission: " + perm); + } } @@ -368,12 +369,12 @@ public class Quests extends JavaPlugin { if (quest.neededQuests.isEmpty() == false) { - for (Quest q : quest.neededQuests) { + for (String s : quest.neededQuests) { - if (quester.completedQuests.contains(q)) { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + "Complete " + ChatColor.DARK_PURPLE + q.name); + if (quester.completedQuests.contains(s)) { + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + "Complete " + ChatColor.DARK_PURPLE + s); } else { - cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + "Complete " + ChatColor.DARK_PURPLE + q.name); + cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + "Complete " + ChatColor.DARK_PURPLE + s); } } @@ -548,19 +549,19 @@ public class Quests extends JavaPlugin { cs.sendMessage(ChatColor.YELLOW + "You must speak to " + ChatColor.DARK_PURPLE + quest.npcStart.getName() + ChatColor.YELLOW + " to start this Quest."); } else if (quest.blockStart != null) { cs.sendMessage(ChatColor.DARK_PURPLE + quest.name + ChatColor.YELLOW + " may not be started via command."); - }else { + } else { boolean takeable = true; - if(quester.completedQuests.contains(quest)){ + if (quester.completedQuests.contains(quest)) { - if(quester.getDifference(quest) > 0){ + if (quester.getDifference(quest) > 0) { cs.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + quest.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + getTime(quester.getDifference(quest)) + ChatColor.YELLOW + "."); takeable = false; } } - if(takeable == true){ + if (takeable == true) { LinkedList