Skip to content

Commit

Permalink
clean(storage): replace deprecated method/constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Siroshun09 committed Aug 24, 2023
1 parent 54b355c commit 66af4e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import net.okocraft.box.api.model.stock.UserStockHolder;
import net.okocraft.box.api.model.user.BoxUser;
import net.okocraft.box.storage.api.factory.stock.UserStockHolderFactory;
import net.okocraft.box.storage.api.holder.LoggerHolder;
import net.okocraft.box.storage.api.model.stock.StockStorage;
import net.okocraft.box.storage.api.util.item.BoxItemSupplier;
import net.okocraft.box.storage.implementation.database.database.Database;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -41,12 +39,8 @@ public void init() throws Exception {
int itemId = resultSet.getInt("item_id");
int amount = resultSet.getInt("amount");

var item = BoxItemSupplier.getItem(itemId);

if (item.isPresent()) {
stock.add(new StockData(item.get(), amount));
} else {
LoggerHolder.get().warning("Unknown item id: " + itemId + " (" + strUuid + ")");
if (amount != 0) {
stock.add(new StockData(itemId, amount));
}
}
}
Expand Down Expand Up @@ -81,7 +75,7 @@ private void insertUserData(@NotNull Connection connection, @NotNull BoxUser use
}

statement.setString(1, strUuid);
statement.setInt(2, data.item().getInternalId());
statement.setInt(2, data.itemInternalId());
statement.setInt(3, data.amount());
statement.addBatch();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.okocraft.box.storage.api.factory.stock.UserStockHolderFactory;
import net.okocraft.box.storage.api.holder.LoggerHolder;
import net.okocraft.box.storage.api.model.stock.StockStorage;
import net.okocraft.box.storage.api.util.item.BoxItemSupplier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -83,7 +82,7 @@ public void saveUserStockHolder(@NotNull UserStockHolder stockHolder) throws Exc
for (var stock : stockHolder.toStockDataCollection()) {
if (0 != stock.amount()) {
builder.append('\'')
.append(stock.item().getInternalId())
.append(stock.itemInternalId())
.append('\'')
.append(':')
.append(' ')
Expand Down Expand Up @@ -112,13 +111,6 @@ public void saveUserStockHolder(@NotNull UserStockHolder stockHolder) throws Exc
return null;
}

var item = BoxItemSupplier.getItem(itemId);

if (item.isEmpty()) {
LoggerHolder.get().warning("Unknown id: " + itemId + " (" + uuid + ")");
return null;
}

int amount;

try {
Expand All @@ -128,6 +120,6 @@ public void saveUserStockHolder(@NotNull UserStockHolder stockHolder) throws Exc
return null;
}

return new StockData(item.get(), amount);
return new StockData(itemId, amount);
}
}

0 comments on commit 66af4e5

Please sign in to comment.