Skip to content

Commit

Permalink
add tag cuboid.expand
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 14, 2019
1 parent feb2e73 commit 23d55c7
Showing 1 changed file with 27 additions and 1 deletion.
@@ -1,7 +1,6 @@
package com.denizenscript.denizen.objects;

import com.denizenscript.denizen.objects.notable.NotableManager;
import com.denizenscript.denizen.utilities.Utilities;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizencore.objects.*;
Expand All @@ -24,6 +23,7 @@
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -1385,6 +1385,32 @@ public static void registerTags() {
return new CuboidTag(location, cuboid.pairs.get(0).low);
});

// <--[tag]
// @attribute <CuboidTag.expand[<location>]>
// @returns CuboidTag
// @description
// Changes the first member of the CuboidTag to be expanded by the given amount, and returns the changed cuboid.
// This will decrease the min coordinates by the given vector location, and increase the max coordinates by it.
// Supplying a negative input will therefore contract the cuboid.
// Note that you can also specify a single number to expand all coordinates by the same amount (equivalent to specifying a location that is that value on X, Y, and Z).
// -->
registerTag("expand", (attribute, cuboid) -> {
if (!attribute.hasContext(1)) {
Debug.echoError("The tag CuboidTag.expand[...] must have a value.");
return null;
}
Vector expandBy;
if (ArgumentHelper.matchesInteger(attribute.getContext(1))) {
int val = attribute.getIntContext(1);
expandBy = new Vector(val, val, val);
}
else {
expandBy = LocationTag.valueOf(attribute.getContext(1)).toVector();
}
LocationPair pair = cuboid.pairs.get(0);
return new CuboidTag(pair.low.clone().subtract(expandBy), pair.high.clone().add(expandBy));
});

// <--[tag]
// @attribute <CuboidTag.list_players>
// @returns ListTag(PlayerTag)
Expand Down

0 comments on commit 23d55c7

Please sign in to comment.