Skip to content

Commit

Permalink
Fix SimpleClans, remedy mcMMO Party stuff.
Browse files Browse the repository at this point in the history
Renamed dParty to Party
Fixed some issues with simpleclans not returning the correct values.
Add a bundle of tags to SimpleClans.
  • Loading branch information
Fortifier42 committed Jan 7, 2016
1 parent 015a770 commit 34688b4
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 18 deletions.
Expand Up @@ -8,7 +8,7 @@
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import net.gnomeffinway.depenizen.extensions.dObjectExtension;
import net.gnomeffinway.depenizen.objects.mcmmo.dParty;
import net.gnomeffinway.depenizen.objects.dParty;

public class McMMOPlayerExtension extends dObjectExtension {

Expand Down
Expand Up @@ -5,7 +5,7 @@
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import net.gnomeffinway.depenizen.extensions.dObjectExtension;
import net.gnomeffinway.depenizen.objects.simpleclans.dClan;
import net.gnomeffinway.depenizen.objects.dClan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;

public class SimpleClansPlayerExtension extends dObjectExtension {
Expand Down Expand Up @@ -141,6 +141,33 @@ else if (attribute.startsWith("total")) {
return null;
}
}

// <--[tag]
// @attribute <p@player.simpleclans.rank>
// @returns Element
// @description
// Returns the player's rank within the clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("rank")) {
String rank = cplayer.getRank();
if (rank == null) {
return null;
}
return new Element(rank).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.simpleclans.is_trusted>
// @returns Element(Boolean)
// @description
// Returns whether the player has trusted status in the clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("is_trusted")) {
return new Element(cplayer.isTrusted()).getAttribute(attribute.fulfill(1));
}

else {
return null;
}
Expand Down
@@ -1,5 +1,6 @@
package net.gnomeffinway.depenizen.objects.simpleclans;
package net.gnomeffinway.depenizen.objects;

import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.Fetchable;
Expand All @@ -11,6 +12,7 @@
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.bukkit.Location;

public class dClan implements dObject {

Expand Down Expand Up @@ -94,6 +96,10 @@ public dObject setPrefix(String s) {
return this;
}

public Clan getClan() {
return clan;
}

@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
Expand Down Expand Up @@ -247,6 +253,69 @@ else if (attribute.startsWith("kill_death_ratio")) {
return new Element(clan.getTotalKDR()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <clan@clan.home_location>
// @returns dLocation
// @description
// Returns the clans home location if it has one.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("home_location")) {
Location home = clan.getHomeLocation();
if (home == null) {
return null;
}
return new dLocation(home).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <clan@clan.name>
// @returns Element
// @description
// Returns the clan's name.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("name")) {
return new Element(clan.getName()).getAttribute(attribute.fulfill(1));
}

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

// <--[tag]
// @attribute <clan@clan.warring_with[<clan>]>
// @returns Element(Boolean)
// @description
// Returns whether the clan is at war with another clan.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("warring_with") && attribute.hasContext(1)) {
dClan opponent = dClan.valueOf(attribute.getContext(1));
if (opponent == null) {
return null;
}
return new Element(clan.isWarring(opponent.getClan())).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <clan@clan.friendly_fire>
// @returns Element(Boolean)
// @description
// Returns whether the clan has friendly fire enabled.
// @plugin Depenizen, SimpleClans
// -->
else if (attribute.startsWith("friendly_fire")) {
return new Element(clan.isFriendlyFire()).getAttribute(attribute.fulfill(1));
}

return new Element(identify()).getAttribute(attribute);
}
}
@@ -1,4 +1,4 @@
package net.gnomeffinway.depenizen.objects.mcmmo;
package net.gnomeffinway.depenizen.objects;

import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
Expand All @@ -21,7 +21,7 @@ public static dParty valueOf(String string) {
return dParty.valueOf(string, null);
}

@Fetchable("dparty")
@Fetchable("party")
public static dParty valueOf(String string, TagContext context) {
if (string == null) {
return null;
Expand All @@ -30,7 +30,7 @@ public static dParty valueOf(String string, TagContext context) {
////////
// Match party name

string = string.replace("dparty@", "");
string = string.replace("party@", "");
Party party = PartyManager.getParty(string);
if (party == null) {
return null;
Expand All @@ -39,7 +39,7 @@ public static dParty valueOf(String string, TagContext context) {
}

public static boolean matches(String arg) {
arg = arg.replace("dparty@", "");
arg = arg.replace("party@", "");
return PartyManager.getParty(arg) != null;
}

Expand All @@ -66,7 +66,7 @@ public dParty(Party party) {
}
}

String prefix = "dParty";
String prefix = "Party";

@Override
public String getPrefix() {
Expand All @@ -85,12 +85,12 @@ public boolean isUnique() {

@Override
public String getObjectType() {
return "dParty";
return "Party";
}

@Override
public String identify() {
return "dparty@" + party.getName();
return "party@" + party.getName();
}

@Override
Expand Down Expand Up @@ -129,7 +129,7 @@ public String getAttribute(Attribute attribute) {
// @plugin Depenizen, mcMMO
// -->
else if (attribute.startsWith("leader")) {
return dPlayer.valueOf(party.getLeader().getUniqueId().toString()).getAttribute(attribute.fulfill(1));
return new dPlayer(party.getLeader().getUniqueId()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
Expand Down
Expand Up @@ -8,7 +8,7 @@
import net.gnomeffinway.depenizen.events.mcMMO.mcMMOPlayerLevelDownScriptEvent;
import net.gnomeffinway.depenizen.events.mcMMO.mcMMOPlayerLevelUpScriptEvent;
import net.gnomeffinway.depenizen.extensions.mcmmo.McMMOPlayerExtension;
import net.gnomeffinway.depenizen.objects.mcmmo.dParty;
import net.gnomeffinway.depenizen.objects.dParty;
import net.gnomeffinway.depenizen.support.Support;

public class McMMOSupport extends Support {
Expand Down
Expand Up @@ -4,7 +4,7 @@
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.tags.Attribute;
import net.gnomeffinway.depenizen.extensions.simpleclans.SimpleClansPlayerExtension;
import net.gnomeffinway.depenizen.objects.simpleclans.dClan;
import net.gnomeffinway.depenizen.objects.dClan;
import net.gnomeffinway.depenizen.support.Support;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
Expand All @@ -18,16 +18,20 @@ public SimpleClansSupport() {
registerAdditionalTags("simpleclans");
}

public ClanPlayer getFrom(dPlayer p) {
return new ClanPlayer(p.getOfflinePlayer().getUniqueId());
}

@Override
public String additionalTags(Attribute attribute) {
if (attribute.startsWith("simpleclans")) {
attribute = attribute.fulfill(1);

if (attribute.startsWith("list_clans")) {
if (attribute.startsWith("clan") && attribute.hasContext(1)) {
dClan c = dClan.valueOf(attribute.getContext(1));
if (c == null) {
return null;
}
return c.getAttribute(attribute.fulfill(1));
}

else if (attribute.startsWith("list_clans")) {
dList clans = new dList();
for (Clan cl : SimpleClans.getInstance().getClanManager().getClans()) {
clans.add(new dClan(cl).identify());
Expand Down

0 comments on commit 34688b4

Please sign in to comment.