@@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>openinvparent</artifactId>
|
||||
<groupId>com.lishid</groupId>
|
||||
<version>4.3.2-SNAPSHOT</version>
|
||||
<version>4.4.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>openinvplugincore</artifactId>
|
||||
|
@@ -63,11 +63,11 @@ record InventoryListener(OpenInv plugin) implements Listener {
|
||||
|
||||
ISpecialInventory specialInventory = InventoryAccess.getEnderChest(event.getInventory());
|
||||
if (specialInventory != null) {
|
||||
this.plugin.handleCloseInventory(event.getPlayer(), specialInventory);
|
||||
this.plugin.handleCloseInventory(specialInventory);
|
||||
} else {
|
||||
specialInventory = InventoryAccess.getPlayerInventory(event.getInventory());
|
||||
if (specialInventory != null) {
|
||||
this.plugin.handleCloseInventory(event.getPlayer(), specialInventory);
|
||||
this.plugin.handleCloseInventory(specialInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import com.lishid.openinv.commands.OpenInvCommand;
|
||||
import com.lishid.openinv.commands.SearchContainerCommand;
|
||||
import com.lishid.openinv.commands.SearchEnchantCommand;
|
||||
import com.lishid.openinv.commands.SearchInvCommand;
|
||||
import com.lishid.openinv.event.OpenPlayerSaveEvent;
|
||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||
import com.lishid.openinv.internal.ISpecialInventory;
|
||||
@@ -544,7 +545,7 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
|
||||
}
|
||||
}
|
||||
|
||||
void handleCloseInventory(@NotNull HumanEntity exViewer, @NotNull ISpecialInventory inventory) {
|
||||
void handleCloseInventory(@NotNull ISpecialInventory inventory) {
|
||||
Map<UUID, ? extends ISpecialInventory> map = inventory instanceof ISpecialPlayerInventory ? inventories : enderChests;
|
||||
UUID key = inventory.getPlayer().getUniqueId();
|
||||
@Nullable ISpecialInventory loaded = map.get(key);
|
||||
@@ -576,11 +577,18 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
|
||||
// Re-fetch from map - prevents duplicate saves on multi-close.
|
||||
ISpecialInventory current = map.remove(key);
|
||||
|
||||
if (!disableSaving()
|
||||
&& current != null
|
||||
&& current.getPlayer() instanceof Player player
|
||||
&& !player.isOnline()) {
|
||||
this.accessor.getPlayerDataManager().inject(player).saveData();
|
||||
if (disableSaving()
|
||||
|| current == null
|
||||
|| !(current.getPlayer() instanceof Player player)
|
||||
|| player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
OpenPlayerSaveEvent event = new OpenPlayerSaveEvent(player, current);
|
||||
getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
this.accessor.getPlayerDataManager().inject(player).saveData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user