Add UltimateStacker hook for stacked blocks (#281)

This commit is contained in:
ceze88 2023-04-05 13:14:16 +02:00 committed by GitHub
parent c093796a6e
commit 9c42a8d007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 0 deletions

11
pom.xml
View File

@ -149,6 +149,11 @@
<id>rosewood-repo</id>
<url>https://repo.rosewooddev.io/repository/public/</url>
</repository>
<!-- UltimateStacker repo -->
<repository>
<id>songoda-public</id>
<url>https://repo.songoda.com/repository/public/</url>
</repository>
</repositories>
<dependencies>
@ -234,6 +239,12 @@
<version>1.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>UltimateStacker</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View File

@ -58,6 +58,7 @@ public class Level extends Addon {
private boolean stackersEnabled;
private boolean advChestEnabled;
private boolean roseStackersEnabled;
private boolean ultimateStackerEnabled;
private final List<GameModeAddon> registeredGameModes = new ArrayList<>();
/**
@ -146,6 +147,12 @@ public class Level extends Addon {
if (roseStackersEnabled) {
log("Hooked into RoseStackers.");
}
// Check if UltimateStacker is enabled
ultimateStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker");
if (ultimateStackerEnabled) {
log("Hooked into UltimateStacker.");
}
}
@Override
@ -403,6 +410,13 @@ public class Level extends Addon {
return roseStackersEnabled;
}
/**
* @return the ultimateStackerEnabled
*/
public boolean isUltimateStackerEnabled() {
return ultimateStackerEnabled;
}
/**
* Method Level#getVisitHook returns the visitHook of this object.
*

View File

@ -16,6 +16,9 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedQueue;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.core.compatibility.CompatibleMaterial;
import com.songoda.ultimatestacker.stackable.block.BlockStack;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
@ -524,6 +527,25 @@ public class IslandLevelCalculator {
if (addon.isStackersEnabled() && (blockData.getMaterial().equals(Material.CAULDRON) || blockData.getMaterial().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)) {
BlockStack stack = UltimateStacker.getInstance().getBlockStackManager().getBlock(block, CompatibleMaterial.getMaterial(block));
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());
}
}
}
}
// Scan chests
if (addon.getSettings().isIncludeChests() && CHESTS.contains(blockData.getMaterial())) {
chestBlocks.add(cp.chunk);