This commit is contained in:
nossr50 2024-10-31 20:38:04 -07:00
commit 9d5bebef52
2 changed files with 13 additions and 1 deletions

View File

@ -1,18 +1,26 @@
package com.gmail.nossr50.events;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class McMMOReplaceVanillaTreasureEvent extends Event {
private @NotNull ItemStack replacementItemStack;
private final @NotNull Item originalItem;
private final @Nullable Player causingPlayer;
public McMMOReplaceVanillaTreasureEvent(@NotNull Item originalItem, @NotNull ItemStack replacementItemStack) {
this(originalItem, replacementItemStack, null);
}
public McMMOReplaceVanillaTreasureEvent(@NotNull Item originalItem, @NotNull ItemStack replacementItemStack, @Nullable Player causingPlayer) {
this.originalItem = originalItem;
this.replacementItemStack = replacementItemStack;
this.causingPlayer = causingPlayer;
}
/** Rest of file is required boilerplate for custom events **/
@ -31,6 +39,10 @@ public class McMMOReplaceVanillaTreasureEvent extends Event {
return replacementItemStack;
}
public @Nullable Player getCausingPlayer() {
return causingPlayer;
}
public void setReplacementItemStack(@NotNull ItemStack replacementItemStack) {
this.replacementItemStack = replacementItemStack;
}

View File

@ -312,7 +312,7 @@ public class PlayerListener implements Listener {
ItemStack replacementCatch = new ItemStack(Material.SALMON, 1);
McMMOReplaceVanillaTreasureEvent replaceVanillaTreasureEvent = new McMMOReplaceVanillaTreasureEvent(fishingCatch, replacementCatch);
McMMOReplaceVanillaTreasureEvent replaceVanillaTreasureEvent = new McMMOReplaceVanillaTreasureEvent(fishingCatch, replacementCatch, player);
Bukkit.getPluginManager().callEvent(replaceVanillaTreasureEvent);
//Replace