mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-23 18:45:17 +01:00
Add support to hook into AdvancedChests.
https://github.com/BentoBoxWorld/Level/issues/214
This commit is contained in:
parent
e002ade414
commit
311455e921
@ -48,6 +48,7 @@ public class Level extends Addon implements Listener {
|
|||||||
private Pipeliner pipeliner;
|
private Pipeliner pipeliner;
|
||||||
private LevelsManager manager;
|
private LevelsManager manager;
|
||||||
private boolean stackersEnabled;
|
private boolean stackersEnabled;
|
||||||
|
private boolean advChestEnabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
@ -98,6 +99,11 @@ public class Level extends Addon implements Listener {
|
|||||||
if (stackersEnabled) {
|
if (stackersEnabled) {
|
||||||
log("Hooked into WildStackers.");
|
log("Hooked into WildStackers.");
|
||||||
}
|
}
|
||||||
|
// Check if AdvancedChests is enabled on the server
|
||||||
|
advChestEnabled = Bukkit.getPluginManager().getPlugin("AdvancedChests") != null;
|
||||||
|
if (advChestEnabled) {
|
||||||
|
log("Hooked into AdvancedChests.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -278,6 +284,13 @@ public class Level extends Addon implements Listener {
|
|||||||
return stackersEnabled;
|
return stackersEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the advChestEnabled
|
||||||
|
*/
|
||||||
|
public boolean isAdvChestEnabled() {
|
||||||
|
return advChestEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get level from cache for a player.
|
* Get level from cache for a player.
|
||||||
* @param targetPlayer - target player UUID
|
* @param targetPlayer - target player UUID
|
||||||
|
@ -34,6 +34,9 @@ import com.google.common.collect.Multiset;
|
|||||||
import com.google.common.collect.Multiset.Entry;
|
import com.google.common.collect.Multiset.Entry;
|
||||||
import com.google.common.collect.Multisets;
|
import com.google.common.collect.Multisets;
|
||||||
|
|
||||||
|
import us.lynuxcraft.deadsilenceiv.advancedchests.AdvancedChestsAPI;
|
||||||
|
import us.lynuxcraft.deadsilenceiv.advancedchests.chest.AdvancedChest;
|
||||||
|
import us.lynuxcraft.deadsilenceiv.advancedchests.chest.ChestPage;
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.util.Pair;
|
import world.bentobox.bentobox.util.Pair;
|
||||||
@ -430,7 +433,17 @@ public class IslandLevelCalculator {
|
|||||||
// Count blocks in chests
|
// Count blocks in chests
|
||||||
for (BlockState bs : chunk.getTileEntities()) {
|
for (BlockState bs : chunk.getTileEntities()) {
|
||||||
if (bs instanceof Container) {
|
if (bs instanceof Container) {
|
||||||
Inventory inv = ((Container)bs).getSnapshotInventory();
|
if (addon.isAdvChestEnabled()) {
|
||||||
|
AdvancedChest aChest = AdvancedChestsAPI.getChestManager().getAdvancedChest(bs.getLocation());
|
||||||
|
aChest.getPages().stream().map(ChestPage::getInventory).forEach(this::countChestItems);
|
||||||
|
} else {
|
||||||
|
countChestItems(((Container)bs).getSnapshotInventory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void countChestItems(Inventory inv) {
|
||||||
for (ItemStack i : inv) {
|
for (ItemStack i : inv) {
|
||||||
if (i != null && i.getType().isBlock()) {
|
if (i != null && i.getType().isBlock()) {
|
||||||
for (int c = 0; c < i.getAmount(); c++) {
|
for (int c = 0; c < i.getAmount(); c++) {
|
||||||
@ -439,8 +452,6 @@ public class IslandLevelCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan the chunk chests and count the blocks
|
* Scan the chunk chests and count the blocks
|
||||||
|
Loading…
Reference in New Issue
Block a user