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:
commit
b44cce7a5e
@ -339,7 +339,7 @@ public class BlockStorage {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static String serializeBlockInfo(Config cfg) {
|
private static String serializeBlockInfo(Config cfg) {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
for (String key: cfg.getKeys()) {
|
for (String key : cfg.getKeys()) {
|
||||||
json.put(key, cfg.getString(key));
|
json.put(key, cfg.getString(key));
|
||||||
}
|
}
|
||||||
return json.toJSONString();
|
return json.toJSONString();
|
||||||
@ -596,8 +596,11 @@ public class BlockStorage {
|
|||||||
public void clearInventory(Location l) {
|
public void clearInventory(Location l) {
|
||||||
BlockMenu menu = getInventory(l);
|
BlockMenu menu = getInventory(l);
|
||||||
|
|
||||||
for (HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) {
|
for (HumanEntity human : new ArrayList<>(menu.toInventory().getViewers())) {
|
||||||
human.closeInventory();
|
// 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);
|
inventories.get(l).delete(l);
|
||||||
|
Loading…
Reference in New Issue
Block a user