mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-22 00:58:55 +01:00
Finished catches for (hopefully) all quest-reading errors.
This commit is contained in:
parent
92bf724fe6
commit
2fae0182a6
@ -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<String> effectList = data.getStringList(eventKey + "effects");
|
||||
List<String> 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<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")){
|
||||
|
||||
List<Material> itemIds = new LinkedList<Material>();
|
||||
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<Integer> 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<Material> itemIds = new LinkedList<Material>();
|
||||
|
||||
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")){
|
||||
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<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");
|
||||
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<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")){
|
||||
|
||||
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<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");
|
||||
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<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")){
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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{
|
||||
|
||||
|
@ -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());
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class Quest {
|
||||
List<Integer> itemAmounts = new LinkedList<Integer>();
|
||||
List<Boolean> removeItems = new LinkedList<Boolean>();
|
||||
|
||||
List<Quest> neededQuests = new LinkedList<Quest>();
|
||||
List<String> neededQuests = new LinkedList<String>();
|
||||
|
||||
List<String> permissionReqs = new LinkedList<String>();
|
||||
|
||||
@ -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);
|
||||
|
@ -26,9 +26,9 @@ public class Quester{
|
||||
Quests plugin;
|
||||
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);
|
||||
|
||||
@ -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<String> questTimeNames = new LinkedList<String>();
|
||||
List<Long> questTimes = new LinkedList<Long>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user