use of com.bgsoftware.wildstacker.api.objects.StackedBarrel in project IridiumSkyblock by Iridium-Development.
the class WildStackerSupport method getExtraBlocks.
@Override
public int getExtraBlocks(Island island, XMaterial material) {
IslandBlocks islandBlocks = IridiumSkyblock.getInstance().getIslandManager().getIslandBlock(island, material);
int stackedBlocks = 0;
for (StackedBarrel stackedBarrel : WildStackerAPI.getWildStacker().getSystemManager().getStackedBarrels()) {
if (!island.isInIsland(stackedBarrel.getLocation()))
continue;
if (material != XMaterial.matchXMaterial(stackedBarrel.getType()))
continue;
if (material == XMaterial.matchXMaterial(stackedBarrel.getType())) {
stackedBlocks--;
} else {
stackedBlocks += stackedBarrel.getStackAmount();
}
}
islandBlocks.setExtraAmount(stackedBlocks);
return stackedBlocks;
}
use of com.bgsoftware.wildstacker.api.objects.StackedBarrel in project Level by BentoBoxWorld.
the class IslandLevelCalculator method handleStackedBlocks.
private void handleStackedBlocks() {
// Deal with any stacked blocks
Iterator<Location> it = stackedBlocks.iterator();
while (it.hasNext()) {
Location v = it.next();
Util.getChunkAtAsync(v).thenAccept(c -> {
Block cauldronBlock = v.getBlock();
boolean belowSeaLevel = seaHeight > 0 && v.getBlockY() <= seaHeight;
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);
}
}
it.remove();
});
}
}
use of com.bgsoftware.wildstacker.api.objects.StackedBarrel in project RoseStacker by Rosewood-Development.
the class WildStackerPluginConverter method convert.
@Override
public void convert() {
StackManager stackManager = this.rosePlugin.getManager(StackManager.class);
// Force save loaded data
SystemManager systemHandler = WildStackerAPI.getWildStacker().getSystemManager();
systemHandler.performCacheSave();
// Go through the database to be able to load all information
DatabaseConnector connector = new SQLiteConnector(this.wildStacker, "database");
connector.connect(connection -> {
// Load barrels (blocks)
Set<StackedBlock> stackedBlocks = new HashSet<>();
try (Statement statement = connection.createStatement()) {
ResultSet result = statement.executeQuery("SELECT location, stackAmount FROM barrels");
while (result.next()) {
Location location = this.parseLocation(result.getString("location"), ',');
if (location == null)
continue;
int amount = result.getInt("stackAmount");
Material type = systemHandler.getStackedSnapshot(location.getChunk()).getStackedBarrelItem(location).getValue().getType();
Block block = location.getBlock();
// Remove hologram thingy
StackedBarrel barrel = systemHandler.getStackedBarrel(block);
if (barrel != null)
barrel.removeDisplayBlock();
// Set the block type to the stack type since we just removed the hologram thingy
block.setType(type);
// Stacks of 1 aren't really stacks
if (amount == 1)
continue;
stackedBlocks.add(new StackedBlock(amount, block));
}
}
// Load spawners
Set<StackedSpawner> stackedSpawners = new HashSet<>();
try (Statement statement = connection.createStatement()) {
ResultSet result = statement.executeQuery("SELECT location, stackAmount FROM spawners");
while (result.next()) {
Location location = this.parseLocation(result.getString("location"), ',');
if (location == null)
continue;
Block block = location.getBlock();
BlockState blockState = block.getState();
if (!(blockState instanceof CreatureSpawner))
continue;
int amount = result.getInt("stackAmount");
stackedSpawners.add(new StackedSpawner(amount, location));
}
}
if (!stackedBlocks.isEmpty() || !stackedSpawners.isEmpty()) {
Bukkit.getScheduler().runTask(this.rosePlugin, () -> {
for (StackedBlock stackedBlock : stackedBlocks) stackManager.createBlockStack(stackedBlock.getLocation().getBlock(), stackedBlock.getStackSize());
for (StackedSpawner stackedSpawner : stackedSpawners) stackManager.createSpawnerStack(stackedSpawner.getLocation().getBlock(), stackedSpawner.getStackSize(), false);
});
}
});
}
Aggregations