Changed CustomPlayerFishEvent

This commit is contained in:
Indyuce 2021-01-01 23:33:28 +01:00
parent 05a6d46a0d
commit bd479df373
2 changed files with 14 additions and 10 deletions

View File

@ -2,27 +2,31 @@ package net.Indyuce.mmocore.api.event;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.player.PlayerData;
public class CustomPlayerFishEvent extends PlayerDataEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final DropItem caught;
private ItemStack caught;
private boolean cancelled = false;
public CustomPlayerFishEvent(PlayerData player, DropItem caught) {
public CustomPlayerFishEvent(PlayerData player, ItemStack caught) {
super(player);
this.caught = caught;
}
public DropItem getCaught() {
public ItemStack getCaught() {
return caught;
}
public void setCaught(ItemStack caught) {
this.caught = caught;
}
@Override
public boolean isCancelled() {
return cancelled;

View File

@ -156,17 +156,17 @@ public class FishingListener implements Listener {
return;
}
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, caught.getDropItem());
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return;
ItemStack collect = caught.collect(new LootBuilder(playerData, 0));
if (collect == null) {
hook.getWorld().spawnParticle(Particle.SMOKE_NORMAL, location, 24, 0, 0, 0, .08);
return;
}
CustomPlayerFishEvent called = new CustomPlayerFishEvent(playerData, collect);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return;
// calculate velocity
Item item = hook.getWorld().dropItemNaturally(hook.getLocation(), collect);
if (MMOCore.plugin.hasHolograms())