This would be v1.0 beta2. Just live testing on mcteam.org left to do.
This commit is contained in:
		@@ -47,7 +47,7 @@ You can download it here: [http://bamboo.lukegb.com/browse/BUKKIT-BUKKITMAIN/](h
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<b>You will also need Google GSON in your build path.</b><br/>
 | 
					<b>You will also need Google GSON in your build path.</b><br/>
 | 
				
			||||||
You can download it here: [http://code.google.com/p/google-gson/](http://code.google.com/p/google-gson/)<br/>
 | 
					You can download it here: [http://code.google.com/p/google-gson/](http://code.google.com/p/google-gson/)<br/>
 | 
				
			||||||
<b>OR</b> you can use the file in this repo `/packaging/gson.jar`<br/>
 | 
					<b>OR</b> you can use the file in this repo `/packaging/your_minecraft_server/gson.jar`<br/>
 | 
				
			||||||
However you won't get javadocs and source that way.
 | 
					However you won't get javadocs and source that way.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You will need to include the MANIFEST.MF and plugin.yml in your jar. All bukkit plugins need a plugin.yml and the MANIFEST.MF is needed for the plugin to find the gson.jar (wich should be in the same folder as the main server jar when running the server).
 | 
					You will need to include the MANIFEST.MF and plugin.yml in your jar. All bukkit plugins need a plugin.yml and the MANIFEST.MF is needed for the plugin to find the gson.jar (wich should be in the same folder as the main server jar when running the server).
 | 
				
			||||||
@@ -1,3 +1,3 @@
 | 
				
			|||||||
name: Factions
 | 
					name: Factions
 | 
				
			||||||
version: 1.0 beta1
 | 
					version: 1.0 beta2
 | 
				
			||||||
main: com.bukkit.mcteam.factions.Factions
 | 
					main: com.bukkit.mcteam.factions.Factions
 | 
				
			||||||
@@ -24,7 +24,7 @@ public class Commands {
 | 
				
			|||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasHelp, "[page]", "Display this, or the next help page"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasHelp, "[page]", "Display this, or the next help page"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasList, "", "List all factions"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasList, "", "List all factions"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasShow, "*[faction name]", "Show faction information")); // TODO display relations!
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasShow, "*[faction name]", "Show faction information")); // TODO display relations!
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasMap, "*[on|off]", "Show territory map, set optional auto update.")); // TODO COMPASS
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasMap, "*[on|off]", "Show territory map, set optional auto update."));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasJoin, "[faction name]", "Join a faction"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasJoin, "[faction name]", "Join a faction"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasLeave, "", "Leave your faction"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasLeave, "", "Leave your faction"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasCreate, "[faction name]", "Create new faction"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasCreate, "[faction name]", "Create new faction"));
 | 
				
			||||||
