Fix null pointer exception that occurs when certain items are added

This commit is contained in:
Melledy
2023-12-05 22:09:08 -08:00
parent d82cfd4586
commit 4a291cb936
3 changed files with 9 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ public enum ItemMainType {
private InventoryTabType tabType; private InventoryTabType tabType;
private ItemMainType(int value) { private ItemMainType(int value) {
this.val = value; this(value, InventoryTabType.NONE);
} }
private ItemMainType(int value, InventoryTabType tabType) { private ItemMainType(int value, InventoryTabType tabType) {

View File

@@ -62,7 +62,10 @@ public class Inventory extends BasePlayerManager {
} }
public InventoryTab getTab(InventoryTabType type) { public InventoryTab getTab(InventoryTabType type) {
if (type == null) return null; if (type == null || type == InventoryTabType.NONE) {
return null;
}
return this.inventoryTypes.get(type.getVal()); return this.inventoryTypes.get(type.getVal());
} }

View File

@@ -103,6 +103,9 @@ public class PacketPlayerSyncScNotify extends BasePacket {
private void addItemToProto(PlayerSyncScNotify data, GameItem item) { private void addItemToProto(PlayerSyncScNotify data, GameItem item) {
switch (item.getExcel().getItemMainType().getTabType()) { switch (item.getExcel().getItemMainType().getTabType()) {
case MATERIAL -> {
data.addMaterialList(item.toMaterialProto());
}
case RELIC -> { case RELIC -> {
if (item.getCount() > 0) { if (item.getCount() > 0) {
data.addRelicList(item.toRelicProto()); data.addRelicList(item.toRelicProto());
@@ -118,7 +121,7 @@ public class PacketPlayerSyncScNotify extends BasePacket {
} }
} }
default -> { default -> {
data.addMaterialList(item.toMaterialProto()); // Skip
} }
} }
} }