Add PlayerForgeItemEvent

This commit is contained in:
KingRainbow44 2023-08-27 23:22:35 -04:00
parent 9b84deaab3
commit 40887b17fe
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 24 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import emu.grasscutter.net.proto.ForgeQueueManipulateReqOuterClass.ForgeQueueMan
import emu.grasscutter.net.proto.ForgeQueueManipulateTypeOuterClass.ForgeQueueManipulateType;
import emu.grasscutter.net.proto.ForgeStartReqOuterClass.ForgeStartReq;
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
import emu.grasscutter.server.event.player.PlayerForgeItemEvent;
import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.Utils;
import java.util.ArrayList;
@ -21,7 +22,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ForgingManager extends BasePlayerManager {
public final class ForgingManager extends BasePlayerManager {
public ForgingManager(Player player) {
super(player);
@ -186,6 +187,12 @@ public class ForgingManager extends BasePlayerManager {
int resultId = data.getResultItemId() > 0 ? data.getResultItemId() : data.getShowItemId();
ItemData resultItemData = GameData.getItemDataMap().get(resultId);
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);
// Battle pass trigger handler

View File

@ -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;
}
}