Fix bug when breaking a barrel

This commit is contained in:
Sn0wStorm 2019-08-19 14:37:45 +02:00
parent 4cd2da083c
commit f9871d23fa

View File

@ -1,28 +1,25 @@
package com.dre.brewery;
import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.block.Block;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import com.dre.brewery.integration.CitadelBarrel;
import com.dre.brewery.integration.GriefPreventionBarrel;
import com.dre.brewery.integration.LWCBarrel;
import com.dre.brewery.integration.LogBlockBarrel;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
public class Barrel implements InventoryHolder {
@ -472,10 +469,12 @@ public class Barrel implements InventoryHolder {
// removes a barrel, throwing included potions to the ground
public void remove(Block broken, Player breaker) {
if (inventory != null) {
for (HumanEntity human : inventory.getViewers()) {
human.closeInventory();
while (!inventory.getViewers().isEmpty()) {
// Use while loop to fix ConcModExc
inventory.getViewers().get(0).closeInventory();
}
ItemStack[] items = inventory.getContents();
inventory.clear();
if (P.p.useLB && breaker != null) {
try {
LogBlockBarrel.breakBarrel(breaker, items, spigot.getLocation());