mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-23 11:22:55 +08:00
Add PlayerForgeItemEvent
This commit is contained in:
parent
9b84deaab3
commit
40887b17fe
@ -14,6 +14,7 @@ import emu.grasscutter.net.proto.ForgeQueueManipulateReqOuterClass.ForgeQueueMan
|
|||||||
import emu.grasscutter.net.proto.ForgeQueueManipulateTypeOuterClass.ForgeQueueManipulateType;
|
import emu.grasscutter.net.proto.ForgeQueueManipulateTypeOuterClass.ForgeQueueManipulateType;
|
||||||
import emu.grasscutter.net.proto.ForgeStartReqOuterClass.ForgeStartReq;
|
import emu.grasscutter.net.proto.ForgeStartReqOuterClass.ForgeStartReq;
|
||||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
|
import emu.grasscutter.server.event.player.PlayerForgeItemEvent;
|
||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -21,7 +22,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ForgingManager extends BasePlayerManager {
|
public final class ForgingManager extends BasePlayerManager {
|
||||||
|
|
||||||
public ForgingManager(Player player) {
|
public ForgingManager(Player player) {
|
||||||
super(player);
|
super(player);
|
||||||
@ -186,6 +187,12 @@ public class ForgingManager extends BasePlayerManager {
|
|||||||
int resultId = data.getResultItemId() > 0 ? data.getResultItemId() : data.getShowItemId();
|
int resultId = data.getResultItemId() > 0 ? data.getResultItemId() : data.getShowItemId();
|
||||||
ItemData resultItemData = GameData.getItemDataMap().get(resultId);
|
ItemData resultItemData = GameData.getItemDataMap().get(resultId);
|
||||||
GameItem addItem = new GameItem(resultItemData, data.getResultItemCount() * finished);
|
GameItem addItem = new GameItem(resultItemData, data.getResultItemCount() * finished);
|
||||||
|
|
||||||
|
// Call the PlayerForgeItemEvent.
|
||||||
|
var event = new PlayerForgeItemEvent(this.player, addItem);
|
||||||
|
if (!event.call()) return;
|
||||||
|
|
||||||
|
addItem = event.getItemForged();
|
||||||
this.player.getInventory().addItem(addItem);
|
this.player.getInventory().addItem(addItem);
|
||||||
|
|
||||||
// Battle pass trigger handler
|
// Battle pass trigger handler
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
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.*;
|
||||||
|
|
||||||
|
public final class PlayerForgeItemEvent extends PlayerEvent {
|
||||||
|
@Getter @Setter private GameItem itemForged;
|
||||||
|
|
||||||
|
public PlayerForgeItemEvent(Player player, GameItem itemForged) {
|
||||||
|
super(player);
|
||||||
|
|
||||||
|
this.itemForged = itemForged;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user