Adds support for double slabs.

https://github.com/BentoBoxWorld/Level/issues/64
This commit is contained in:
tastybento 2019-07-06 10:31:42 -07:00
parent 1e1e53cf57
commit 908027e6ba
2 changed files with 18 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<groupId>world.bentobox</groupId> <groupId>world.bentobox</groupId>
<artifactId>level</artifactId> <artifactId>level</artifactId>
<version>1.5.1-SNAPSHOT</version> <version>1.6.0-SNAPSHOT</version>
<name>Level</name> <name>Level</name>
<description>Level is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description> <description>Level is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like SkyBlock or AcidIsland.</description>
@ -66,7 +66,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.14.1-R0.1-SNAPSHOT</version> <version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -12,7 +12,10 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChunkSnapshot; import org.bukkit.ChunkSnapshot;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Slab;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import com.google.common.collect.HashMultiset; import com.google.common.collect.HashMultiset;
@ -126,11 +129,18 @@ public class CalcIslandLevel {
} }
for (int y = 0; y < island.getCenter().getWorld().getMaxHeight(); y++) { for (int y = 0; y < island.getCenter().getWorld().getMaxHeight(); y++) {
Material blockData = chunk.getBlockType(x, y, z); BlockData blockData = chunk.getBlockData(x, y, z);
int seaHeight = addon.getPlugin().getIWM().getSeaHeight(world); int seaHeight = addon.getPlugin().getIWM().getSeaHeight(world);
boolean belowSeaLevel = seaHeight > 0 && y <= seaHeight; boolean belowSeaLevel = seaHeight > 0 && y <= seaHeight;
// Air is free // Air is free
if (!blockData.equals(Material.AIR)) { if (!blockData.getMaterial().equals(Material.AIR)) {
// Slabs can be doubled, so check them twice
if (Tag.SLABS.isTagged(blockData.getMaterial())) {
Slab slab = (Slab)blockData;
if (slab.getType().equals(Slab.Type.DOUBLE)) {
checkBlock(blockData, belowSeaLevel);
}
}
checkBlock(blockData, belowSeaLevel); checkBlock(blockData, belowSeaLevel);
} }
} }
@ -138,14 +148,14 @@ public class CalcIslandLevel {
} }
} }
private void checkBlock(Material md, boolean belowSeaLevel) { private void checkBlock(BlockData bd, boolean belowSeaLevel) {
int count = limitCount(md); int count = limitCount(bd.getMaterial());
if (belowSeaLevel) { if (belowSeaLevel) {
result.underWaterBlockCount += count; result.underWaterBlockCount += count;
result.uwCount.add(md); result.uwCount.add(bd.getMaterial());
} else { } else {
result.rawBlockCount += count; result.rawBlockCount += count;
result.mdCount.add(md); result.mdCount.add(bd.getMaterial());
} }
} }