mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 20:56:28 +00:00
Add PlayerObtainItemEvent
This commit is contained in:
parent
9c8a29c864
commit
0ad8eb443b
@ -1,7 +1,5 @@
|
||||
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;
|
||||
@ -13,14 +11,18 @@ import emu.grasscutter.game.props.*;
|
||||
import emu.grasscutter.game.props.ItemUseAction.UseItemParams;
|
||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
||||
import emu.grasscutter.server.event.player.PlayerObtainItemEvent;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import it.unimi.dsi.fastutil.longs.*;
|
||||
import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.val;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS;
|
||||
|
||||
public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
private final Long2ObjectMap<GameItem> store;
|
||||
private final Int2ObjectMap<InventoryTab> inventoryTypes;
|
||||
@ -121,6 +123,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
if (result != null) {
|
||||
this.triggerAddItemEvents(result);
|
||||
getPlayer().sendPacket(new PacketStoreItemChangeNotify(result));
|
||||
|
||||
// Call PlayerObtainItemEvent.
|
||||
new PlayerObtainItemEvent(this.getPlayer(), item).call();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package emu.grasscutter.server.event.player;
|
||||
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.event.types.PlayerEvent;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public final class PlayerObtainItemEvent extends PlayerEvent {
|
||||
private final GameItem item;
|
||||
|
||||
public PlayerObtainItemEvent(Player player, GameItem item) {
|
||||
super(player);
|
||||
|
||||
this.item = item;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user