mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-19 23:57:36 +01:00
Add support for Wild Stacker (#124)
* Add support for Wild Stackers (Blocks Only) * Shorten my recent commit, modified checkBlock method slightly to not pass full BlockData; rather just the Material that is used in the method
This commit is contained in:
parent
1de94afe7e
commit
f779f0ca95
11
pom.xml
11
pom.xml
@ -147,6 +147,11 @@
|
|||||||
<id>codemc-public</id>
|
<id>codemc-public</id>
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<!--Wild Stacker repo-->
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -182,6 +187,12 @@
|
|||||||
<version>${bentobox.version}</version>
|
<version>${bentobox.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Wild Stacker dependency-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.OmerBenGera</groupId>
|
||||||
|
<artifactId>WildStackerAPI</artifactId>
|
||||||
|
<version>b17</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -13,6 +13,7 @@ import world.bentobox.bentobox.api.addons.Addon;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.Database;
|
import world.bentobox.bentobox.database.Database;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.level.calculators.CalcIslandLevel;
|
||||||
import world.bentobox.level.commands.admin.AdminLevelCommand;
|
import world.bentobox.level.commands.admin.AdminLevelCommand;
|
||||||
import world.bentobox.level.commands.admin.AdminTopCommand;
|
import world.bentobox.level.commands.admin.AdminTopCommand;
|
||||||
import world.bentobox.level.commands.island.IslandLevelCommand;
|
import world.bentobox.level.commands.island.IslandLevelCommand;
|
||||||
@ -199,6 +200,13 @@ public class Level extends Addon {
|
|||||||
registerRequestHandler(new LevelRequestHandler(this));
|
registerRequestHandler(new LevelRequestHandler(this));
|
||||||
registerRequestHandler(new TopTenRequestHandler(this));
|
registerRequestHandler(new TopTenRequestHandler(this));
|
||||||
|
|
||||||
|
// Check if WildStackers is enabled on the server
|
||||||
|
if (getPlugin().getServer().getPluginManager().getPlugin("WildStacker") != null) {
|
||||||
|
// I only added support for counting blocks into the island level
|
||||||
|
// Someone else can PR if they want spawners added to the Leveling system :)
|
||||||
|
CalcIslandLevel.stackersEnabled = true;
|
||||||
|
} else CalcIslandLevel.stackersEnabled = false;
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,15 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
import com.bgsoftware.wildstacker.api.WildStackerAPI;
|
||||||
|
import com.bgsoftware.wildstacker.api.objects.StackedBarrel;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.ChunkSnapshot;
|
import org.bukkit.ChunkSnapshot;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.type.Slab;
|
import org.bukkit.block.data.type.Slab;
|
||||||
|
|
||||||
@ -38,6 +41,7 @@ public class CalcIslandLevel {
|
|||||||
private static final String LINE_BREAK = "==================================";
|
private static final String LINE_BREAK = "==================================";
|
||||||
|
|
||||||
public static final long MAX_AMOUNT = 10000;
|
public static final long MAX_AMOUNT = 10000;
|
||||||
|
public static Boolean stackersEnabled;
|
||||||
|
|
||||||
private final Level addon;
|
private final Level addon;
|
||||||
|
|
||||||
@ -122,7 +126,7 @@ public class CalcIslandLevel {
|
|||||||
ChunkSnapshot snapShot = ch.getChunkSnapshot();
|
ChunkSnapshot snapShot = ch.getChunkSnapshot();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(addon.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(addon.getPlugin(), () -> {
|
||||||
this.scanChunk(snapShot);
|
this.scanChunk(snapShot, ch);
|
||||||
count.getAndIncrement();
|
count.getAndIncrement();
|
||||||
if (count.get() == total) {
|
if (count.get() == total) {
|
||||||
Bukkit.getScheduler().cancelTask(queueid);
|
Bukkit.getScheduler().cancelTask(queueid);
|
||||||
@ -131,7 +135,7 @@ public class CalcIslandLevel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanChunk(ChunkSnapshot chunk) {
|
private void scanChunk(ChunkSnapshot chunk, Chunk physicalChunk) {
|
||||||
World chunkWorld = Bukkit.getWorld(chunk.getWorldName());
|
World chunkWorld = Bukkit.getWorld(chunk.getWorldName());
|
||||||
if (chunkWorld == null) return;
|
if (chunkWorld == null) return;
|
||||||
int maxHeight = chunkWorld.getMaxHeight();
|
int maxHeight = chunkWorld.getMaxHeight();
|
||||||
@ -155,23 +159,37 @@ public class CalcIslandLevel {
|
|||||||
if (Tag.SLABS.isTagged(blockData.getMaterial())) {
|
if (Tag.SLABS.isTagged(blockData.getMaterial())) {
|
||||||
Slab slab = (Slab)blockData;
|
Slab slab = (Slab)blockData;
|
||||||
if (slab.getType().equals(Slab.Type.DOUBLE)) {
|
if (slab.getType().equals(Slab.Type.DOUBLE)) {
|
||||||
checkBlock(blockData, belowSeaLevel);
|
checkBlock(blockData.getMaterial(), belowSeaLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkBlock(blockData, belowSeaLevel);
|
|
||||||
|
// Hook for Wild Stackers (Blocks Only)
|
||||||
|
if (stackersEnabled && blockData.getMaterial() == Material.CAULDRON) {
|
||||||
|
Block cauldronBlock = physicalChunk.getBlock(x, y, z);
|
||||||
|
if (WildStackerAPI.getWildStacker().getSystemManager().isStackedBarrel(cauldronBlock)) {
|
||||||
|
StackedBarrel barrel = WildStackerAPI.getStackedBarrel(cauldronBlock);
|
||||||
|
int barrelAmt = WildStackerAPI.getBarrelAmount(cauldronBlock);
|
||||||
|
for (int _x = 0; _x < barrelAmt; _x++) {
|
||||||
|
checkBlock(barrel.getType(), belowSeaLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkBlock(blockData.getMaterial(), belowSeaLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBlock(BlockData bd, boolean belowSeaLevel) {
|
// Didnt see a reason to pass BlockData when all that's used was the material
|
||||||
int count = limitCount(bd.getMaterial());
|
private void checkBlock(Material mat, boolean belowSeaLevel) {
|
||||||
|
int count = limitCount(mat);
|
||||||
if (belowSeaLevel) {
|
if (belowSeaLevel) {
|
||||||
result.underWaterBlockCount.addAndGet(count);
|
result.underWaterBlockCount.addAndGet(count);
|
||||||
result.uwCount.add(bd.getMaterial());
|
result.uwCount.add(mat);
|
||||||
} else {
|
} else {
|
||||||
result.rawBlockCount.addAndGet(count);
|
result.rawBlockCount.addAndGet(count);
|
||||||
result.mdCount.add(bd.getMaterial());
|
result.mdCount.add(mat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user