1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Block Inventories now close when the Block is broken

This commit is contained in:
mrCookieSlime 2016-05-22 10:26:12 +02:00
parent 3e7ac8c2fc
commit 2f1475a5ba
2 changed files with 18 additions and 1 deletions

View File

@ -630,6 +630,10 @@ public class SlimefunItems {
public static ItemStack TRASH_CAN = null;
public static ItemStack ELYTRA = new ItemStack(Material.ELYTRA);
public static ItemStack INFUSED_ELYTRA = new CustomItem(new CustomItem(ELYTRA, "§5Infused Elytra"), new String[] {"MENDING-1"});
public static ItemStack SOULBOUND_ELYTRA = new CustomItem(ELYTRA, "§cSoulbound Elytra");
// ChestTerminal Addon
public static ItemStack CHEST_TERMINAL = null;

View File

@ -13,6 +13,7 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.ItemStack;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@ -369,7 +370,14 @@ public class BlockStorage {
if (destroy) {
if (storage.hasInventory(l)) storage.clearInventory(l);
if (storage.hasUniversalInventory(l)) storage.getUniversalInventory(l).save();
if (storage.hasUniversalInventory(l)) {
UniversalBlockMenu menu = storage.getUniversalInventory(l);
for (HumanEntity n: menu.toInventory().getViewers()) {
n.closeInventory();
}
storage.getUniversalInventory(l).save();
}
if (ticking_chunks.containsKey(l.getChunk().toString())) {
Set<Block> blocks = ticking_chunks.get(l.getChunk().toString());
blocks.remove(l.getBlock());
@ -499,6 +507,11 @@ public class BlockStorage {
}
public void clearInventory(Location l) {
BlockMenu menu = getInventory(l);
for (HumanEntity n: menu.toInventory().getViewers()) {
n.closeInventory();
}
inventories.get(l).delete(l);
inventories.remove(l);
}