mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-18 08:15:05 +01:00
Fix null pointer exception that occurs when certain items are added
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user