mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-11-18 06:24:17 +01:00
Added access to dropped item to CustomPlayerFishEvent
This commit is contained in:
parent
703f1f9610
commit
7ef35007fd
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.api.event;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -9,13 +10,19 @@ public class CustomPlayerFishEvent extends PlayerDataEvent implements Cancellabl
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private ItemStack caught;
|
||||
private final Item droppedItem;
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public CustomPlayerFishEvent(PlayerData player, ItemStack caught) {
|
||||
public CustomPlayerFishEvent(PlayerData player, ItemStack caught, Item droppedItem) {
|
||||
super(player);
|
||||
|
||||
this.caught = caught;
|
||||
this.droppedItem = droppedItem;
|
||||
}
|
||||
|
||||
public Item getDroppedItem() {
|
||||
return droppedItem;
|
||||
}
|
||||
|
||||
public ItemStack getCaught() {
|
||||
|
||||
@ -176,17 +176,20 @@ public class FishingListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
|
||||
|
||||
// Call Bukkit event
|
||||
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect);
|
||||
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect, item);
|
||||
Bukkit.getPluginManager().callEvent(called);
|
||||
if (called.isCancelled())
|
||||
if (called.isCancelled()) {
|
||||
item.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Increase player statistic
|
||||
player.incrementStatistic(Statistic.FISH_CAUGHT);
|
||||
|
||||
// Calculate yeet velocity
|
||||
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
|
||||
MMOCoreUtils.displayIndicator(location.add(0, 1.25, 0),
|
||||
ConfigMessage.fromKey("fish-out-water" + (isCriticalFish() ? "-crit" : "")).asLine());
|
||||
Vector vec = player.getLocation().subtract(hook.getLocation()).toVector();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user