@@ -38,8 +38,8 @@ public class Commands {
 | 
				
			|||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasInvite, "[player name]", "Invite player"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasInvite, "[player name]", "Invite player"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasDeinvite, "[player name]", "Remove a pending invitation"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasDeinvite, "[player name]", "Remove a pending invitation"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasKick, "[player name]", "Kick a player from the faction"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasKick, "[player name]", "Kick a player from the faction"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasModerator, "[player name]", "Give or revoke moderator rights")); // TODO
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasModerator, "[player name]", "Give or revoke moderator rights"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasAdmin, "[player name]", "Hand over your admin rights")); // TODO
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasAdmin, "[player name]", "Hand over your admin rights"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasClaim, "", "Claim the land where you are standing"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasClaim, "", "Claim the land where you are standing"));
 | 
				
			||||||
		pageLines.add(TextUtil.commandHelp(Conf.aliasUnclaim, "", "Unclaim the land where you are standing"));
 | 
							pageLines.add(TextUtil.commandHelp(Conf.aliasUnclaim, "", "Unclaim the land where you are standing"));
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@@ -213,9 +213,7 @@ public class Commands {
 | 
				
			|||||||
		} else if (Conf.aliasVersion.contains(command)) {
 | 
							} else if (Conf.aliasVersion.contains(command)) {
 | 
				
			||||||
			version(me);
 | 
								version(me);
 | 
				
			||||||
		}  else {
 | 
							}  else {
 | 
				
			||||||
			//me.sendMessage(Conf.colorSystem+"Unknown faction command"+Conf.colorCommand+" "+command);
 | 
					 | 
				
			||||||
			me.sendMessage(Conf.colorSystem+"Unknown faction command"+Conf.colorCommand+" "+command);
 | 
								me.sendMessage(Conf.colorSystem+"Unknown faction command"+Conf.colorCommand+" "+command);
 | 
				
			||||||
			//me.getPlayer().sendMessage(TextUtil.repeat(tokens.get(0), Integer.parseInt(tokens.get(1))));
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -243,14 +241,14 @@ public class Commands {
 | 
				
			|||||||
		me.sendMessage(errors);
 | 
							me.sendMessage(errors);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (errors.size() == 0) {
 | 
							if (errors.size() == 0) {
 | 
				
			||||||
			faction.sendMessage(me.getFullName(faction)+Conf.colorAction+" left your faction.");
 | 
								faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" left your faction.");
 | 
				
			||||||
			me.sendMessage("You left "+faction.getName(me));
 | 
								me.sendMessage("You left "+faction.getName(me));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (faction.getFollowersAll().size() == 0) {
 | 
							if (faction.getFollowersAll().size() == 0) {
 | 
				
			||||||
			// Remove this faction
 | 
								// Remove this faction
 | 
				
			||||||
			for (Follower follower : Follower.getAll()) {
 | 
								for (Follower follower : Follower.getAll()) {
 | 
				
			||||||
				follower.sendMessage(Conf.colorAction+"The faction "+faction.getName(follower)+Conf.colorAction+" was disbandoned.");
 | 
									follower.sendMessage(Conf.colorSystem+"The faction "+faction.getName(follower)+Conf.colorSystem+" was disbandoned.");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			EM.factionDelete(faction.id);
 | 
								EM.factionDelete(faction.id);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -268,18 +266,38 @@ public class Commands {
 | 
				
			|||||||
		if (errors.size() > 0) {
 | 
							if (errors.size() > 0) {
 | 
				
			||||||
			faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" tried to join your faction.");
 | 
								faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" tried to join your faction.");
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			me.sendMessage(Conf.colorAction+"You successfully joined "+faction.getName(me));
 | 
								me.sendMessage(Conf.colorSystem+"You successfully joined "+faction.getName(me));
 | 
				
			||||||
			faction.sendMessage(me.getFullName(faction)+Conf.colorAction+" joined your faction.");
 | 
								faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" joined your faction.");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// TODO MOVE OUT
 | 
					 | 
				
			||||||
	public static void create(Follower me, String name) {
 | 
						public static void create(Follower me, String name) {
 | 
				
			||||||
		ArrayList<String> errors = me.createFaction(name);
 | 
							ArrayList<String> errors = new ArrayList<String>();
 | 
				
			||||||
		me.sendMessage(errors);
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (errors.size() == 0) {
 | 
							if (me.factionId != 0) {
 | 
				
			||||||
			me.sendMessage(Conf.colorAction+"Faction created!");
 | 
								errors.add(Conf.colorSystem+"You must leave your current faction first.");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (Faction.isNameTaken(name)) {
 | 
				
			||||||
 | 
								errors.add(Conf.colorSystem+"That name is already in use.");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							errors.addAll(Faction.validateName(name));
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (errors.size() > 0) {
 | 
				
			||||||
 | 
								me.sendMessage(errors);
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							Faction faction = EM.factionCreate();
 | 
				
			||||||
 | 
							faction.setName(name);
 | 
				
			||||||
 | 
							faction.save();
 | 
				
			||||||
 | 
							me.join(faction);
 | 
				
			||||||
 | 
							me.role = Role.ADMIN;
 | 
				
			||||||
 | 
							me.save();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							for (Follower follower : Follower.getAll()) {
 | 
				
			||||||
 | 
								follower.sendMessage(me.getFullName(follower)+Conf.colorSystem+" created a new faction "+faction.getName(follower));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -392,11 +410,11 @@ public class Commands {
 | 
				
			|||||||
			if (Conf.aliasTrue.contains(mapAutoUpdating.toLowerCase())) {
 | 
								if (Conf.aliasTrue.contains(mapAutoUpdating.toLowerCase())) {
 | 
				
			||||||
				// Turn on
 | 
									// Turn on
 | 
				
			||||||
				me.setMapAutoUpdating(true);
 | 
									me.setMapAutoUpdating(true);
 | 
				
			||||||
				me.sendMessage(Conf.colorAction + "Map auto update ENABLED.");
 | 
									me.sendMessage(Conf.colorSystem + "Map auto update ENABLED.");
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				// Turn off
 | 
									// Turn off
 | 
				
			||||||
				me.setMapAutoUpdating(false);
 | 
									me.setMapAutoUpdating(false);
 | 
				
			||||||
				me.sendMessage(Conf.colorAction + "Map auto update DISABLED.");
 | 
									me.sendMessage(Conf.colorSystem + "Map auto update DISABLED.");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			me.sendMessage(Board.getMap(me.getFaction(), Coord.from(me), me.getPlayer().getLocation().getYaw()), false);
 | 
								me.sendMessage(Board.getMap(me.getFaction(), Coord.from(me), me.getPlayer().getLocation().getYaw()), false);
 | 
				
			||||||
@@ -416,7 +434,6 @@ public class Commands {
 | 
				
			|||||||
			ChatColor relationColor = me.getRelationColor(follower);
 | 
								ChatColor relationColor = me.getRelationColor(follower);
 | 
				
			||||||
			follower.sendMessage(relationColor+me.getFullName()+Conf.colorSystem+" invited you to "+relationColor+me.getFaction().getName());
 | 
								follower.sendMessage(relationColor+me.getFullName()+Conf.colorSystem+" invited you to "+relationColor+me.getFaction().getName());
 | 
				
			||||||
			me.getFaction().sendMessage(me.getFullName(me)+Conf.colorSystem+" invited "+follower.getFullName(me)+Conf.colorSystem+" to your faction.");
 | 
								me.getFaction().sendMessage(me.getFullName(me)+Conf.colorSystem+" invited "+follower.getFullName(me)+Conf.colorSystem+" to your faction.");
 | 
				
			||||||
			//me.sendMessage(Conf.colorAction+"You invited "+relationColor+follower.getFullName()+Conf.colorAction+" to "+Relation.MEMBER.getColor()+me.getFaction().getName());
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -690,7 +707,7 @@ public class Commands {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		me.getFaction().setDescription(desc);
 | 
							me.getFaction().setDescription(desc);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		me.sendMessage(Conf.colorAction+"The new decription was set :D");
 | 
							me.sendMessage(Conf.colorSystem+"The new decription was set :D");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Broadcast the description to everyone
 | 
							// Broadcast the description to everyone
 | 
				
			||||||
		for (Follower follower : EM.followerGetAll()) {
 | 
							for (Follower follower : EM.followerGetAll()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,9 @@ import org.bukkit.plugin.PluginManager;
 | 
				
			|||||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
					import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.bukkit.mcteam.factions.entities.*;
 | 
					import com.bukkit.mcteam.factions.entities.*;
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.listeners.FactionsBlockListener;
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.listeners.FactionsEntityListener;
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.listeners.FactionsPlayerListener;
 | 
				
			||||||
import com.bukkit.mcteam.factions.util.Log;
 | 
					import com.bukkit.mcteam.factions.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Factions extends JavaPlugin {
 | 
					public class Factions extends JavaPlugin {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -114,10 +114,7 @@ public class Board {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		// Get the compass
 | 
							// Get the compass
 | 
				
			||||||
		ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Conf.colorChrome);
 | 
							ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Conf.colorChrome);
 | 
				
			||||||
		// Pad the compass some
 | 
					
 | 
				
			||||||
		asciiCompass.set(0, asciiCompass.get(0));
 | 
					 | 
				
			||||||
		asciiCompass.set(1, asciiCompass.get(1));
 | 
					 | 
				
			||||||
		asciiCompass.set(2, asciiCompass.get(2));
 | 
					 | 
				
			||||||
		// Add the compass
 | 
							// Add the compass
 | 
				
			||||||
		ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3));
 | 
							ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3));
 | 
				
			||||||
		ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3));
 | 
							ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,6 @@ public class Conf {
 | 
				
			|||||||
	public static ChatColor colorEnemy;
 | 
						public static ChatColor colorEnemy;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public static ChatColor colorSystem;
 | 
						public static ChatColor colorSystem;
 | 
				
			||||||
	public static ChatColor colorAction;
 | 
					 | 
				
			||||||
	public static ChatColor colorChrome;
 | 
						public static ChatColor colorChrome;
 | 
				
			||||||
	public static ChatColor colorCommand;
 | 
						public static ChatColor colorCommand;
 | 
				
			||||||
	public static ChatColor colorParameter;
 | 
						public static ChatColor colorParameter;
 | 
				
			||||||
@@ -43,8 +42,6 @@ public class Conf {
 | 
				
			|||||||
	public static List<String> aliasShow = new ArrayList<String>();
 | 
						public static List<String> aliasShow = new ArrayList<String>();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public static List<String> aliasMap = new ArrayList<String>();
 | 
						public static List<String> aliasMap = new ArrayList<String>();
 | 
				
			||||||
	public static List<String> aliasHere = new ArrayList<String>();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public static List<String> aliasJoin = new ArrayList<String>();
 | 
						public static List<String> aliasJoin = new ArrayList<String>();
 | 
				
			||||||
	public static List<String> aliasLeave = new ArrayList<String>();
 | 
						public static List<String> aliasLeave = new ArrayList<String>();
 | 
				
			||||||
@@ -76,11 +73,9 @@ public class Conf {
 | 
				
			|||||||
	public static List<String> aliasTrue = new ArrayList<String>();
 | 
						public static List<String> aliasTrue = new ArrayList<String>();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// Power
 | 
						// Power
 | 
				
			||||||
	public static double powerPerLand;
 | 
					 | 
				
			||||||
	public static double powerPerPlayer;
 | 
						public static double powerPerPlayer;
 | 
				
			||||||
	public static double powerPerMinute; // Default health rate
 | 
						public static double powerPerMinute; // Default health rate
 | 
				
			||||||
	public static double powerPerDeath;
 | 
						public static double powerPerDeath;
 | 
				
			||||||
	public static double powerDefaultBonus;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// Protected blocks
 | 
						// Protected blocks
 | 
				
			||||||
	public static List<Material> territoryProtectedMaterials = new ArrayList<Material>();
 | 
						public static List<Material> territoryProtectedMaterials = new ArrayList<Material>();
 | 
				
			||||||
@@ -89,15 +84,18 @@ public class Conf {
 | 
				
			|||||||
		logThreshold = 10;
 | 
							logThreshold = 10;
 | 
				
			||||||
		prefixAdmin = "**";
 | 
							prefixAdmin = "**";
 | 
				
			||||||
		prefixMod = "*";
 | 
							prefixMod = "*";
 | 
				
			||||||
		factionNameMinLength = 3;
 | 
							useRelationColoredChat = true;
 | 
				
			||||||
		factionNameMaxLength = 40;
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		mapHeight = 8;
 | 
							powerPerPlayer = 10; // One player has 10 power
 | 
				
			||||||
		mapWidth = 49;
 | 
							powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
 | 
				
			||||||
 | 
							powerPerDeath = 2; //A death makes you loose 2 power
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		territoryShieldFactor = 0.5;
 | 
							territoryShieldFactor = 0.5;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		useRelationColoredChat = true;
 | 
							territoryProtectedMaterials.add(Material.WOODEN_DOOR);
 | 
				
			||||||
 | 
							territoryProtectedMaterials.add(Material.DISPENSER);
 | 
				
			||||||
 | 
							territoryProtectedMaterials.add(Material.CHEST);
 | 
				
			||||||
 | 
							territoryProtectedMaterials.add(Material.FURNACE);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		colorMember = ChatColor.GREEN;
 | 
							colorMember = ChatColor.GREEN;
 | 
				
			||||||
		colorAlly = ChatColor.LIGHT_PURPLE;
 | 
							colorAlly = ChatColor.LIGHT_PURPLE;
 | 
				
			||||||
@@ -105,7 +103,6 @@ public class Conf {
 | 
				
			|||||||
		colorEnemy = ChatColor.RED;
 | 
							colorEnemy = ChatColor.RED;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		colorSystem = ChatColor.YELLOW;
 | 
							colorSystem = ChatColor.YELLOW;
 | 
				
			||||||
		colorAction = ChatColor.LIGHT_PURPLE;
 | 
					 | 
				
			||||||
		colorChrome = ChatColor.GOLD;
 | 
							colorChrome = ChatColor.GOLD;
 | 
				
			||||||
		colorCommand = ChatColor.AQUA;
 | 
							colorCommand = ChatColor.AQUA;
 | 
				
			||||||
		colorParameter = ChatColor.DARK_AQUA;
 | 
							colorParameter = ChatColor.DARK_AQUA;
 | 
				
			||||||
@@ -128,7 +125,6 @@ public class Conf {
 | 
				
			|||||||
		aliasShow.add("who");
 | 
							aliasShow.add("who");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		aliasMap.add("map");
 | 
							aliasMap.add("map");
 | 
				
			||||||
		aliasHere.add("here");
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		aliasJoin.add("join");
 | 
							aliasJoin.add("join");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@@ -177,16 +173,11 @@ public class Conf {
 | 
				
			|||||||
		aliasTrue.add("on");
 | 
							aliasTrue.add("on");
 | 
				
			||||||
		aliasTrue.add("+");
 | 
							aliasTrue.add("+");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		powerPerLand = 1; // 1 power grants one land Perhaps this should not even be a config value...
 | 
							factionNameMinLength = 3;
 | 
				
			||||||
		powerPerPlayer = 10; // One player has 10 power
 | 
							factionNameMaxLength = 40;
 | 
				
			||||||
		powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
 | 
					 | 
				
			||||||
		powerPerDeath = 2; //A death makes you loose 2 power
 | 
					 | 
				
			||||||
		powerDefaultBonus = 0; //A faction normally has a power bonus
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		territoryProtectedMaterials.add(Material.WOODEN_DOOR);
 | 
							mapHeight = 8;
 | 
				
			||||||
		territoryProtectedMaterials.add(Material.DISPENSER);
 | 
							mapWidth = 49;
 | 
				
			||||||
		territoryProtectedMaterials.add(Material.CHEST);
 | 
					 | 
				
			||||||
		territoryProtectedMaterials.add(Material.FURNACE);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	//----------------------------------------------//
 | 
						//----------------------------------------------//
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,7 @@ public class EM {
 | 
				
			|||||||
	.create();
 | 
						.create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static void loadAll() {
 | 
						public static void loadAll() {
 | 
				
			||||||
 | 
							folderBase.mkdirs();
 | 
				
			||||||
		configLoad();
 | 
							configLoad();
 | 
				
			||||||
		Log.threshold = Conf.logThreshold;
 | 
							Log.threshold = Conf.logThreshold;
 | 
				
			||||||
		boardLoad();
 | 
							boardLoad();
 | 
				
			||||||
@@ -59,11 +60,12 @@ public class EM {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Log.info("No conf.json found! Creating a new one with the default values");
 | 
							Log.info("No conf.json found! Creating a new one with the default values");
 | 
				
			||||||
		//configSave(); // FOR DEBUGGING...
 | 
							configSave();
 | 
				
			||||||
		return true;		
 | 
							return true;		
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public static boolean configSave() {
 | 
						public static boolean configSave() {
 | 
				
			||||||
 | 
							folderBase.mkdirs();
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			DiscUtil.write(fileConfig, gson.toJson(new Conf()));
 | 
								DiscUtil.write(fileConfig, gson.toJson(new Conf()));
 | 
				
			||||||
			Log.debug("Config was saved to disc");
 | 
								Log.debug("Config was saved to disc");
 | 
				
			||||||
@@ -91,11 +93,12 @@ public class EM {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Log.info("No board.json found! Creating a new one with the default values");
 | 
							Log.info("No board.json found! Creating a new one with the default values");
 | 
				
			||||||
		//boardSave(); // FOR DEBUGGING...
 | 
							boardSave();
 | 
				
			||||||
		return true;		
 | 
							return true;		
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public static boolean boardSave() {
 | 
						public static boolean boardSave() {
 | 
				
			||||||
 | 
							folderBase.mkdirs();
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			DiscUtil.write(fileBoard, gson.toJson(new Board()));
 | 
								DiscUtil.write(fileBoard, gson.toJson(new Board()));
 | 
				
			||||||
			Log.debug("Board was saved to disc");
 | 
								Log.debug("Board was saved to disc");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,19 +72,15 @@ public class Faction {
 | 
				
			|||||||
	// Power
 | 
						// Power
 | 
				
			||||||
	//----------------------------------------------//
 | 
						//----------------------------------------------//
 | 
				
			||||||
	public double getPower() {
 | 
						public double getPower() {
 | 
				
			||||||
		double ret = this.getPowerBonus();
 | 
							double ret = 0;
 | 
				
			||||||
		for (Follower follower : this.getFollowersAll()) {
 | 
							for (Follower follower : this.getFollowersAll()) {
 | 
				
			||||||
			ret += follower.getPower();
 | 
								ret += follower.getPower();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public double getPowerBonus() {
 | 
					 | 
				
			||||||
		return Conf.powerDefaultBonus; // TODO this could be modified by commands later on
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public double getPowerMax() {
 | 
						public double getPowerMax() {
 | 
				
			||||||
		double ret = this.getPowerBonus();
 | 
							double ret = 0;
 | 
				
			||||||
		for (Follower follower : this.getFollowersAll()) {
 | 
							for (Follower follower : this.getFollowersAll()) {
 | 
				
			||||||
			ret += follower.getPowerMax();
 | 
								ret += follower.getPowerMax();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -104,7 +100,7 @@ public class Faction {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public double getLandMax() {
 | 
						public double getLandMax() {
 | 
				
			||||||
		return this.getPower() / Conf.powerPerLand;
 | 
							return this.getPower();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public int getLandMaxRounded() {
 | 
						public int getLandMaxRounded() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -203,33 +203,6 @@ public class Follower {
 | 
				
			|||||||
		return errors;
 | 
							return errors;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public ArrayList<String> createFaction(String name) {
 | 
					 | 
				
			||||||
		ArrayList<String> errors = new ArrayList<String>();
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (this.factionId != 0) {
 | 
					 | 
				
			||||||
			errors.add(Conf.colorSystem+"You must leave your current faction first.");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (Faction.isNameTaken(name)) {
 | 
					 | 
				
			||||||
			errors.add(Conf.colorSystem+"That name is already in use.");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		errors.addAll(Faction.validateName(name));
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (errors.size() > 0) {
 | 
					 | 
				
			||||||
			return errors;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		Faction faction = EM.factionCreate();
 | 
					 | 
				
			||||||
		faction.setName(name);
 | 
					 | 
				
			||||||
		faction.save();
 | 
					 | 
				
			||||||
		this.join(faction);
 | 
					 | 
				
			||||||
		this.role = Role.ADMIN;
 | 
					 | 
				
			||||||
		this.save();
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		return errors;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public ArrayList<String> invite(Follower follower) {
 | 
						public ArrayList<String> invite(Follower follower) {
 | 
				
			||||||
		ArrayList<String> errors = new ArrayList<String>();
 | 
							ArrayList<String> errors = new ArrayList<String>();
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.bukkit.mcteam.factions;
 | 
					package com.bukkit.mcteam.factions.listeners;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.bukkit.Material;
 | 
					import org.bukkit.Material;
 | 
				
			||||||
import org.bukkit.block.Block;
 | 
					import org.bukkit.block.Block;
 | 
				
			||||||
@@ -9,8 +9,9 @@ import org.bukkit.event.block.BlockInteractEvent;
 | 
				
			|||||||
import org.bukkit.event.block.BlockListener;
 | 
					import org.bukkit.event.block.BlockListener;
 | 
				
			||||||
import org.bukkit.event.block.BlockPlaceEvent;
 | 
					import org.bukkit.event.block.BlockPlaceEvent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.Factions;
 | 
				
			||||||
import com.bukkit.mcteam.factions.entities.*;
 | 
					import com.bukkit.mcteam.factions.entities.*;
 | 
				
			||||||
import com.bukkit.mcteam.factions.util.TextUtil;
 | 
					import com.bukkit.mcteam.factions.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class FactionsBlockListener extends BlockListener {
 | 
					public class FactionsBlockListener extends BlockListener {
 | 
				
			||||||
	public Factions plugin;
 | 
						public Factions plugin;
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.bukkit.mcteam.factions;
 | 
					package com.bukkit.mcteam.factions.listeners;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.text.DecimalFormat;
 | 
					import java.text.DecimalFormat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
 | 
				
			|||||||
import org.bukkit.event.entity.EntityDeathEvent;
 | 
					import org.bukkit.event.entity.EntityDeathEvent;
 | 
				
			||||||
import org.bukkit.event.entity.EntityListener;
 | 
					import org.bukkit.event.entity.EntityListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.Factions;
 | 
				
			||||||
import com.bukkit.mcteam.factions.entities.Conf;
 | 
					import com.bukkit.mcteam.factions.entities.Conf;
 | 
				
			||||||
import com.bukkit.mcteam.factions.entities.Follower;
 | 
					import com.bukkit.mcteam.factions.entities.Follower;
 | 
				
			||||||
import com.bukkit.mcteam.factions.struct.Relation;
 | 
					import com.bukkit.mcteam.factions.struct.Relation;
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
package com.bukkit.mcteam.factions;
 | 
					package com.bukkit.mcteam.factions.listeners;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -10,6 +10,8 @@ import org.bukkit.event.player.PlayerEvent;
 | 
				
			|||||||
import org.bukkit.event.player.PlayerListener;
 | 
					import org.bukkit.event.player.PlayerListener;
 | 
				
			||||||
import org.bukkit.event.player.PlayerMoveEvent;
 | 
					import org.bukkit.event.player.PlayerMoveEvent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.Commands;
 | 
				
			||||||
 | 
					import com.bukkit.mcteam.factions.Factions;
 | 
				
			||||||
import com.bukkit.mcteam.factions.entities.*;
 | 
					import com.bukkit.mcteam.factions.entities.*;
 | 
				
			||||||
import com.bukkit.mcteam.factions.util.*;
 | 
					import com.bukkit.mcteam.factions.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -9,7 +9,6 @@ public enum Relation {
 | 
				
			|||||||
	ALLY(2, "ally"),
 | 
						ALLY(2, "ally"),
 | 
				
			||||||
	NEUTRAL(1, "neutral"),
 | 
						NEUTRAL(1, "neutral"),
 | 
				
			||||||
	ENEMY(0, "enemy");
 | 
						ENEMY(0, "enemy");
 | 
				
			||||||
	//UNKNOWN(-1, "unknown");
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public final int value;
 | 
						public final int value;
 | 
				
			||||||
	public final String nicename;
 | 
						public final String nicename;
 | 
				
			||||||
@@ -27,22 +26,4 @@ public enum Relation {
 | 
				
			|||||||
	public ChatColor getColor() {
 | 
						public ChatColor getColor() {
 | 
				
			||||||
		return Conf.relationColor(this);
 | 
							return Conf.relationColor(this);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/*public String getChartDot() {
 | 
					 | 
				
			||||||
		return Conf.chartDot(this);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public static Relation from(String str) {
 | 
					 | 
				
			||||||
		if (str.equalsIgnoreCase("member")) {
 | 
					 | 
				
			||||||
			return Relation.MEMBER;
 | 
					 | 
				
			||||||
		} else if (str.equalsIgnoreCase("ally")) {
 | 
					 | 
				
			||||||
			return Relation.ALLY;
 | 
					 | 
				
			||||||
		} else if (str.equalsIgnoreCase("neutral")) {
 | 
					 | 
				
			||||||
			return Relation.NEUTRAL;
 | 
					 | 
				
			||||||
		} else if (str.equalsIgnoreCase("enemy")) {
 | 
					 | 
				
			||||||
			return Relation.ENEMY;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		return Relation.UNKNOWN;
 | 
					 | 
				
			||||||
	}*/
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user