9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-30 04:19:30 +00:00
This commit is contained in:
XiaoMoMi
2024-01-06 02:19:01 +08:00
parent ff2cdaaa13
commit 90e7757909
27 changed files with 246 additions and 76 deletions

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.api.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class FishingBagPreCollectEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlerList = new HandlerList();
private final ItemStack itemStack;
private boolean isCancelled;
private final Inventory bag;
public FishingBagPreCollectEvent(@NotNull Player who, ItemStack itemStack, Inventory bag) {
super(who);
this.itemStack = itemStack;
this.isCancelled = false;
this.bag = bag;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
public ItemStack getItemStack() {
return itemStack;
}
@Override
public @NotNull HandlerList getHandlers() {
return handlerList;
}
public static HandlerList getHandlerList() {
return handlerList;
}
public Inventory getBagInventory() {
return bag;
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.api.event;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class FishingLootPreSpawnEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlerList = new HandlerList();
private final Location location;
private final ItemStack itemStack;
private boolean isCancelled;
public FishingLootPreSpawnEvent(@NotNull Player who, Location location, ItemStack itemStack) {
super(who);
this.itemStack = itemStack;
this.location = location;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
public Location getLocation() {
return location;
}
public ItemStack getItemStack() {
return itemStack;
}
@Override
public @NotNull HandlerList getHandlers() {
return handlerList;
}
public static HandlerList getHandlerList() {
return handlerList;
}
}

View File

@@ -18,23 +18,23 @@
package net.momirealms.customfishing.api.event;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class FishingLootSpawnEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlerList = new HandlerList();
private final Location location;
private final ItemStack itemStack;
private final Item item;
private boolean isCancelled;
public FishingLootSpawnEvent(@NotNull Player who, Location location, ItemStack itemStack) {
public FishingLootSpawnEvent(@NotNull Player who, Location location, Item item) {
super(who);
this.itemStack = itemStack;
this.item = item;
this.location = location;
this.isCancelled = false;
}
@@ -53,8 +53,8 @@ public class FishingLootSpawnEvent extends PlayerEvent implements Cancellable {
return location;
}
public ItemStack getItemStack() {
return itemStack;
public Item getItem() {
return item;
}
@Override

View File

@@ -127,7 +127,9 @@ public class FishingResultEvent extends PlayerEvent implements Cancellable {
}
/**
* Gets the amount of loot received
* Gets the amount of loot received.
* This value is determined by the "multiple-loot" effect.
* If you want to get the amount of item spawned, listen to FishingLootSpawnEvent
*
* @return The amount of loot received, or 1 if the loot is block or entity
*/

View File

@@ -24,7 +24,6 @@ import net.momirealms.customfishing.api.mechanic.condition.Condition;
import org.bukkit.configuration.ConfigurationSection;
import java.util.HashMap;
import java.util.List;
public interface ActionManager {