1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Merge pull request #457 from dpkirchner/master

Fix ConcurrentModificationException that occurred when reactor explodes.
This commit is contained in:
TheBusyBiscuit 2017-10-14 09:45:03 +02:00 committed by GitHub
commit 96e8e33391
3 changed files with 13 additions and 13 deletions

View File

@ -1,8 +1,10 @@
package me.mrCookieSlime.Slimefun.api;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -415,11 +417,7 @@ public class BlockStorage {
if (destroy) {
if (storage.hasInventory(l)) storage.clearInventory(l);
if (storage.hasUniversalInventory(l)) {
UniversalBlockMenu menu = storage.getUniversalInventory(l);
for (HumanEntity n: menu.toInventory().getViewers()) {
n.closeInventory();
}
storage.getUniversalInventory(l).close();
storage.getUniversalInventory(l).save();
}
if (ticking_chunks.containsKey(l.getChunk().toString())) {
@ -552,10 +550,11 @@ public class BlockStorage {
public void clearInventory(Location l) {
BlockMenu menu = getInventory(l);
for (HumanEntity n: menu.toInventory().getViewers()) {
n.closeInventory();
for(HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) {
human.closeInventory();
}
inventories.get(l).delete(l);
inventories.remove(l);
}

View File

@ -1,7 +1,8 @@
package me.mrCookieSlime.Slimefun.api.inventory;
import java.io.File;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -131,9 +132,7 @@ public class BlockMenu extends ChestMenu {
}
public void close() {
Iterator<HumanEntity> iterator = toInventory().getViewers().iterator();
while (iterator.hasNext()) {
HumanEntity human = iterator.next();
for(HumanEntity human: new ArrayList<>(toInventory().getViewers())) {
human.closeInventory();
}
}

View File

@ -1,6 +1,8 @@
package me.mrCookieSlime.Slimefun.api.inventory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
@ -89,7 +91,7 @@ public class UniversalBlockMenu extends ChestMenu {
}
public void close() {
for (HumanEntity human: toInventory().getViewers()) {
for(HumanEntity human: new ArrayList<>(toInventory().getViewers())) {
human.closeInventory();
}
}