Skip to content

Commit

Permalink
More Schematic stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fortifier42 committed Jan 24, 2016
1 parent 4bf00f3 commit 2a78412
Showing 1 changed file with 23 additions and 9 deletions.
Expand Up @@ -10,6 +10,7 @@
import net.aufdemrand.denizencore.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand;
import net.aufdemrand.denizencore.scripts.commands.Holdable;
Expand Down Expand Up @@ -241,13 +242,34 @@ public void schematicTags(ReplaceableTagEvent event) {
return;
}

Attribute attribute = event.getAttributes().fulfill(1);

// <--[tag]
// @attribute <schematic.list>
// @returns dList(Element)
// @description
// Returns a list of all loaded schematics.
// -->
if (attribute.startsWith("list")) {
event.setReplaced(new dList(schematics.keySet()).getAttribute(attribute.fulfill(1)));
}

if (!event.hasNameContext()) {
return;
}

String id = event.getNameContext().toUpperCase();

Attribute attribute = event.getAttributes().fulfill(1);

// <--[tag]
// @attribute <schematic[<name>].is_loaded>
// @returns Element(Boolean)
// @description
// Returns whether the schematic is loaded into the server.
// -->
if (attribute.startsWith("is_loaded")) {
event.setReplaced(new Element(schematics.containsKey(id)).getAttribute(attribute.fulfill(1)));
}

if (!schematics.containsKey(id)) {
// Meta below
Expand All @@ -272,7 +294,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns Element(Boolean)
// @description
// Returns whether the schematic exists.
// @plugin WorldEdit
// -->
if (attribute.startsWith("exists")) {
event.setReplaced(new Element(true)
Expand All @@ -285,7 +306,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns Element(Number)
// @description
// Returns the height (Y) of the schematic.
// @plugin WorldEdit
// -->
if (attribute.startsWith("height")) {
event.setReplaced(new Element(set.y_length)
Expand All @@ -298,7 +318,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns Element(Number)
// @description
// Returns the length (Z) of the schematic.
// @plugin WorldEdit
// -->
if (attribute.startsWith("length")) {
event.setReplaced(new Element(set.z_height)
Expand All @@ -311,7 +330,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns Element(Number)
// @description
// Returns the width (X) of the schematic.
// @plugin WorldEdit
// -->
if (attribute.startsWith("width")) {
event.setReplaced(new Element(set.x_width)
Expand All @@ -324,7 +342,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns dMaterial
// @description
// Returns the material for the block at the location in the schematic.
// @plugin WorldEdit
// -->
if (attribute.startsWith("block")) {
if (attribute.hasContext(1) && dLocation.matches(attribute.getContext(1))) {
Expand All @@ -341,7 +358,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns dLocation
// @description
// Returns the origin location of the schematic.
// @plugin WorldEdit
// -->
if (attribute.startsWith("origin")) {
event.setReplaced(new dLocation(null, set.center_x, set.center_y, set.center_z)
Expand All @@ -354,7 +370,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns Element(Number)
// @description
// Returns the number of blocks in the schematic.
// @plugin WorldEdit
// -->
if (attribute.startsWith("blocks")) {
event.setReplaced(new Element(set.blocks.size())
Expand All @@ -367,7 +382,6 @@ public void schematicTags(ReplaceableTagEvent event) {
// @returns dCuboid
// @description
// Returns a cuboid of where the schematic would be if it was pasted at an origin.
// @plugin WorldEdit
// -->
if (attribute.startsWith("cuboid") && attribute.hasContext(1)) {
dLocation origin = dLocation.valueOf(attribute.getContext(1));
Expand Down

0 comments on commit 2a78412

Please sign in to comment.