Adds Faction founding date

..but does not implement it. Future commit will need to add this to /f
show.
This commit is contained in:
Nick Porillo 2015-05-12 12:20:11 -04:00
parent 362bb55a0f
commit dbba8c055c
4 changed files with 28 additions and 3 deletions

View File

@ -83,6 +83,10 @@ public interface Faction extends EconomyParticipator {
public Location getHome();
public long getFoundedDate();
public void setFoundedDate(long newDate);
public void confirmValidHome();
public String getAccountId();

View File

@ -58,6 +58,21 @@ public class CmdTop extends FCommand {
return 0;
}
});
} else if (criteria.equalsIgnoreCase("start")) {
Collections.sort(factionList, new Comparator<Faction>() {
@Override
public int compare(Faction f1, Faction f2) {
long f1start = f1.getFoundedDate();
long f2start = f2.getFoundedDate();
// flip signs because a smaller date is farther in the past
if (f1start > f2start) {
return 1;
} else if (f1start < f2start) {
return -1;
}
return 0;
}
});
} else if (criteria.equalsIgnoreCase("power")) {
Collections.sort(factionList, new Comparator<Faction>() {
@Override
@ -106,11 +121,11 @@ public class CmdTop extends FCommand {
public int compare(Faction f1, Faction f2) {
double f1Size = Econ.getBalance(f1.getAccountId());
// Lets get the balance of /all/ the players in the Faction.
for(FPlayer fp : f1.getFPlayers()) {
for (FPlayer fp : f1.getFPlayers()) {
f1Size = f1Size + Econ.getBalance(fp.getAccountId());
}
double f2Size = Econ.getBalance(f2.getAccountId());
for(FPlayer fp : f2.getFPlayers()) {
for (FPlayer fp : f2.getFPlayers()) {
f2Size = f2Size + Econ.getBalance(fp.getAccountId());
}
if (f1Size < f2Size) {
@ -162,11 +177,13 @@ public class CmdTop extends FCommand {
return String.valueOf(faction.getFPlayers().size());
} else if (criteria.equalsIgnoreCase("land")) {
return String.valueOf(faction.getLandRounded());
} else if (criteria.equalsIgnoreCase("start")) {
return sdf.format(faction.getFoundedDate());
} else if (criteria.equalsIgnoreCase("power")) {
return String.valueOf(faction.getPowerRounded());
} else { // Last one is balance, and it has 3 different things it could be.
double balance = Econ.getBalance(faction.getAccountId());
for(FPlayer fp : faction.getFPlayers()) {
for (FPlayer fp : faction.getFPlayers()) {
balance = balance + Econ.getBalance(fp.getAccountId());
}
return String.valueOf(balance);

View File

@ -9,11 +9,14 @@ import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.SimpleDateFormat;
import java.util.List;
public abstract class FCommand extends MCommand<P> {
public SimpleDateFormat sdf = new SimpleDateFormat(TL.DATE_FORMAT.toString());
public boolean disableOnLock;
public FPlayer fme;

View File

@ -676,6 +676,7 @@ public enum TL {
DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}] &r"),
FACTION_LOGIN("faction-login", "&e%1$s &9logged in."),
FACTION_LOGOUT("faction-logout", "&e%1$s &9logged out.."),
DATE_FORMAT("date-format", "MM/d/yy h:ma"), // 3/31/15 07:49AM
/**
* Raidable is used in multiple places. Allow more than just true/false.