package com.biggestnerd.civfriends;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.UUID;

import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.craftbukkit.libs.com.google.gson.GsonBuilder;

public class FriendSave {
	
	private double friendDistance = 50D;
	private float maxReductionPercent = 0.35F;
	private ArrayList<FriendList> friendLists = new ArrayList<FriendList>();
	
	public FriendSave() {
		this.friendLists = new ArrayList<FriendList>();
	}
	
	public FriendList getFriendListForPlayer(UUID player) {
		for(FriendList friends : friendLists) {
			if(friends.getPlayer().equals(player)) {
				return friends;
			}
		}
		FriendList friends = new FriendList(player);
		friendLists.add(friends);
		return friends;
	}
	
	public double getFriendDistance() {
		return this.friendDistance;
	}
	
	public float getMaxReductionPercent() {
		return this.maxReductionPercent;
	}
	
	public void addFriendList(FriendList list) {
		this.friendLists.add(list);
	}
	
	public void purgeEmpty() {
		ArrayList<FriendList> tbr = new ArrayList<FriendList>();
		for(FriendList fl : friendLists) {
			if(fl.getFriends().isEmpty()) {
				tbr.add(fl);
			}
		}
		friendLists.removeAll(tbr);
	}
	
	public void save(File file) {
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		try {
			String json = gson.toJson(this);

			FileWriter writer = new FileWriter(file);
			writer.write(json);
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static FriendSave load(File file) {
		Gson gson = new Gson();
		try {
			return (FriendSave) gson.fromJson(new FileReader(file), FriendSave.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new FriendSave();
	}
}

@@ -402,416 +402,1309 @@
 ate 
-ArrayList%3CFriendList%3E friendLists = new ArrayList%3CFriendList%3E();%0A%09%0A%09public FriendSave() %7B%0A%09%09this.friendLists = new ArrayList%3CFriendList%3E();%0A%09%7D%0A%09%0A%09public FriendList getFriendListForPlayer(UUID player) %7B%0A%09%09for(FriendList friends : friendLists) %7B%0A%09%09%09if(friends.getPlayer().equals(player)) %7B%0A%09%09%09%09return friends;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09FriendList friends = new FriendList(player);%0A%09%09friendLists.add(friends);%0A%09%09return friends
+float damageReductionScale = 1.09F;%0A%09private int baseDamageReduction = 1;%0A%09private float maxIncreasePercent = 0.2F;%0A%09private float damageIncreaseScale = 1.65F;%0A%09private int baseDamageIncrease = 1;%0A%09private ArrayList%3CFriendList%3E friendLists = new ArrayList%3CFriendList%3E();%0A%09private boolean reduceDamageTaken = true;%0A%09private boolean increaseDamageDealt = false;%0A%09private boolean preventFriendlyFire = false;%0A%09%0A%09public FriendSave() %7B%0A%09%09this.friendLists = new ArrayList%3CFriendList%3E();%0A%09%7D%0A%09%0A%09public FriendList getFriendListForPlayer(UUID player) %7B%0A%09%09for(FriendList friends : friendLists) %7B%0A%09%09%09if(friends.getPlayer().equals(player)) %7B%0A%09%09%09%09return friends;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09FriendList friends = new FriendList(player);%0A%09%09friendLists.add(friends);%0A%09%09return friends;%0A%09%7D%0A%09%0A%09public boolean shouldPreventFriendlyFire() %7B%0A%09%09return this.preventFriendlyFire;%0A%09%7D%0A%09%0A%09public boolean shouldReduceDamageTaken() %7B%0A%09%09return this.reduceDamageTaken;%0A%09%7D%0A%09%0A%09public float getMaxIncreasePercent() %7B%0A%09%09return maxIncreasePercent;%0A%09%7D%0A%0A%09public float getDamageIncreaseScale() %7B%0A%09%09return damageIncreaseScale;%0A%09%7D%0A%0A%09public int getBaseDamageIncrease() %7B%0A%09%09return baseDamageIncrease;%0A%09%7D%0A%0A%09public boolean shouldIncreaseDamageDealt() %7B%0A%09%09return this.increaseDamageDealt;%0A%09%7D%0A%09%0A%09public int getBaseDamageReduction() %7B%0A%09%09return this.baseDamageReduction
 ;%0A%09%7D
@@ -1932,32 +1932,115 @@
 add(list);%0A%09%7D%0A%09%0A
+%09public float getDamageReductionScale() %7B%0A%09%09return this.damageReductionScale;%0A%09%7D%0A%09%0A
 %09public void pur

Update FriendSave.java