Format code [skip actions]

This commit is contained in:
github-actions 2024-06-09 15:12:09 +00:00
parent bfc2c7c096
commit 2bb2da44bc
2 changed files with 90 additions and 97 deletions

View File

@ -1,5 +1,7 @@
package emu.grasscutter.game.inventory;
import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.ItemParamData;
@ -23,21 +25,17 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Getter;
import lombok.val;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.val;
public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
private final Long2ObjectMap<GameItem> store;
@Getter
private final Int2ObjectMap<InventoryTab> inventoryTypes;
@Getter private final Int2ObjectMap<InventoryTab> inventoryTypes;
public Inventory(Player player) {
super(player);
@ -87,8 +85,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
return this.getItems().get(id);
}
@Nullable
public InventoryTab getInventoryTabByItemId(int itemId) {
@Nullable public InventoryTab getInventoryTabByItemId(int itemId) {
val itemData = GameData.getItemDataMap().get(itemId);
if (itemData == null || itemData.getItemType() == null) {
return null;
@ -96,8 +93,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
return getInventoryTab(itemData.getItemType());
}
@Nullable
public GameItem getItemById(int itemId) {
@Nullable public GameItem getItemById(int itemId) {
val inventoryTab = this.getInventoryTabByItemId(itemId);
return inventoryTab != null ? inventoryTab.getItemById(itemId) : null;
}
@ -332,7 +328,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
case MATERIAL_COSTUME:
case MATERIAL_NAMECARD:
Grasscutter.getLogger()
.warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name());
.warn(
"Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.",
item.getItemData().getMaterialType().name());
return null;
default:
if (tab == null) {
@ -455,7 +453,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
GameItem item =
getInventoryTab(ItemType.ITEM_MATERIAL)
.getItemById(
itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S
itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield
// (item == null) ? 0 : item.getCount(); // What if we ever want to
// operate on weapons/relics/furniture? :S
yield (item == null) ? 0 : item.getCount();
}
};

View File

@ -2,27 +2,20 @@ package emu.grasscutter.net.packet;
import com.google.protobuf.GeneratedMessageV3;
import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead;
import java.io.*;
import lombok.Getter;
import lombok.Setter;
import java.io.*;
public class BasePacket {
private static final int const1 = 17767; // 0x4567
private static final int const2 = -30293; // 0x89ab
public final boolean shouldEncrypt = true;
@Setter
@Getter
private int opcode;
@Setter @Getter private int opcode;
private boolean shouldBuildHeader = false;
@Setter
@Getter
private byte[] header;
@Getter
private byte[] data;
@Setter @Getter private byte[] header;
@Getter private byte[] data;
// Encryption
@Setter
private boolean useDispatchKey;
@Setter private boolean useDispatchKey;
public BasePacket(int opcode) {
this.opcode = opcode;