Skip to content

Commit

Permalink
reduce weight and risk of towny player tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 8, 2019
1 parent 59ffe09 commit 5996f5a
Showing 1 changed file with 104 additions and 104 deletions.
Expand Up @@ -34,130 +34,130 @@ private TownyPlayerExtension(dPlayer player) {

dPlayer player = null;

public Resident getResident() throws NotRegisteredException {
return TownyUniverse.getDataSource().getResident(player.getName());
}

@Override
public String getAttribute(Attribute attribute) {

Resident resident;
try {
resident = TownyUniverse.getDataSource().getResident(player.getName());
}
catch (NotRegisteredException e) {
if (!attribute.hasAlternative()) {
dB.echoError("'" + player.getName() + "' is not registered in Towny!");
// <--[tag]
// @attribute <p@player.has_nation>
// @returns Element(Boolean)
// @description
// Returns whether the player is part of a nation.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("has_nation")) {
return new Element(getResident().hasNation()).getAttribute(attribute.fulfill(1));
}
return null;
}

// <--[tag]
// @attribute <p@player.has_nation>
// @returns Element(Boolean)
// @description
// Returns whether the player is part of a nation.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("has_nation")) {
return new Element(resident.hasNation()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.has_town>
// @returns Element(Boolean)
// @description
// Returns whether the player is part of a town.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("has_town")) {
return new Element(resident.hasTown()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.mode_list>
// @returns dList(Element)
// @description
// Returns the player's towny modes as a list.
// @Plugin DepenizenBukkit, Towny
// -->
else if (attribute.startsWith("mode_list")) {
dList modes = new dList();
for (String mode : resident.getModes()) {
modes.add(new Element(mode).identify());
// <--[tag]
// @attribute <p@player.has_town>
// @returns Element(Boolean)
// @description
// Returns whether the player is part of a town.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("has_town")) {
return new Element(getResident().hasTown()).getAttribute(attribute.fulfill(1));
}
return modes.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.nation_ranks>
// @returns dList(Element)
// @description
// Returns the player's nation ranks.
// @Plugin DepenizenBukkit, Towny
// -->
else if (attribute.startsWith("nation_ranks")) {
dList ranks = new dList();
for (String rank : resident.getNationRanks()) {
ranks.add(new Element(rank).identify());
// <--[tag]
// @attribute <p@player.mode_list>
// @returns dList(Element)
// @description
// Returns the player's towny modes as a list.
// @Plugin DepenizenBukkit, Towny
// -->
else if (attribute.startsWith("mode_list")) {
dList modes = new dList();
for (String mode : getResident().getModes()) {
modes.add(new Element(mode).identify());
}
return modes.getAttribute(attribute.fulfill(1));
}
return ranks.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.nation>
// @returns dNation
// @description
// Returns the player's nation.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("nation")) {
try {
if (resident.hasNation()) {
return new dNation(resident.getTown().getNation()).getAttribute(attribute.fulfill(1));
}
else {
return null;
// <--[tag]
// @attribute <p@player.nation_ranks>
// @returns dList(Element)
// @description
// Returns the player's nation ranks.
// @Plugin DepenizenBukkit, Towny
// -->
else if (attribute.startsWith("nation_ranks")) {
dList ranks = new dList();
for (String rank : getResident().getNationRanks()) {
ranks.add(new Element(rank).identify());
}
return ranks.getAttribute(attribute.fulfill(1));
}
catch (NotRegisteredException e) {
if (!attribute.hasAlternative()) {
dB.echoError("'" + player.getName() + "' is not registered to a nation in Towny!");

// <--[tag]
// @attribute <p@player.nation>
// @returns dNation
// @description
// Returns the player's nation.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("nation")) {
try {
if (getResident().hasNation()) {
return new dNation(getResident().getTown().getNation()).getAttribute(attribute.fulfill(1));
}
else {
return null;
}
}
catch (NotRegisteredException e) {
if (!attribute.hasAlternative()) {
dB.echoError("'" + player.getName() + "' is not registered to a nation in Towny!");
}
}
}
}

// <--[tag]
// @attribute <p@player.town_ranks>
// @returns dList(Element)
// @description
// Returns the player's town ranks.
// @Plugin DepenizenBukkit, Towny
// -->
else if (attribute.startsWith("town_ranks")) {
dList ranks = new dList();
for (String rank : resident.getTownRanks()) {
ranks.add(new Element(rank).identify());
// <--[tag]
// @attribute <p@player.town_ranks>
// @returns dList(Element)
// @description
// Returns the player's town ranks.
// @Plugin DepenizenBukkit, Towny
// -->
else if (attribute.startsWith("town_ranks")) {
dList ranks = new dList();
for (String rank : getResident().getTownRanks()) {
ranks.add(new Element(rank).identify());
}
return ranks.getAttribute(attribute.fulfill(1));
}
return ranks.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <p@player.town>
// @returns dTown
// @description
// Returns the player's town.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("town")) {
try {
if (resident.hasTown()) {
return new dTown(resident.getTown()).getAttribute(attribute.fulfill(1));
// <--[tag]
// @attribute <p@player.town>
// @returns dTown
// @description
// Returns the player's town.
// @Plugin DepenizenBukkit, Towny
// -->
if (attribute.startsWith("town")) {
try {
if (getResident().hasTown()) {
return new dTown(getResident().getTown()).getAttribute(attribute.fulfill(1));
}
else {
return null;
}
}
else {
return null;
catch (NotRegisteredException e) {
if (!attribute.hasAlternative()) {
dB.echoError("'" + player.getName() + "' is not registered to a town in Towny!");
}
}
}
catch (NotRegisteredException e) {
if (!attribute.hasAlternative()) {
dB.echoError("'" + player.getName() + "' is not registered to a town in Towny!");
}
}
catch (NotRegisteredException e) {
if (!attribute.hasAlternative()) {
dB.echoError("'" + player.getName() + "' is not registered in Towny!");
}
}

Expand Down

0 comments on commit 5996f5a

Please sign in to comment.