Skip to content

Commit

Permalink
Add skyblock tags for dWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
Fortifier42 committed Jan 10, 2016
1 parent b6c1cd9 commit 7eaed46
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
@@ -0,0 +1,53 @@
package net.gnomeffinway.depenizen.extensions.askyblock;

import com.wasteofplastic.askyblock.ASkyBlockAPI;
import net.aufdemrand.denizen.objects.dWorld;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.tags.Attribute;
import net.gnomeffinway.depenizen.extensions.dObjectExtension;

public class ASkyBlockWorldExtension extends dObjectExtension {

public static boolean describes(dObject pl) {
return pl instanceof dWorld;
}

public static ASkyBlockWorldExtension getFrom(dObject object) {
if (!describes(object)) {
return null;
}
else {
return new ASkyBlockWorldExtension((dWorld) object);
}
}

public ASkyBlockWorldExtension(dWorld world) {
this.world = world;
}

dWorld world;
ASkyBlockAPI api = ASkyBlockAPI.getInstance();

@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}

// <--[tag]
// @attribute <w@world.is_skyblock_world>
// @returns Element(Boolean)
// @description
// Returns whether the world is used by A SkyBlock.
// @plugin Depenizen, A SkyBlock
// -->
if (attribute.startsWith("is_skyblock_world")) {
return new Element(api.getIslandWorld() == world.getWorld() ||
api.getNetherWorld() == world.getWorld()).getAttribute(attribute.fulfill(1));
}

return null;
}

}
Expand Up @@ -9,20 +9,22 @@
import net.aufdemrand.denizencore.tags.Attribute;
import net.gnomeffinway.depenizen.extensions.askyblock.ASkyBlockLocationExtension;
import net.gnomeffinway.depenizen.extensions.askyblock.ASkyBlockPlayerExtension;
import net.gnomeffinway.depenizen.extensions.askyblock.ASkyBlockWorldExtension;
import net.gnomeffinway.depenizen.support.Support;

public class ASkyBlockSupport extends Support {

public ASkyBlockSupport() {
registerProperty(ASkyBlockPlayerExtension.class, dPlayer.class);
registerProperty(ASkyBlockLocationExtension.class, dLocation.class);
registerProperty(ASkyBlockWorldExtension.class, dWorld.class);
}

ASkyBlockAPI api = ASkyBlockAPI.getInstance();

@Override
public String additionalTags(Attribute attribute) {
if (attribute == null ) {
if (attribute == null) {
return null;
}

Expand Down

0 comments on commit 7eaed46

Please sign in to comment.