mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Merge pull request #457 from dpkirchner/master
Fix ConcurrentModificationException that occurred when reactor explodes.
This commit is contained in:
commit
96e8e33391
@ -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,8 +550,9 @@ 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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user