Fixes issue where greenhouse biome was not reverted on breakage
Also removed greenhouses that no longer have an island. https://github.com/BentoBoxWorld/Greenhouses/issues/11
This commit is contained in:
parent
96936bdc9a
commit
815caa799a
2
pom.xml
2
pom.xml
|
@ -51,7 +51,7 @@
|
||||||
<!-- Revision variable removes warning about dynamic version -->
|
<!-- Revision variable removes warning about dynamic version -->
|
||||||
<revision>${build.version}-SNAPSHOT</revision>
|
<revision>${build.version}-SNAPSHOT</revision>
|
||||||
<!-- This allows to change between versions and snapshots. -->
|
<!-- This allows to change between versions and snapshots. -->
|
||||||
<build.version>0.3.1</build.version>
|
<build.version>0.3.2</build.version>
|
||||||
<build.number>-LOCAL</build.number>
|
<build.number>-LOCAL</build.number>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package world.bentobox.greenhouses.managers;
|
package world.bentobox.greenhouses.managers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -85,10 +87,13 @@ public class GreenhouseManager implements Listener {
|
||||||
private void loadGreenhouses() {
|
private void loadGreenhouses() {
|
||||||
map.clear();
|
map.clear();
|
||||||
addon.log("Loading greenhouses...");
|
addon.log("Loading greenhouses...");
|
||||||
|
List<Greenhouse> toBeRemoved = new ArrayList<>();
|
||||||
handler.loadObjects().forEach(g -> {
|
handler.loadObjects().forEach(g -> {
|
||||||
GreenhouseResult result = map.addGreenhouse(g);
|
GreenhouseResult result = map.addGreenhouse(g);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case FAIL_NO_ISLAND:
|
case FAIL_NO_ISLAND:
|
||||||
|
// Delete the failed greenhouse
|
||||||
|
toBeRemoved.add(g);
|
||||||
case FAIL_OVERLAPPING:
|
case FAIL_OVERLAPPING:
|
||||||
case NULL:
|
case NULL:
|
||||||
addon.logError(result.name());
|
addon.logError(result.name());
|
||||||
|
@ -102,6 +107,8 @@ public class GreenhouseManager implements Listener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addon.log("Loaded " + map.getSize() + " greenhouses.");
|
addon.log("Loaded " + map.getSize() + " greenhouses.");
|
||||||
|
// Remove the old or outdated greenhouses
|
||||||
|
toBeRemoved.forEach(handler::deleteObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,12 +127,12 @@ public class GreenhouseManager implements Listener {
|
||||||
handler.deleteObject(g);
|
handler.deleteObject(g);
|
||||||
map.removeGreenhouse(g);
|
map.removeGreenhouse(g);
|
||||||
addon.log("Returning biome to original state: " + g.getOriginalBiome().toString());
|
addon.log("Returning biome to original state: " + g.getOriginalBiome().toString());
|
||||||
if (g.getOriginalBiome().equals(Biome.NETHER) || g.getOriginalBiome().equals(Biome.DESERT)
|
for (int x = (int)g.getBoundingBox().getMinX(); x<= (int)g.getBoundingBox().getMaxX(); x++) {
|
||||||
|| g.getOriginalBiome().equals(Biome.DESERT_HILLS)) {
|
for (int z = (int)g.getBoundingBox().getMinZ(); z<= (int)g.getBoundingBox().getMaxZ(); z++) {
|
||||||
for (int x = (int)g.getBoundingBox().getMinX(); x<= (int)g.getBoundingBox().getMaxX(); x++) {
|
// Set back to the original biome
|
||||||
for (int z = (int)g.getBoundingBox().getMinZ(); z<= (int)g.getBoundingBox().getMinZ(); z++) {
|
g.getLocation().getWorld().setBiome(x, z, g.getOriginalBiome());
|
||||||
// Set back to the original biome
|
if (g.getOriginalBiome().equals(Biome.NETHER) || g.getOriginalBiome().equals(Biome.DESERT)
|
||||||
g.getLocation().getWorld().setBiome(x, z, g.getOriginalBiome());
|
|| g.getOriginalBiome().equals(Biome.DESERT_HILLS)) {
|
||||||
for (int y = g.getFloorHeight(); y< g.getCeilingHeight(); y++) {
|
for (int y = g.getFloorHeight(); y< g.getCeilingHeight(); y++) {
|
||||||
Block b = g.getLocation().getWorld().getBlockAt(x, y, z);
|
Block b = g.getLocation().getWorld().getBlockAt(x, y, z);
|
||||||
// Remove any water
|
// Remove any water
|
||||||
|
|
Loading…
Reference in New Issue