mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-21 19:34:42 +01:00
Run IntelliJ IDEA code formatter
This commit is contained in:
@@ -4,36 +4,36 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class EquipInventoryTab implements InventoryTab {
|
||||
private final Set<GameItem> items;
|
||||
private final int maxCapacity;
|
||||
|
||||
public EquipInventoryTab(int maxCapacity) {
|
||||
this.items = new HashSet<GameItem>();
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
private final Set<GameItem> items;
|
||||
private final int maxCapacity;
|
||||
|
||||
@Override
|
||||
public GameItem getItemById(int id) {
|
||||
return null;
|
||||
}
|
||||
public EquipInventoryTab(int maxCapacity) {
|
||||
this.items = new HashSet<GameItem>();
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddItem(GameItem item) {
|
||||
this.items.add(item);
|
||||
}
|
||||
@Override
|
||||
public GameItem getItemById(int id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveItem(GameItem item) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
@Override
|
||||
public void onAddItem(GameItem item) {
|
||||
this.items.add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return this.items.size();
|
||||
}
|
||||
@Override
|
||||
public void onRemoveItem(GameItem item) {
|
||||
this.items.remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCapacity() {
|
||||
return this.maxCapacity;
|
||||
}
|
||||
@Override
|
||||
public int getSize() {
|
||||
return this.items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCapacity() {
|
||||
return this.maxCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,46 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public enum EquipType {
|
||||
EQUIP_NONE (0),
|
||||
EQUIP_BRACER (1),
|
||||
EQUIP_NECKLACE (2),
|
||||
EQUIP_SHOES (3),
|
||||
EQUIP_RING (4),
|
||||
EQUIP_DRESS (5),
|
||||
EQUIP_WEAPON (6);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<EquipType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, EquipType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private EquipType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
EQUIP_NONE(0),
|
||||
EQUIP_BRACER(1),
|
||||
EQUIP_NECKLACE(2),
|
||||
EQUIP_SHOES(3),
|
||||
EQUIP_RING(4),
|
||||
EQUIP_DRESS(5),
|
||||
EQUIP_WEAPON(6);
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static EquipType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, EQUIP_NONE);
|
||||
}
|
||||
|
||||
public static EquipType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, EQUIP_NONE);
|
||||
}
|
||||
private static final Int2ObjectMap<EquipType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, EquipType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
EquipType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static EquipType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, EQUIP_NONE);
|
||||
}
|
||||
|
||||
public static EquipType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, EQUIP_NONE);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.morphia.annotations.PostLoad;
|
||||
import dev.morphia.annotations.Transient;
|
||||
|
||||
import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.GameDepot;
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
@@ -36,34 +24,72 @@ import emu.grasscutter.net.proto.WeaponOuterClass.Weapon;
|
||||
import emu.grasscutter.utils.WeightedList;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity(value = "items", useDiscriminator = false)
|
||||
public class GameItem {
|
||||
@Id private ObjectId id;
|
||||
@Indexed private int ownerId;
|
||||
@Getter @Setter private int itemId;
|
||||
@Getter @Setter private int count;
|
||||
@Id
|
||||
private ObjectId id;
|
||||
@Indexed
|
||||
private int ownerId;
|
||||
@Getter
|
||||
@Setter
|
||||
private int itemId;
|
||||
@Getter
|
||||
@Setter
|
||||
private int count;
|
||||
|
||||
@Transient @Getter private long guid; // Player unique id
|
||||
@Transient @Getter @Setter private ItemData itemData;
|
||||
@Transient
|
||||
@Getter
|
||||
private long guid; // Player unique id
|
||||
@Transient
|
||||
@Getter
|
||||
@Setter
|
||||
private ItemData itemData;
|
||||
|
||||
// Equips
|
||||
@Getter @Setter private int level;
|
||||
@Getter @Setter private int exp;
|
||||
@Getter @Setter private int totalExp;
|
||||
@Getter @Setter private int promoteLevel;
|
||||
@Getter @Setter private boolean locked;
|
||||
@Getter
|
||||
@Setter
|
||||
private int level;
|
||||
@Getter
|
||||
@Setter
|
||||
private int exp;
|
||||
@Getter
|
||||
@Setter
|
||||
private int totalExp;
|
||||
@Getter
|
||||
@Setter
|
||||
private int promoteLevel;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean locked;
|
||||
|
||||
// Weapon
|
||||
@Getter private List<Integer> affixes;
|
||||
@Getter @Setter private int refinement = 0;
|
||||
@Getter
|
||||
private List<Integer> affixes;
|
||||
@Getter
|
||||
@Setter
|
||||
private int refinement = 0;
|
||||
|
||||
// Relic
|
||||
@Getter @Setter private int mainPropId;
|
||||
@Getter private List<Integer> appendPropIdList;
|
||||
@Getter
|
||||
@Setter
|
||||
private int mainPropId;
|
||||
@Getter
|
||||
private List<Integer> appendPropIdList;
|
||||
|
||||
@Getter @Setter private int equipCharacter;
|
||||
@Transient @Getter @Setter private int weaponEntityId;
|
||||
@Getter
|
||||
@Setter
|
||||
private int equipCharacter;
|
||||
@Transient
|
||||
@Getter
|
||||
@Setter
|
||||
private int weaponEntityId;
|
||||
|
||||
public GameItem() {
|
||||
// Morphia only
|
||||
@@ -91,7 +117,7 @@ public class GameItem {
|
||||
|
||||
switch (data.getItemType()) {
|
||||
case ITEM_VIRTUAL:
|
||||
this.count = count;
|
||||
this.count = count;
|
||||
break;
|
||||
case ITEM_WEAPON:
|
||||
this.count = 1;
|
||||
@@ -122,23 +148,6 @@ public class GameItem {
|
||||
}
|
||||
}
|
||||
|
||||
public int getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public void setOwner(Player player) {
|
||||
this.ownerId = player.getUid();
|
||||
this.guid = player.getNextGameGuid();
|
||||
}
|
||||
|
||||
public ObjectId getObjectId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ItemType getItemType() {
|
||||
return this.itemData.getItemType();
|
||||
}
|
||||
|
||||
public static int getMinPromoteLevel(int level) {
|
||||
if (level > 80) {
|
||||
return 6;
|
||||
@@ -156,6 +165,23 @@ public class GameItem {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public void setOwner(Player player) {
|
||||
this.ownerId = player.getUid();
|
||||
this.guid = player.getNextGameGuid();
|
||||
}
|
||||
|
||||
public ObjectId getObjectId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ItemType getItemType() {
|
||||
return this.itemData.getItemType();
|
||||
}
|
||||
|
||||
public int getEquipSlot() {
|
||||
return this.getItemData().getEquipType().getValue();
|
||||
}
|
||||
@@ -270,28 +296,28 @@ public class GameItem {
|
||||
|
||||
public SceneWeaponInfo createSceneWeaponInfo() {
|
||||
SceneWeaponInfo.Builder weaponInfo = SceneWeaponInfo.newBuilder()
|
||||
.setEntityId(this.getWeaponEntityId())
|
||||
.setItemId(this.getItemId())
|
||||
.setGuid(this.getGuid())
|
||||
.setLevel(this.getLevel())
|
||||
.setGadgetId(this.getItemData().getGadgetId())
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0));
|
||||
.setEntityId(this.getWeaponEntityId())
|
||||
.setItemId(this.getItemId())
|
||||
.setGuid(this.getGuid())
|
||||
.setLevel(this.getLevel())
|
||||
.setGadgetId(this.getItemData().getGadgetId())
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0));
|
||||
|
||||
if (this.getAffixes() != null && this.getAffixes().size() > 0) {
|
||||
for (int affix : this.getAffixes()) {
|
||||
weaponInfo.putAffixMap(affix, this.getRefinement());
|
||||
}
|
||||
}
|
||||
if (this.getAffixes() != null && this.getAffixes().size() > 0) {
|
||||
for (int affix : this.getAffixes()) {
|
||||
weaponInfo.putAffixMap(affix, this.getRefinement());
|
||||
}
|
||||
}
|
||||
|
||||
return weaponInfo.build();
|
||||
}
|
||||
|
||||
public SceneReliquaryInfo createSceneReliquaryInfo() {
|
||||
SceneReliquaryInfo relicInfo = SceneReliquaryInfo.newBuilder()
|
||||
.setItemId(this.getItemId())
|
||||
.setGuid(this.getGuid())
|
||||
.setLevel(this.getLevel())
|
||||
.build();
|
||||
.setItemId(this.getItemId())
|
||||
.setGuid(this.getGuid())
|
||||
.setLevel(this.getLevel())
|
||||
.build();
|
||||
|
||||
return relicInfo;
|
||||
}
|
||||
@@ -324,8 +350,8 @@ public class GameItem {
|
||||
|
||||
public Item toProto() {
|
||||
Item.Builder proto = Item.newBuilder()
|
||||
.setGuid(this.getGuid())
|
||||
.setItemId(this.getItemId());
|
||||
.setGuid(this.getGuid())
|
||||
.setItemId(this.getItemId());
|
||||
|
||||
switch (getItemType()) {
|
||||
case ITEM_WEAPON:
|
||||
|
||||
@@ -214,7 +214,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
case MATERIAL_FLYCLOAK:
|
||||
case MATERIAL_COSTUME:
|
||||
case MATERIAL_NAMECARD:
|
||||
Grasscutter.getLogger().warn("Attempted to add a "+item.getItemData().getMaterialType().name()+" to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.");
|
||||
Grasscutter.getLogger().warn("Attempted to add a " + item.getItemData().getMaterialType().name() + " to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.");
|
||||
return null;
|
||||
default:
|
||||
if (tab == null) {
|
||||
@@ -236,7 +236,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
existingItem.save();
|
||||
return existingItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
public interface InventoryTab {
|
||||
public GameItem getItemById(int id);
|
||||
|
||||
public void onAddItem(GameItem item);
|
||||
|
||||
public void onRemoveItem(GameItem item);
|
||||
|
||||
public int getSize();
|
||||
|
||||
public int getMaxCapacity();
|
||||
GameItem getItemById(int id);
|
||||
|
||||
void onAddItem(GameItem item);
|
||||
|
||||
void onRemoveItem(GameItem item);
|
||||
|
||||
int getSize();
|
||||
|
||||
int getMaxCapacity();
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
public class ItemDef {
|
||||
private int itemId;
|
||||
private int count;
|
||||
|
||||
public ItemDef(int itemId, int count) {
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(int itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
private int itemId;
|
||||
private int count;
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
public ItemDef(int itemId, int count) {
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(int itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,46 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public enum ItemQuality {
|
||||
QUALITY_NONE(0),
|
||||
QUALITY_WHITE(1),
|
||||
QUALITY_GREEN(2),
|
||||
QUALITY_BLUE(3),
|
||||
QUALITY_PURPLE(4),
|
||||
QUALITY_ORANGE(5),
|
||||
QUALITY_ORANGE_SP(105);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemQuality> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ItemQuality> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemQuality(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
QUALITY_NONE(0),
|
||||
QUALITY_WHITE(1),
|
||||
QUALITY_GREEN(2),
|
||||
QUALITY_BLUE(3),
|
||||
QUALITY_PURPLE(4),
|
||||
QUALITY_ORANGE(5),
|
||||
QUALITY_ORANGE_SP(105);
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemQuality getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, QUALITY_NONE);
|
||||
}
|
||||
|
||||
public static ItemQuality getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, QUALITY_NONE);
|
||||
}
|
||||
private static final Int2ObjectMap<ItemQuality> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ItemQuality> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
ItemQuality(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ItemQuality getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, QUALITY_NONE);
|
||||
}
|
||||
|
||||
public static ItemQuality getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, QUALITY_NONE);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,46 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public enum ItemType {
|
||||
ITEM_NONE (0),
|
||||
ITEM_VIRTUAL (1),
|
||||
ITEM_MATERIAL (2),
|
||||
ITEM_RELIQUARY (3),
|
||||
ITEM_WEAPON (4),
|
||||
ITEM_DISPLAY (5),
|
||||
ITEM_FURNITURE (6);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ItemType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
ITEM_NONE(0),
|
||||
ITEM_VIRTUAL(1),
|
||||
ITEM_MATERIAL(2),
|
||||
ITEM_RELIQUARY(3),
|
||||
ITEM_WEAPON(4),
|
||||
ITEM_DISPLAY(5),
|
||||
ITEM_FURNITURE(6);
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_NONE);
|
||||
}
|
||||
|
||||
public static ItemType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, ITEM_NONE);
|
||||
}
|
||||
private static final Int2ObjectMap<ItemType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ItemType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private final int value;
|
||||
|
||||
ItemType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ItemType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_NONE);
|
||||
}
|
||||
|
||||
public static ItemType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, ITEM_NONE);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,36 +4,36 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class MaterialInventoryTab implements InventoryTab {
|
||||
private final Int2ObjectMap<GameItem> items;
|
||||
private final int maxCapacity;
|
||||
|
||||
public MaterialInventoryTab(int maxCapacity) {
|
||||
this.items = new Int2ObjectOpenHashMap<>();
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameItem getItemById(int id) {
|
||||
return this.items.get(id);
|
||||
}
|
||||
private final Int2ObjectMap<GameItem> items;
|
||||
private final int maxCapacity;
|
||||
|
||||
@Override
|
||||
public void onAddItem(GameItem item) {
|
||||
this.items.put(item.getItemId(), item);
|
||||
}
|
||||
public MaterialInventoryTab(int maxCapacity) {
|
||||
this.items = new Int2ObjectOpenHashMap<>();
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveItem(GameItem item) {
|
||||
this.items.remove(item.getItemId());
|
||||
}
|
||||
@Override
|
||||
public GameItem getItemById(int id) {
|
||||
return this.items.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return this.items.size();
|
||||
}
|
||||
@Override
|
||||
public void onAddItem(GameItem item) {
|
||||
this.items.put(item.getItemId(), item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCapacity() {
|
||||
return this.maxCapacity;
|
||||
}
|
||||
@Override
|
||||
public void onRemoveItem(GameItem item) {
|
||||
this.items.remove(item.getItemId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return this.items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCapacity() {
|
||||
return this.maxCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +1,55 @@
|
||||
package emu.grasscutter.game.inventory;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public enum MaterialType {
|
||||
MATERIAL_NONE (0),
|
||||
MATERIAL_FOOD (1),
|
||||
MATERIAL_QUEST (2),
|
||||
MATERIAL_EXCHANGE (4),
|
||||
MATERIAL_CONSUME (5),
|
||||
MATERIAL_EXP_FRUIT (6),
|
||||
MATERIAL_AVATAR (7),
|
||||
MATERIAL_ADSORBATE (8),
|
||||
MATERIAL_CRICKET (9),
|
||||
MATERIAL_ELEM_CRYSTAL (10),
|
||||
MATERIAL_WEAPON_EXP_STONE (11),
|
||||
MATERIAL_CHEST (12),
|
||||
MATERIAL_RELIQUARY_MATERIAL (13),
|
||||
MATERIAL_AVATAR_MATERIAL (14),
|
||||
MATERIAL_NOTICE_ADD_HP (15),
|
||||
MATERIAL_SEA_LAMP (16),
|
||||
MATERIAL_SELECTABLE_CHEST (17),
|
||||
MATERIAL_FLYCLOAK (18),
|
||||
MATERIAL_NAMECARD (19),
|
||||
MATERIAL_TALENT (20),
|
||||
MATERIAL_WIDGET (21),
|
||||
MATERIAL_CHEST_BATCH_USE (22),
|
||||
MATERIAL_FAKE_ABSORBATE (23),
|
||||
MATERIAL_CONSUME_BATCH_USE (24),
|
||||
MATERIAL_WOOD (25),
|
||||
MATERIAL_FURNITURE_FORMULA (27),
|
||||
MATERIAL_CHANNELLER_SLAB_BUFF (28),
|
||||
MATERIAL_FURNITURE_SUITE_FORMULA (29),
|
||||
MATERIAL_COSTUME (30),
|
||||
MATERIAL_HOME_SEED (31),
|
||||
MATERIAL_FISH_BAIT (32),
|
||||
MATERIAL_FISH_ROD (33),
|
||||
MATERIAL_SUMO_BUFF (34),
|
||||
MATERIAL_FIREWORKS (35),
|
||||
MATERIAL_BGM (36),
|
||||
MATERIAL_SPICE_FOOD (37),
|
||||
MATERIAL_ACTIVITY_ROBOT (38),
|
||||
MATERIAL_ACTIVITY_GEAR (39),
|
||||
MATERIAL_ACTIVITY_JIGSAW (40),
|
||||
MATERIAL_ARANARA (41),
|
||||
MATERIAL_DESHRET_MANUAL (46);
|
||||
MATERIAL_NONE(0),
|
||||
MATERIAL_FOOD(1),
|
||||
MATERIAL_QUEST(2),
|
||||
MATERIAL_EXCHANGE(4),
|
||||
MATERIAL_CONSUME(5),
|
||||
MATERIAL_EXP_FRUIT(6),
|
||||
MATERIAL_AVATAR(7),
|
||||
MATERIAL_ADSORBATE(8),
|
||||
MATERIAL_CRICKET(9),
|
||||
MATERIAL_ELEM_CRYSTAL(10),
|
||||
MATERIAL_WEAPON_EXP_STONE(11),
|
||||
MATERIAL_CHEST(12),
|
||||
MATERIAL_RELIQUARY_MATERIAL(13),
|
||||
MATERIAL_AVATAR_MATERIAL(14),
|
||||
MATERIAL_NOTICE_ADD_HP(15),
|
||||
MATERIAL_SEA_LAMP(16),
|
||||
MATERIAL_SELECTABLE_CHEST(17),
|
||||
MATERIAL_FLYCLOAK(18),
|
||||
MATERIAL_NAMECARD(19),
|
||||
MATERIAL_TALENT(20),
|
||||
MATERIAL_WIDGET(21),
|
||||
MATERIAL_CHEST_BATCH_USE(22),
|
||||
MATERIAL_FAKE_ABSORBATE(23),
|
||||
MATERIAL_CONSUME_BATCH_USE(24),
|
||||
MATERIAL_WOOD(25),
|
||||
MATERIAL_FURNITURE_FORMULA(27),
|
||||
MATERIAL_CHANNELLER_SLAB_BUFF(28),
|
||||
MATERIAL_FURNITURE_SUITE_FORMULA(29),
|
||||
MATERIAL_COSTUME(30),
|
||||
MATERIAL_HOME_SEED(31),
|
||||
MATERIAL_FISH_BAIT(32),
|
||||
MATERIAL_FISH_ROD(33),
|
||||
MATERIAL_SUMO_BUFF(34),
|
||||
MATERIAL_FIREWORKS(35),
|
||||
MATERIAL_BGM(36),
|
||||
MATERIAL_SPICE_FOOD(37),
|
||||
MATERIAL_ACTIVITY_ROBOT(38),
|
||||
MATERIAL_ACTIVITY_GEAR(39),
|
||||
MATERIAL_ACTIVITY_JIGSAW(40),
|
||||
MATERIAL_ARANARA(41),
|
||||
MATERIAL_DESHRET_MANUAL(46);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, MaterialType> stringMap = new HashMap<>();
|
||||
|
||||
@@ -61,12 +60,10 @@ public enum MaterialType {
|
||||
});
|
||||
}
|
||||
|
||||
private MaterialType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
private final int value;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
MaterialType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByValue(int value) {
|
||||
@@ -76,4 +73,8 @@ public enum MaterialType {
|
||||
public static MaterialType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, MATERIAL_NONE);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user