Skip to content

Commit

Permalink
Formatting, fix fatal flaws, organizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Jan 23, 2014
1 parent 4ad7a2f commit 8f0823e
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 154 deletions.
34 changes: 12 additions & 22 deletions src/main/java/net/gnomeffinway/depenizen/objects/dFaction.java
Expand Up @@ -106,7 +106,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <faction@faction.balance>
// @returns Element(Double)
// @returns Element(Decimal)
// @description
// Returns the amount of money the faction currently has.
// @plugin Factions
Expand All @@ -115,13 +115,13 @@ public String getAttribute(Attribute attribute) {
return new Element(Money.get(faction))
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <faction@faction.home>
// @returns dLocation
// @description
// Returns the location of the faction's home, if any.
// @plugin Factions
// -->
// <--[tag]
// @attribute <faction@faction.home>
// @returns dLocation
// @description
// Returns the location of the faction's home, if any.
// @plugin Factions
// -->
else if (attribute.startsWith("home")) {
if (faction.hasHome())
return new dLocation(faction.getHome().asBukkitLocation())
Expand Down Expand Up @@ -171,7 +171,7 @@ else if (attribute.startsWith("ispermanent") || attribute.startsWith("is_permane
// @plugin Factions
// -->
else if (attribute.startsWith("leader"))
return new dPlayer(faction.getLeader().getPlayer())
return dPlayer.valueOf(faction.getLeader().getName())
.getAttribute(attribute.fulfill(1));

// <--[tag]
Expand All @@ -187,7 +187,7 @@ else if (attribute.startsWith("name"))

// <--[tag]
// @attribute <faction@faction.player_count>
// @returns Element(Integer)
// @returns Element(Number)
// @description
// Returns the number of players in the faction.
// @plugin Factions
Expand All @@ -198,7 +198,7 @@ else if (attribute.startsWith("playercount") || attribute.startsWith("player_cou

// <--[tag]
// @attribute <faction@faction.power>
// @returns Element(Double)
// @returns Element(Decimal)
// @description
// Returns the amount of power the faction currently has.
// @plugin Factions
Expand Down Expand Up @@ -226,24 +226,14 @@ else if (attribute.startsWith("relation")) {

// <--[tag]
// @attribute <faction@faction.size>
// @returns Element(Integer)
// @returns Element(Number)
// @description
// Returns the amount of land the faction has.
// @plugin Factions
// -->
else if (attribute.startsWith("size"))
return new Element(faction.getLandCount())
.getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <faction@faction.leader>
// @returns Element(String)
// @description
// Returns the name of the faction leader.
// @plugin Factions
// -->
else if (attribute.startsWith("leader"))
return new Element(faction.getLeader().getName())
.getAttribute(attribute.fulfill(1));

return new Element(identify()).getAttribute(attribute);

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/net/gnomeffinway/depenizen/objects/dJob.java
Expand Up @@ -148,7 +148,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <job@job[<player>].xp.max>
// @returns Element(Integer)
// @returns Element(Number)
// @description
// Returns the maximum experience a player can get in a specified job.
// @plugin Jobs
Expand All @@ -160,7 +160,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <job@job[<player>].xp.level>
// @returns Element(Integer)
// @returns Element(Number)
// @description
// Returns the current experience level a player has in a specified job.
// @plugin Jobs
Expand All @@ -181,14 +181,25 @@ public String getAttribute(Attribute attribute) {
}
}

// <--[tag]
// @attribute <job@job.color>
// @returns Element(ChatColor)
// @description
// Returns the ChatColor of the job.
// @plugin Jobs
// -->
if (attribute.startsWith("color"))
return new Element(job.getChatColor().toString())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <job@job.description>
// @returns Element
// @description
// Returns the description of the job.
// @plugin Jobs
// -->
if (attribute.startsWith("description"))
else if (attribute.startsWith("description"))
return new Element(job.getDescription()).getAttribute(attribute.fulfill(1));

else if (attribute.startsWith("name")) {
Expand Down Expand Up @@ -216,17 +227,6 @@ else if (attribute.startsWith("name")) {
return new Element(job.getName()).getAttribute(attribute);
}

// <--[tag]
// @attribute <job@job.color>
// @returns Element(ChatColor)
// @description
// Returns the ChatColor of the job.
// @plugin Jobs
// -->
else if (attribute.startsWith("color"))
return new Element(job.getChatColor().toString())
.getAttribute(attribute.fulfill(1));

return new Element(identify()).getAttribute(attribute.fulfill(1));

}
Expand Down
205 changes: 102 additions & 103 deletions src/main/java/net/gnomeffinway/depenizen/objects/dNation.java
Expand Up @@ -98,131 +98,130 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <nation@nation.balance>
// @returns Element(Double)
// @returns Element(Decimal)
// @description
// Returns the current money balance of the nation.
// @plugin Towny
// -->
if (attribute.startsWith("balance"))
if (attribute.startsWith("balance")) {
try {
return new Element(nation.getHoldingBalance()).getAttribute(attribute.fulfill(1));
} catch (EconomyException e) {
dB.echoError("Invalid economy response!");
}
}

// <--[tag]
// @attribute <nation@nation.capital>
// @returns dTown
// @description
// Returns the capital city of the nation as a dTown.
// @plugin Towny
// -->
else if (attribute.startsWith("capital"))
// <--[tag]
// @returns dTown
// @description
// Returns the capital city of the nation as a dTown.
// @plugin Towny
// -->
else if (attribute.startsWith("capital")) {
if (nation.hasCapital())
return new dTown(nation.getCapital())
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <nation@nation.king>
// @returns dPlayer
// @description
// Returns the king of the nation.
// @plugin Towny
// -->
else if (attribute.startsWith("king"))
return dPlayer.valueOf(nation.getCapital().getMayor().getName())
.getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <nation@nation.is_neutral>
// @returns Element(Boolean)
// @description
// Returns true if the nation is neutral.
// @plugin Towny
// -->
else if (attribute.startsWith("isneutral") || attribute.startsWith("is_neutral"))
return new Element(nation.isNeutral())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.is_neutral>
// @returns Element(Boolean)
// @description
// Returns true if the nation is neutral.
// @plugin Towny
// -->
else if (attribute.startsWith("isneutral") || attribute.startsWith("is_neutral"))
return new Element(nation.isNeutral())
.getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <nation@nation.king>
// @returns dPlayer
// @description
// Returns the king of the nation.
// @plugin Towny
// -->
else if (attribute.startsWith("king"))
return dPlayer.valueOf(nation.getCapital().getMayor().getName())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.player_count>
// @returns Element(Integer)
// @description
// Returns the amount of players in the nation.
// @plugin Towny
// -->
else if (attribute.startsWith("playercount") || attribute.startsWith("player_count"))
return new Element(nation.getNumResidents())
.getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <nation@nation.name>
// @returns Element
// @description
// Returns the nation's name.
// @plugin Towny
else if (attribute.startsWith("name"))
return new Element(nation.getName())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @returns Element(Number)
// @description
// Returns the amount of players in the nation.
// @plugin Towny
// -->
else if (attribute.startsWith("playercount") || attribute.startsWith("player_count"))
return new Element(nation.getNumResidents())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.relation[<nation>]>
// @returns Element
// @description
// Returns the nation's current relation with another nation.
// @plugin Towny
// -->
else if (attribute.startsWith("relation")) {

// <--[tag]
// @attribute <nation@nation.relation[<nation>]>
// @returns Element
// @description
// Returns the nation's current relation with another nation.
// @plugin Towny
// -->
else if (attribute.startsWith("relation")) {
try {
dNation to = valueOf(attribute.getContext(1));

try {
dNation to = valueOf(attribute.getContext(1));
if (nation.hasAlly(to.nation))
return new Element("allies").getAttribute(attribute.fulfill(1));
else if (nation.hasEnemy(to.nation))
return new Element("enemies").getAttribute(attribute.fulfill(1));
else
return new Element("neutral").getAttribute(attribute.fulfill(1));

if (nation.hasAlly(to.nation))
return new Element("allies").getAttribute(attribute.fulfill(1));
else if (nation.hasEnemy(to.nation))
return new Element("enemies").getAttribute(attribute.fulfill(1));
else
return new Element("neutral").getAttribute(attribute.fulfill(1));
} catch (Exception e) {}

} catch (Exception e) {
}
}

}
// <--[tag]
// @attribute <nation@nation.tag>
// @returns Element
// @description
// Returns the nation's tag.
// @plugin Towny
// -->
else if (attribute.startsWith("tag")) {
if (nation.hasTag())
return new Element(nation.getTag())
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <nation@nation.taxes>
// @returns Element(Decimal)
// @description
// Returns the nation's current taxes.
// @plugin Towny
// -->
else if (attribute.startsWith("taxes"))
return new Element(nation.getTaxes())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.tag>
// @returns Element
// @description
// Returns the nation's tag.
// @plugin Towny
// -->
else if (attribute.startsWith("tag"))
if (nation.hasTag())
return new Element(nation.getTag())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.taxes>
// @returns Element(Double)
// @description
// Returns the nation's current taxes.
// @plugin Towny
// -->
else if (attribute.startsWith("taxes"))
return new Element(nation.getTaxes())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.town_count>
// @returns Element(Integer)
// @description
// Returns the number of towns in the nation.
// @plugin Towny
// -->
else if (attribute.startsWith("towncount") || attribute.startsWith("town_count"))
return new Element(nation.getNumTowns())
.getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <nation@nation.name>
// @returns Element(String)
// @description
// Returns the nation's current name.
// @plugin Towny
// -->
else if (attribute.startsWith("name"))
return new Element(nation.getName())
.getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <nation@nation.town_count>
// @returns Element(Number)
// @description
// Returns the number of towns in the nation.
// @plugin Towny
// -->
else if (attribute.startsWith("towncount") || attribute.startsWith("town_count"))
return new Element(nation.getNumTowns())
.getAttribute(attribute.fulfill(1));

return new Element(identify()).getAttribute(attribute.fulfill(0));

Expand Down

0 comments on commit 8f0823e

Please sign in to comment.