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.Cancellable;
import org.bukkit.event.HandlerList; 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; import net.Indyuce.mmocore.api.player.PlayerData;
public class CustomPlayerFishEvent extends PlayerDataEvent implements Cancellable { public class CustomPlayerFishEvent extends PlayerDataEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final DropItem caught; private ItemStack caught;
private boolean cancelled = false; private boolean cancelled = false;
public CustomPlayerFishEvent(PlayerData player, DropItem caught) { public CustomPlayerFishEvent(PlayerData player, ItemStack caught) {
super(player); super(player);
this.caught = caught; this.caught = caught;
} }
public DropItem getCaught() { public ItemStack getCaught() {
return caught; return caught;
} }
public void setCaught(ItemStack caught) {
this.caught = caught;
}
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;

View File

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