Skip to content

Commit

Permalink
Update towny classes in preparation for events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fortifier42 committed Jan 10, 2016
1 parent 6a77d42 commit 54d8679
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Expand Up @@ -66,6 +66,17 @@ public String getAttribute(Attribute attribute) {
}
}

// <--[tag]
// @attribute <l@location.is_wilderness>
// @returns Element(Boolean)
// @description
// Returns whether the location is wilderness.
// @plugin Depenizen, Towny
// -->
else if (attribute.startsWith("is_wilderness")) {
return new Element(TownyUniverse.isWilderness(location.getBlock())).getAttribute(attribute.fulfill(1));
}

return null;

}
Expand Down
@@ -1,5 +1,9 @@
package net.gnomeffinway.depenizen.support.plugins;

import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.WorldCoord;
import net.aufdemrand.denizen.objects.dCuboid;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
Expand All @@ -11,6 +15,7 @@
import net.gnomeffinway.depenizen.support.Support;
import net.gnomeffinway.depenizen.extensions.towny.TownyLocationExtension;
import net.gnomeffinway.depenizen.extensions.towny.TownyPlayerExtension;
import org.bukkit.Location;

public class TownySupport extends Support {

Expand All @@ -22,6 +27,23 @@ public TownySupport() {
registerAdditionalTags("town", "nation");
}

public static Town fromWorldCoord(WorldCoord coord) {
if (coord == null) {
return null;
}
Location loc = new Location(coord.getBukkitWorld(), coord.getX(), 0, coord.getZ());
try {
String name = TownyUniverse.getTownName(loc);
if (name == null) {
return null;
}
return TownyUniverse.getDataSource().getTown(name);
}
catch (NotRegisteredException e) {
return null;
}
}

@Override
public String additionalTags(Attribute attribute) {

Expand Down

0 comments on commit 54d8679

Please sign in to comment.