Skip to content

Commit

Permalink
Fix some faction tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Sep 8, 2013
1 parent ea20907 commit 1d1a8ea
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/gnomeffinway/depenizen/Depenizen.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.palmergames.bukkit.towny.Towny;
import com.vexsoftware.votifier.Votifier;

public class Depenizen extends JavaPlugin{
public class Depenizen extends JavaPlugin {

public static mcMMO mcmmo;
public static Factions factions;
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/net/gnomeffinway/depenizen/objects/dFaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public dFaction(Faction faction) {
dB.echoError("Faction referenced is null!");
}

public Faction getFaction() {
return faction;
}

/////////////////////
// dObject Methods
/////////////////
Expand Down Expand Up @@ -103,9 +107,13 @@ public String getAttribute(Attribute attribute) {
return new Element(Money.get(faction))
.getAttribute(attribute.fulfill(1));

else if (attribute.startsWith("home"))
return new dLocation(faction.getHome().asBukkitBlock().getLocation())
.getAttribute(attribute.fulfill(1));
else if (attribute.startsWith("home")) {
if (faction.hasHome())
return new dLocation(faction.getHome().asBukkitBlock().getLocation())
.getAttribute(attribute.fulfill(1));
else
return new Element("null").getAttribute(attribute.fulfill(1));
}

else if (attribute.startsWith("isopen") || attribute.startsWith("is_open"))
return new Element(faction.isOpen())
Expand Down Expand Up @@ -136,27 +144,20 @@ else if (attribute.startsWith("power"))
.getAttribute(attribute.fulfill(1));

else if (attribute.startsWith("relation")) {

Faction to = null;

for (FactionColl fc : FactionColls.get().getColls())
for (Faction f : fc.getAll())
if (f.getComparisonName().equalsIgnoreCase(attribute.getContext(1))) {
to = f;
break;
}
dFaction to = valueOf(attribute.getContext(1));

if(to != null)
return new Element(faction.getRelationTo(to).name())
return new Element(faction.getRelationTo(to.getFaction()).toString())
.getAttribute(attribute.fulfill(1));

else
return new Element("null").getAttribute(attribute.fulfill(1));
}

else if (attribute.startsWith("size"))
return new Element(faction.getLandCount())
.getAttribute(attribute.fulfill(1));

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

}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/gnomeffinway/depenizen/objects/dJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.ObjectFetcher;
import net.aufdemrand.denizen.objects.dObject;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.tags.Attribute;
import net.aufdemrand.denizen.utilities.debugging.dB;

Expand Down
19 changes: 12 additions & 7 deletions src/main/java/net/gnomeffinway/depenizen/tags/FactionsTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.aufdemrand.denizen.events.ReplaceableTagEvent;
import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.tags.Attribute;
import net.aufdemrand.denizen.utilities.debugging.dB;
Expand All @@ -17,8 +16,6 @@
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.FFlag;
import com.massivecraft.mcore.money.Money;

public class FactionsTags implements Listener {

Expand Down Expand Up @@ -63,17 +60,25 @@ public void factionsTags(ReplaceableTagEvent event) {

if (attribute.startsWith("factions")) {
if (player.hasFaction()) {
if (attribute.startsWith("role"))
event.setReplaced(new Element(player.getRole().toString()).getAttribute(attribute.fulfill(2)));
if (attribute.startsWith("role")) {
if (player.getRole() != null)
event.setReplaced(new Element(player.getRole().toString()).getAttribute(attribute.fulfill(2)));
else
event.setReplaced(new Element("null").getAttribute(attribute.fulfill(2)));
}

else if (attribute.startsWith("title"))
event.setReplaced(new Element(player.getTitle()).getAttribute(attribute.fulfill(2)));
if (player.hasTitle())
event.setReplaced(new Element(player.getTitle()).getAttribute(attribute.fulfill(2)));
else
event.setReplaced(new Element("null").getAttribute(attribute.fulfill(2)));
}

if (attribute.startsWith("power"))
event.setReplaced(new Element(player.getPower()).getAttribute(attribute.fulfill(2)));
}
if (attribute.startsWith("faction")) {

else if (attribute.startsWith("faction")) {
event.setReplaced(new dFaction(player.getFaction()).getAttribute(attribute.fulfill(1)));
}
}
Expand Down

0 comments on commit 1d1a8ea

Please sign in to comment.