mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-05 18:37:40 +01:00
Fixed rare case of endless loop over Inventory viewers
This commit is contained in:
parent
cec9a50b15
commit
29ea53683c
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.dre</groupId>
|
||||
<artifactId>brewery</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.8.2</version>
|
||||
<name>Brewery</name>
|
||||
|
||||
<properties>
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: Brewery
|
||||
version: 1.8.1
|
||||
version: 1.8.2
|
||||
main: com.dre.brewery.P
|
||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault, Citadel]
|
||||
authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
|
||||
|
@ -8,6 +8,7 @@ import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -18,6 +19,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@ -469,9 +471,10 @@ public class Barrel implements InventoryHolder {
|
||||
// removes a barrel, throwing included potions to the ground
|
||||
public void remove(Block broken, Player breaker) {
|
||||
if (inventory != null) {
|
||||
while (!inventory.getViewers().isEmpty()) {
|
||||
// Use while loop to fix ConcModExc
|
||||
inventory.getViewers().get(0).closeInventory();
|
||||
List<HumanEntity> viewers = new ArrayList(inventory.getViewers());
|
||||
// Copy List to fix ConcModExc
|
||||
for (HumanEntity viewer : viewers) {
|
||||
viewer.closeInventory();
|
||||
}
|
||||
ItemStack[] items = inventory.getContents();
|
||||
inventory.clear();
|
||||
|
@ -349,10 +349,23 @@ public class InventoryListener implements Listener {
|
||||
barrel.clickInv(event);
|
||||
}
|
||||
|
||||
//public static boolean opening = false;
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (!P.use1_14) return;
|
||||
|
||||
/*Barrel x = null;
|
||||
if (event.getInventory().getHolder() instanceof Barrel) {
|
||||
x = ((Barrel) event.getInventory().getHolder());
|
||||
}
|
||||
|
||||
if (!opening) {
|
||||
opening = true;
|
||||
Barrel finalBarrel = x;
|
||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, () -> {finalBarrel.remove(null, null); opening = false;}, 100);
|
||||
}*/
|
||||
|
||||
// Check for MC Barrel
|
||||
if (event.getInventory().getType() == InventoryType.BARREL) {
|
||||
Inventory inv = event.getInventory();
|
||||
|
Loading…
Reference in New Issue
Block a user