mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-23 01:27:45 +01:00
Isolate UltimateStacker imports so no errors if US is not installed (#307)
Fixes #306
This commit is contained in:
parent
1bd6219f94
commit
a4f8d12138
@ -40,8 +40,6 @@ import com.bgsoftware.wildstacker.api.objects.StackedBarrel;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.google.common.collect.Multiset.Entry;
|
||||
import com.google.common.collect.Multisets;
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerApi;
|
||||
import com.craftaro.ultimatestacker.api.utils.Stackable;
|
||||
|
||||
import dev.rosewood.rosestacker.api.RoseStackerAPI;
|
||||
import us.lynuxcraft.deadsilenceiv.advancedchests.AdvancedChestsAPI;
|
||||
@ -448,46 +446,33 @@ public class IslandLevelCalculator {
|
||||
// Only count to the highest block in the world for some optimization
|
||||
for (int y = cp.world.getMinHeight(); y < cp.world.getMaxHeight(); y++) {
|
||||
BlockData blockData = cp.chunkSnapshot.getBlockData(x, y, z);
|
||||
Material m = blockData.getMaterial();
|
||||
boolean belowSeaLevel = seaHeight > 0 && y <= seaHeight;
|
||||
// Slabs can be doubled, so check them twice
|
||||
if (Tag.SLABS.isTagged(blockData.getMaterial())) {
|
||||
if (Tag.SLABS.isTagged(m)) {
|
||||
Slab slab = (Slab) blockData;
|
||||
if (slab.getType().equals(Slab.Type.DOUBLE)) {
|
||||
checkBlock(blockData.getMaterial(), belowSeaLevel);
|
||||
checkBlock(m, belowSeaLevel);
|
||||
}
|
||||
}
|
||||
// Hook for Wild Stackers (Blocks and Spawners Only) - this has to use the real
|
||||
// chunk
|
||||
if (addon.isStackersEnabled() && (blockData.getMaterial().equals(Material.CAULDRON)
|
||||
|| blockData.getMaterial().equals(Material.SPAWNER))) {
|
||||
if (addon.isStackersEnabled() && (m.equals(Material.CAULDRON) || m.equals(Material.SPAWNER))) {
|
||||
stackedBlocks.add(new Location(cp.world, (double) x + cp.chunkSnapshot.getX() * 16, y,
|
||||
(double) z + cp.chunkSnapshot.getZ() * 16));
|
||||
}
|
||||
|
||||
Block block = cp.chunk.getBlock(x, y, z);
|
||||
|
||||
if (addon.isUltimateStackerEnabled()) {
|
||||
if (!blockData.getMaterial().equals(Material.AIR)) {
|
||||
Stackable stack = UltimateStackerApi.getBlockStackManager().getBlock(block.getLocation());
|
||||
if (stack != null) {
|
||||
int value = limitCount(blockData.getMaterial());
|
||||
if (belowSeaLevel) {
|
||||
results.underWaterBlockCount.addAndGet((long) stack.getAmount() * value);
|
||||
results.uwCount.add(blockData.getMaterial());
|
||||
} else {
|
||||
results.rawBlockCount.addAndGet((long) stack.getAmount() * value);
|
||||
results.mdCount.add(blockData.getMaterial());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addon.isUltimateStackerEnabled() && !m.isAir()) {
|
||||
Location l = new Location(cp.chunk.getWorld(), x, y, z);
|
||||
UltimateStackerCalc.addStackers(m, l, results, belowSeaLevel, limitCount(m));
|
||||
}
|
||||
|
||||
// Scan chests
|
||||
if (addon.getSettings().isIncludeChests() && CHESTS.contains(blockData.getMaterial())) {
|
||||
if (addon.getSettings().isIncludeChests() && CHESTS.contains(m)) {
|
||||
chestBlocks.add(cp.chunk);
|
||||
}
|
||||
// Add the value of the block's material
|
||||
checkBlock(blockData.getMaterial(), belowSeaLevel);
|
||||
checkBlock(m, belowSeaLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package world.bentobox.level.calculators;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.craftaro.ultimatestacker.api.UltimateStackerApi;
|
||||
import com.craftaro.ultimatestacker.api.utils.Stackable;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
|
||||
/**
|
||||
* Isolates UltimateStacker imports so that they are only loaded if the plugin exists
|
||||
*/
|
||||
public class UltimateStackerCalc {
|
||||
public static void addStackers(Material material, Location location, Results results, boolean belowSeaLevel,
|
||||
int value) {
|
||||
Stackable stack = UltimateStackerApi.getBlockStackManager().getBlock(location);
|
||||
if (stack != null) {
|
||||
if (belowSeaLevel) {
|
||||
results.underWaterBlockCount.addAndGet((long) stack.getAmount() * value);
|
||||
results.uwCount.add(material);
|
||||
} else {
|
||||
results.rawBlockCount.addAndGet((long) stack.getAmount() * value);
|
||||
results.mdCount.add(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user