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

Merge pull request #874 from SoSeDiK/AEA

Prevent "Asynchronous entity add!"
This commit is contained in:
TheBusyBiscuit 2019-03-30 11:29:26 +01:00 committed by GitHub
commit b44cce7a5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -339,7 +339,7 @@ public class BlockStorage {
@SuppressWarnings("unchecked")
private static String serializeBlockInfo(Config cfg) {
JSONObject json = new JSONObject();
for (String key: cfg.getKeys()) {
for (String key : cfg.getKeys()) {
json.put(key, cfg.getString(key));
}
return json.toJSONString();
@ -596,8 +596,11 @@ public class BlockStorage {
public void clearInventory(Location l) {
BlockMenu menu = getInventory(l);
for (HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) {
human.closeInventory();
for (HumanEntity human : new ArrayList<>(menu.toInventory().getViewers())) {
// Prevents "java.lang.IllegalStateException: Asynchronous entity add!" when closing inventory while holding an item
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> {
human.closeInventory();
});
}
inventories.get(l).delete(l);