mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 18:12:52 +08:00
Format code [skip actions]
This commit is contained in:
parent
c80e0f0572
commit
87ffbdd0f1
@ -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;
|
||||||
@ -20,14 +22,11 @@ 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 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 static emu.grasscutter.config.Configuration.INVENTORY_LIMITS;
|
|
||||||
|
|
||||||
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;
|
||||||
private final Int2ObjectMap<InventoryTab> inventoryTypes;
|
private final Int2ObjectMap<InventoryTab> inventoryTypes;
|
||||||
@ -455,14 +454,10 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
|||||||
* @return True if the item was removed, false otherwise.
|
* @return True if the item was removed, false otherwise.
|
||||||
*/
|
*/
|
||||||
public synchronized boolean removeItemById(int itemId, int count) {
|
public synchronized boolean removeItemById(int itemId, int count) {
|
||||||
var item = this.getItems().values().stream()
|
var item = this.getItems().values().stream().filter(i -> i.getItemId() == itemId).findFirst();
|
||||||
.filter(i -> i.getItemId() == itemId)
|
|
||||||
.findFirst();
|
|
||||||
|
|
||||||
// Check if the item is in the player's inventory.
|
// Check if the item is in the player's inventory.
|
||||||
return item.filter(
|
return item.filter(gameItem -> this.removeItem(gameItem, count)).isPresent();
|
||||||
gameItem -> this.removeItem(gameItem, count)
|
|
||||||
).isPresent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean removeItem(GameItem item) {
|
public synchronized boolean removeItem(GameItem item) {
|
||||||
|
@ -26,10 +26,9 @@ import emu.grasscutter.server.game.GameServer;
|
|||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.*;
|
import it.unimi.dsi.fastutil.ints.*;
|
||||||
import lombok.val;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import lombok.val;
|
||||||
|
|
||||||
public class InventorySystem extends BaseGameSystem {
|
public class InventorySystem extends BaseGameSystem {
|
||||||
private static final Int2IntMap weaponRefundMaterials = new Int2IntArrayMap();
|
private static final Int2IntMap weaponRefundMaterials = new Int2IntArrayMap();
|
||||||
|
@ -41,15 +41,14 @@ import emu.grasscutter.server.packet.send.*;
|
|||||||
import emu.grasscutter.utils.KahnsSort;
|
import emu.grasscutter.utils.KahnsSort;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.val;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.val;
|
||||||
|
|
||||||
public final class Scene {
|
public final class Scene {
|
||||||
@Getter private final World world;
|
@Getter private final World world;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.game.world;
|
package emu.grasscutter.game.world;
|
||||||
|
|
||||||
|
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||||
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
@ -22,17 +24,14 @@ import emu.grasscutter.utils.Position;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.val;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.Getter;
|
||||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
import lombok.val;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class World implements Iterable<Player> {
|
public final class World implements Iterable<Player> {
|
||||||
@Getter private final GameServer server;
|
@Getter private final GameServer server;
|
||||||
@ -533,14 +532,10 @@ public final class World implements Iterable<Player> {
|
|||||||
player -> player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_GAME_TIME_TICK));
|
player -> player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_GAME_TIME_TICK));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Notifies all players of the current world time. */
|
||||||
* Notifies all players of the current world time.
|
|
||||||
*/
|
|
||||||
public void updateTime() {
|
public void updateTime() {
|
||||||
this.getPlayers().forEach(p ->
|
this.getPlayers().forEach(p -> p.sendPacket(new PacketPlayerGameTimeNotify(p)));
|
||||||
p.sendPacket(new PacketPlayerGameTimeNotify(p)));
|
this.getPlayers().forEach(p -> p.sendPacket(new PacketSceneTimeNotify(p)));
|
||||||
this.getPlayers().forEach(p ->
|
|
||||||
p.sendPacket(new PacketSceneTimeNotify(p)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -557,8 +552,7 @@ public final class World implements Iterable<Player> {
|
|||||||
.forEach(player -> player.setProperty(PlayerProperty.PROP_IS_GAME_TIME_LOCKED, locked));
|
.forEach(player -> player.setProperty(PlayerProperty.PROP_IS_GAME_TIME_LOCKED, locked));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull @Override
|
||||||
@Override
|
|
||||||
public Iterator<Player> iterator() {
|
public Iterator<Player> iterator() {
|
||||||
return this.getPlayers().iterator();
|
return this.getPlayers().iterator();
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ public class PacketPlayerSetPauseRsp extends BasePacket {
|
|||||||
public PacketPlayerSetPauseRsp(Retcode retcode) {
|
public PacketPlayerSetPauseRsp(Retcode retcode) {
|
||||||
super(PacketOpcodes.PlayerSetPauseRsp);
|
super(PacketOpcodes.PlayerSetPauseRsp);
|
||||||
|
|
||||||
this.setData(PlayerSetPauseRsp.newBuilder()
|
this.setData(PlayerSetPauseRsp.newBuilder().setRetcode(retcode.getNumber()));
|
||||||
.setRetcode(retcode.getNumber()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user