Skip to content

Commit

Permalink
Exposed Structrador#structure to childs
Browse files Browse the repository at this point in the history
Exposed Structrador#plugin to childs
Added Cuboid#getEntities
  • Loading branch information
anjoismysign committed Apr 23, 2024
1 parent 231775c commit 3f6b278
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion local-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.698.15</version>
<version>1.698.16</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.698.15</version>
<version>1.698.16</version>
<packaging>pom</packaging>

<properties>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/us/mytheria/bloblib/entities/Cuboid.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -263,4 +264,18 @@ public List<Location> drawEdges(double distance) {
}
return result;
}

/**
* Get the entities in the cuboid.
*
* @return List of entities
*/
public List<Entity> getEntities() {
double distance = getDistance();
Location center = getCenter();
return center.getWorld().getNearbyEntities(center, distance, distance, distance)
.stream()
.filter(entity -> isIn(entity.getLocation()))
.toList();
}
}
9 changes: 2 additions & 7 deletions src/main/java/us/mytheria/bloblib/utilities/Structrador.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
public class Structrador {
private static final ManoratorFactory MANORATOR_FACTORY = BlobLibAPI.getInstance().getManoBukkit().getManoratorFactory();

private final Structure structure;
private final JavaPlugin plugin;
protected final Structure structure;
protected final JavaPlugin plugin;

/**
* Will create a structure from the given location and radius.
Expand Down Expand Up @@ -334,11 +334,6 @@ public void run() {
next.setSilent(true);
Entity added = world.addEntity(next);
added.teleport(entityLocation);
/*
* Intermediate level of API-NMS
* Known to work in 1.20.1
* Might break in future versions
*/
if (added instanceof Hanging hanging) {
BlockFace facing = hanging.getFacing();
hanging.setFacingDirection(
Expand Down

0 comments on commit 3f6b278

Please sign in to comment.