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; package emu.grasscutter.game.inventory;
import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.ItemParamData; 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.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Getter;
import lombok.val;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS; import lombok.Getter;
import lombok.val;
public class Inventory extends BasePlayerManager implements Iterable<GameItem> { public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
private final Long2ObjectMap<GameItem> store; private final Long2ObjectMap<GameItem> store;
@Getter @Getter private final Int2ObjectMap<InventoryTab> inventoryTypes;
private final Int2ObjectMap<InventoryTab> inventoryTypes;
public Inventory(Player player) { public Inventory(Player player) {
super(player); super(player);
@ -87,8 +85,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
return this.getItems().get(id); return this.getItems().get(id);
} }
@Nullable @Nullable public InventoryTab getInventoryTabByItemId(int itemId) {
public InventoryTab getInventoryTabByItemId(int itemId) {
val itemData = GameData.getItemDataMap().get(itemId); val itemData = GameData.getItemDataMap().get(itemId);
if (itemData == null || itemData.getItemType() == null) { if (itemData == null || itemData.getItemType() == null) {
return null; return null;
@ -96,8 +93,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
return getInventoryTab(itemData.getItemType()); return getInventoryTab(itemData.getItemType());
} }
@Nullable @Nullable public GameItem getItemById(int itemId) {
public GameItem getItemById(int itemId) {
val inventoryTab = this.getInventoryTabByItemId(itemId); val inventoryTab = this.getInventoryTabByItemId(itemId);
return inventoryTab != null ? inventoryTab.getItemById(itemId) : null; return inventoryTab != null ? inventoryTab.getItemById(itemId) : null;
} }
@ -332,7 +328,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
case MATERIAL_COSTUME: case MATERIAL_COSTUME:
case MATERIAL_NAMECARD: case MATERIAL_NAMECARD:
Grasscutter.getLogger() 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; return null;
default: default:
if (tab == null) { if (tab == null) {
@ -455,7 +453,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
GameItem item = GameItem item =
getInventoryTab(ItemType.ITEM_MATERIAL) getInventoryTab(ItemType.ITEM_MATERIAL)
.getItemById( .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(); yield (item == null) ? 0 : item.getCount();
} }
}; };

View File

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