Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadedXero authored May 10, 2023
1 parent 6102f1a commit 0f28a2e
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.none030</groupId>
<artifactId>MortisStructures</artifactId>
<version>2.1</version>
<version>2.2</version>
<packaging>jar</packaging>

<name>MortisStructures</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private void loadSchematics(ConfigurationSection schematics) {
continue;
}
boolean town = checks.getBoolean("town");
int townRange = checks.getInt("town-range");
boolean water = checks.getBoolean("water");
boolean lava = checks.getBoolean("lava");
List<Material> mustHaveBlocks = null;
Expand Down Expand Up @@ -140,7 +141,7 @@ private void loadSchematics(ConfigurationSection schematics) {
mustNotHaveBiomes.add(biome);
}
}
StructureChecks check = new StructureChecks(town, water, lava, mustHaveBlocks, mustNotHaveBlocks, mustHaveBiomes, mustNotHaveBiomes);
StructureChecks check = new StructureChecks(town, townRange, water, lava, mustHaveBlocks, mustNotHaveBlocks, mustHaveBiomes, mustNotHaveBiomes);
Structure struc = new Structure(key, clipboard, type, world, loc1, loc2, unbreakable, spawns, interval, despawn, tries, check, mobs, commandsOnSpawn, commandsOnDeSpawn);
getConfigManager().getMainManager().getStructureManager().getStructures().add(struc);
getConfigManager().getMainManager().getStructureManager().getStructureById().put(key, struc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void build(Manager manager) {
Operation operation = new ClipboardHolder(getClipboard())
.createPaste(session)
.to(paste)
.ignoreAirBlocks(true)
.ignoreAirBlocks(false)
.build();
Operations.complete(operation);
}
Expand Down Expand Up @@ -217,6 +217,9 @@ private Location getRandomLocation() {
if (isInTown(locations)) {
continue;
}
if (isTownInRange(location)) {
continue;
}
}
}
if (getChecks().hasWater()) {
Expand Down Expand Up @@ -350,6 +353,22 @@ private Location setInGround(Location location) {
return null;
}

private boolean isTownInRange(Location location) {
int radius = checks.getTownRange();
TownyAPI town = TownyAPI.getInstance();
for (int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
for (int y = location.getWorld().getMinHeight(); y <= location.getWorld().getMaxHeight(); y++) {
for (int z = location.getBlockZ() - radius; z <= location.getBlockX() + radius; z++) {
Location loc = new Location(location.getWorld(), x, y, z);
if (!town.isWilderness(loc)) {
return true;
}
}
}
}
return false;
}

private boolean isInTown(List<Location> locations) {
TownyAPI town = TownyAPI.getInstance();
for (Location location : locations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
public class StructureChecks {

private final boolean isInTown;
private final int townRange;
private final boolean isInWater;
private final boolean isInLava;
private final List<Material> mustHaveBlocks;
private final List<Material> mustNotHaveBlocks;
private final List<Biome> mustHaveBiomes;
private final List<Biome> mustNotHaveBiomes;

public StructureChecks(boolean isInTown, boolean isInWater, boolean isInLava, List<Material> mustHaveBlocks, List<Material> mustNotHaveBlocks, List<Biome> mustHaveBiomes, List<Biome> mustNotHaveBiomes) {
public StructureChecks(boolean isInTown, int townRange, boolean isInWater, boolean isInLava, List<Material> mustHaveBlocks, List<Material> mustNotHaveBlocks, List<Biome> mustHaveBiomes, List<Biome> mustNotHaveBiomes) {
this.isInTown = isInTown;
this.townRange = townRange;
this.isInWater = isInWater;
this.isInLava = isInLava;
this.mustHaveBlocks = mustHaveBlocks;
Expand All @@ -29,6 +31,10 @@ public boolean hasTown() {
return isInTown;
}

public int getTownRange() {
return townRange;
}

public boolean hasWater() {
return isInWater;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ schematics:
- "broadcast &aA structure just despawned"
checks:
town: true # Stops structure from spawning in a town
town-range: 100 # The range to look for a town
water: false # Stops structure from spawning in water
lava: false # Stops structure from spawning in lava
must-have-blocks: # Stops structure from spawning if the specified blocks are not near the spawning location
Expand Down
Binary file added target/MortisStructures-2.2.jar
Binary file not shown.
1 change: 1 addition & 0 deletions target/classes/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ schematics:
- "broadcast &aA structure just despawned"
checks:
town: true # Stops structure from spawning in a town
town-range: 100 # The range to look for a town
water: false # Stops structure from spawning in water
lava: false # Stops structure from spawning in lava
must-have-blocks: # Stops structure from spawning if the specified blocks are not near the spawning location
Expand Down
Binary file modified target/classes/me/none030/mortisstructures/config/MainConfig.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Wed May 10 03:48:04 PKT 2023
#Wed May 10 17:42:31 PKT 2023
artifactId=MortisStructures
groupId=me.none030
version=2.1
version=2.2
Binary file added target/original-MortisStructures-2.2.jar
Binary file not shown.

0 comments on commit 0f28a2e

Please sign in to comment.