|
10 | 10 | import fr.maxlego08.menu.api.storage.Tables; |
11 | 11 | import fr.maxlego08.menu.api.storage.dto.DataDTO; |
12 | 12 | import fr.maxlego08.menu.api.storage.dto.InventoryDTO; |
13 | | -import fr.maxlego08.menu.api.utils.OfflinePlayerCache; |
14 | 13 | import fr.maxlego08.menu.storage.migrations.PlayerDataMigration; |
15 | 14 | import fr.maxlego08.menu.storage.migrations.PlayerInventoriesMigration; |
16 | 15 | import fr.maxlego08.menu.storage.migrations.PlayerOpenInventoryMigration; |
17 | 16 | import fr.maxlego08.menu.zcore.utils.GlobalDatabaseConfiguration; |
18 | 17 | import fr.maxlego08.menu.zcore.utils.TypeSafeCache; |
19 | | -import fr.maxlego08.sarah.DatabaseConfiguration; |
20 | | -import fr.maxlego08.sarah.DatabaseConnection; |
21 | | -import fr.maxlego08.sarah.HikariDatabaseConnection; |
22 | | -import fr.maxlego08.sarah.MigrationManager; |
23 | | -import fr.maxlego08.sarah.RequestHelper; |
24 | | -import fr.maxlego08.sarah.SchemaBuilder; |
25 | | -import fr.maxlego08.sarah.SqliteConnection; |
| 18 | +import fr.maxlego08.sarah.*; |
26 | 19 | import fr.maxlego08.sarah.database.DatabaseType; |
27 | 20 | import fr.maxlego08.sarah.database.Schema; |
28 | 21 | import fr.maxlego08.sarah.logger.JULogger; |
@@ -131,18 +124,20 @@ private void storeOpenInventories() { |
131 | 124 | var iterator = this.cache.get(PlayerOpenInventoryEvent.class).iterator(); |
132 | 125 | while (iterator.hasNext()) { |
133 | 126 | var event = iterator.next(); |
134 | | - schemas.add(SchemaBuilder.insert(Tables.PLAYER_OPEN_INVENTORIES, table -> { |
135 | | - table.uuid("player_id", event.getPlayer().getUniqueId()); |
136 | | - table.string("plugin", event.getInventory().getPlugin().getName()); |
137 | | - table.string("inventory", event.getInventory().getFileName()); |
138 | | - table.bigInt("page", event.getPage()); |
139 | | - table.string("old_inventories", |
140 | | - event.getOldInventories().stream() |
141 | | - .filter(Objects::nonNull) |
142 | | - .map(Inventory::getFileName) |
143 | | - .collect(Collectors.joining(",")) |
144 | | - ); |
145 | | - })); |
| 127 | + if (event != null) { |
| 128 | + schemas.add(SchemaBuilder.insert(Tables.PLAYER_OPEN_INVENTORIES, table -> { |
| 129 | + table.uuid("player_id", event.getPlayer().getUniqueId()); |
| 130 | + table.string("plugin", event.getInventory().getPlugin().getName()); |
| 131 | + table.string("inventory", event.getInventory().getFileName()); |
| 132 | + table.bigInt("page", event.getPage()); |
| 133 | + table.string("old_inventories", |
| 134 | + event.getOldInventories().stream() |
| 135 | + .filter(Objects::nonNull) |
| 136 | + .map(Inventory::getFileName) |
| 137 | + .collect(Collectors.joining(",")) |
| 138 | + ); |
| 139 | + })); |
| 140 | + } |
146 | 141 | iterator.remove(); |
147 | 142 | } |
148 | 143 | this.requestHelper.insertMultiple(schemas); |
|
0 commit comments