mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
2.2.26 draft
This commit is contained in:
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class CompetitionEvent extends Event {
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final State state;
|
||||
private final FishingCompetition competition;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class CustomFishingReloadEvent extends Event {
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,15 @@ public class CustomFishingReloadEvent extends Event {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of the {@link BukkitCustomFishingPlugin} that is being reloaded.
|
||||
*
|
||||
* @return The instance of the Custom Fishing plugin
|
||||
*/
|
||||
public BukkitCustomFishingPlugin getPluginInstance() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
@@ -48,13 +58,4 @@ public class CustomFishingReloadEvent extends Event {
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of the {@link BukkitCustomFishingPlugin} that is being reloaded.
|
||||
*
|
||||
* @return The instance of the Custom Fishing plugin
|
||||
*/
|
||||
public BukkitCustomFishingPlugin getPluginInstance() {
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ 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;
|
||||
@@ -69,15 +70,6 @@ public class FishingBagPreCollectEvent extends PlayerEvent implements Cancellabl
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Inventory} of the fishing bag.
|
||||
*
|
||||
@@ -87,4 +79,13 @@ public class FishingBagPreCollectEvent extends PlayerEvent implements Cancellabl
|
||||
public Inventory getBagInventory() {
|
||||
return bag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <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 net.momirealms.customfishing.api.mechanic.effect.Effect;
|
||||
import net.momirealms.customfishing.api.mechanic.fishing.CustomFishingHook;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This class provides
|
||||
*/
|
||||
public class FishingEffectApplyEvent extends Event {
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final Stage stage;
|
||||
private final Effect effect;
|
||||
private final CustomFishingHook hook;
|
||||
|
||||
public FishingEffectApplyEvent(CustomFishingHook hook, Effect effect, Stage stage) {
|
||||
this.hook = hook;
|
||||
this.effect = effect;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current stage.
|
||||
* <p>
|
||||
* {@link Stage#CAST}: The effect at this stage determines whether the player can perform a certain mechanism for instance lava fishing.
|
||||
* {@link Stage#LOOT}: The effect at this stage play a crucial role in what loot will appear next, and weighted effects should be applied at this stage.
|
||||
* {@link Stage#FISHING}: The effects at this stage affect the hook time, game difficulty and other fishing-related attributes
|
||||
* <p>
|
||||
* For developers, {@link Stage#CAST} will only be triggered once, while the other two stages will be triggered multiple times
|
||||
*
|
||||
* @return the stage
|
||||
*/
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Effect}
|
||||
* <p>
|
||||
* Effects at stage {@link Stage#CAST} are constant because this stage only affects what mechanics the player can play.
|
||||
* Effects at stage {@link Stage#LOOT}/{@link Stage#FISHING} are temporary because the fishhook could move. For example, it flows from the water into the lava or another biome,
|
||||
* causing some conditional effects changing.
|
||||
* <p>
|
||||
* For developers, {@link Stage#CAST} will only be triggered once, while the other two stages will be triggered multiple times
|
||||
*
|
||||
* @return the effect
|
||||
*/
|
||||
public Effect getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Custom Fishing hook
|
||||
*
|
||||
* @return the fishing hook
|
||||
*/
|
||||
public CustomFishingHook getHook() {
|
||||
return hook;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public enum Stage {
|
||||
CAST,
|
||||
LOOT,
|
||||
FISHING
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class FishingHookStateEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final FishHook fishHook;
|
||||
private final State state;
|
||||
|
||||
@@ -46,10 +47,6 @@ public class FishingHookStateEvent extends PlayerEvent {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link FishHook} involved in this event.
|
||||
*
|
||||
@@ -74,6 +71,10 @@ public class FishingHookStateEvent extends PlayerEvent {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public enum State {
|
||||
BITE,
|
||||
ESCAPE,
|
||||
|
||||
@@ -57,16 +57,6 @@ public class FishingResultEvent extends PlayerEvent implements Cancellable {
|
||||
this.fishHook = fishHook;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
@@ -133,6 +123,16 @@ public class FishingResultEvent extends PlayerEvent implements Cancellable {
|
||||
return Optional.ofNullable(context.arg(ContextKeys.AMOUNT)).orElse(1);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public enum Result {
|
||||
SUCCESS,
|
||||
FAILURE
|
||||
|
||||
@@ -62,16 +62,6 @@ public class RodCastEvent extends PlayerEvent implements Cancellable {
|
||||
this.isCancelled = cancel;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link FishingGears}
|
||||
*
|
||||
@@ -89,4 +79,14 @@ public class RodCastEvent extends PlayerEvent implements Cancellable {
|
||||
public PlayerFishEvent getBukkitPlayerFishEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,4 +84,12 @@ public class EffectProperties<T> {
|
||||
public final int hashCode() {
|
||||
return Objects.hashCode(this.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EffectProperties{" +
|
||||
"key='" + key + '\'' +
|
||||
", type=" + type.getSimpleName() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customfishing.api.mechanic.fishing;
|
||||
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.event.FishingEffectApplyEvent;
|
||||
import net.momirealms.customfishing.api.event.FishingLootSpawnEvent;
|
||||
import net.momirealms.customfishing.api.event.FishingResultEvent;
|
||||
import net.momirealms.customfishing.api.mechanic.MechanicType;
|
||||
@@ -129,6 +130,10 @@ public class CustomFishingHook {
|
||||
consumer.accept(effect, context, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// trigger event
|
||||
EventUtils.fireAndForget(new FishingEffectApplyEvent(this, effect, FishingEffectApplyEvent.Stage.CAST));
|
||||
|
||||
List<HookMechanic> enabledMechanics = mechanicProviders.apply(hook, context, effect);
|
||||
this.task = plugin.getScheduler().sync().runRepeating(() -> {
|
||||
// destroy if hook is invalid
|
||||
@@ -168,6 +173,9 @@ public class CustomFishingHook {
|
||||
}
|
||||
}
|
||||
|
||||
// trigger event
|
||||
EventUtils.fireAndForget(new FishingEffectApplyEvent(this, tempEffect, FishingEffectApplyEvent.Stage.LOOT));
|
||||
|
||||
context.arg(ContextKeys.OTHER_LOCATION, hook.getLocation());
|
||||
context.arg(ContextKeys.OTHER_X, hook.getLocation().getBlockX());
|
||||
context.arg(ContextKeys.OTHER_Y, hook.getLocation().getBlockY());
|
||||
@@ -199,6 +207,10 @@ public class CustomFishingHook {
|
||||
consumer.accept(tempEffect, context, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// trigger event
|
||||
EventUtils.fireAndForget(new FishingEffectApplyEvent(this, tempEffect, FishingEffectApplyEvent.Stage.FISHING));
|
||||
|
||||
// start the mechanic
|
||||
mechanic.start(tempEffect);
|
||||
|
||||
@@ -290,7 +302,7 @@ public class CustomFishingHook {
|
||||
*/
|
||||
public void cancelCurrentGame() {
|
||||
if (gamingPlayer == null || !gamingPlayer.isValid()) {
|
||||
throw new RuntimeException("You can't call this method if the player is not playing the game");
|
||||
return;
|
||||
}
|
||||
gamingPlayer.cancel();
|
||||
gamingPlayer = null;
|
||||
@@ -303,7 +315,7 @@ public class CustomFishingHook {
|
||||
* Starts a game.
|
||||
*/
|
||||
public void gameStart() {
|
||||
if (isPlayingGame())
|
||||
if (isPlayingGame() || !hook.isValid())
|
||||
return;
|
||||
Game nextGame = plugin.getGameManager().getNextGame(tempFinalEffect, context);
|
||||
if (nextGame != null) {
|
||||
@@ -347,7 +359,7 @@ public class CustomFishingHook {
|
||||
* Handles the reel-in action.
|
||||
*/
|
||||
public void onReelIn() {
|
||||
if (isPlayingGame()) return;
|
||||
if (isPlayingGame() || !hook.isValid()) return;
|
||||
if (hookMechanic != null) {
|
||||
if (!hookMechanic.isHooked()) {
|
||||
gears.trigger(ActionTrigger.REEL, context);
|
||||
@@ -373,7 +385,7 @@ public class CustomFishingHook {
|
||||
* Handles the bite action.
|
||||
*/
|
||||
public void onBite() {
|
||||
if (isPlayingGame()) return;
|
||||
if (isPlayingGame() || !hook.isValid()) return;
|
||||
plugin.getEventManager().trigger(context, nextLoot.id(), MechanicType.LOOT, ActionTrigger.BITE);
|
||||
gears.trigger(ActionTrigger.BITE, context);
|
||||
if (RequirementManager.isSatisfied(context, ConfigManager.autoFishingRequirements())) {
|
||||
@@ -392,6 +404,7 @@ public class CustomFishingHook {
|
||||
* Handles the landing action.
|
||||
*/
|
||||
public void onLand() {
|
||||
if (!hook.isValid()) return;
|
||||
gears.trigger(ActionTrigger.LAND, context);
|
||||
}
|
||||
|
||||
@@ -399,16 +412,16 @@ public class CustomFishingHook {
|
||||
* Handles the escape action.
|
||||
*/
|
||||
public void onEscape() {
|
||||
if (!isPlayingGame()) {
|
||||
plugin.getEventManager().trigger(context, nextLoot.id(), MechanicType.LOOT, ActionTrigger.ESCAPE);
|
||||
gears.trigger(ActionTrigger.ESCAPE, context);
|
||||
}
|
||||
if (isPlayingGame() || !hook.isValid()) return;
|
||||
plugin.getEventManager().trigger(context, nextLoot.id(), MechanicType.LOOT, ActionTrigger.ESCAPE);
|
||||
gears.trigger(ActionTrigger.ESCAPE, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the lure action.
|
||||
*/
|
||||
public void onLure() {
|
||||
if (isPlayingGame() || !hook.isValid()) return;
|
||||
plugin.getEventManager().trigger(context, nextLoot.id(), MechanicType.LOOT, ActionTrigger.LURE);
|
||||
gears.trigger(ActionTrigger.LURE, context);
|
||||
}
|
||||
|
||||
@@ -593,7 +593,7 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
}, "effects");
|
||||
}
|
||||
|
||||
private TriConsumer<Effect, Context<Player>, Integer> parseEffect(Section section) {
|
||||
public TriConsumer<Effect, Context<Player>, Integer> parseEffect(Section section) {
|
||||
if (!section.contains("type")) {
|
||||
throw new RuntimeException(section.getRouteAsString());
|
||||
}
|
||||
|
||||
@@ -287,70 +287,70 @@ mechanics:
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Sell icon for individual transactions
|
||||
sell-icons:
|
||||
symbol: 'B'
|
||||
allow-icon:
|
||||
material: IRON_BLOCK
|
||||
display:
|
||||
name: '<#00CED1><b>● <!b>Sell the fish'
|
||||
lore:
|
||||
- '<font:uniform><gradient:#E6E6FA:#48D1CC:#E6E6FA>You will earn <green>{money_formatted} coins</green> from the fish</gradient></font>'
|
||||
action:
|
||||
sound_action:
|
||||
type: sound
|
||||
value:
|
||||
key: 'minecraft:block.amethyst_block.place'
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
message_action:
|
||||
type: message
|
||||
value: 'You earned {money_formatted} coins from the fish! You can still earn {rest_formatted} more coins from the market today.'
|
||||
money_action:
|
||||
type: give-money
|
||||
value: '{money}'
|
||||
# Uncomment the command_action if needed
|
||||
# command_action:
|
||||
# type: command
|
||||
# value: 'money give {player} {money}'
|
||||
deny-icon:
|
||||
material: REDSTONE_BLOCK
|
||||
display:
|
||||
name: '<red><b>● <!b>Trade Denied'
|
||||
lore:
|
||||
- '<font:uniform><gradient:#E6E6FA:red:#E6E6FA>No items available to sell!</gradient></font>'
|
||||
action:
|
||||
sound_action:
|
||||
type: sound
|
||||
value:
|
||||
key: 'minecraft:entity.villager.no'
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
limit-icon:
|
||||
material: REDSTONE_BLOCK
|
||||
display:
|
||||
name: '<red><b>● <!b>Trade Denied'
|
||||
lore:
|
||||
- '<font:uniform><gradient:#E6E6FA:red:#E6E6FA>The total value exceeds the daily limit for earnings!</gradient></font>'
|
||||
action:
|
||||
sound_action:
|
||||
type: sound
|
||||
value:
|
||||
key: 'minecraft:block.anvil.land'
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Decorative icons for visual enhancement
|
||||
decorative-icons:
|
||||
glass-pane:
|
||||
symbol: 'A'
|
||||
material: BLACK_STAINED_GLASS_PANE
|
||||
display:
|
||||
name: ' '
|
||||
components:
|
||||
minecraft:hide_tooltip: {}
|
||||
# Sell icon for individual transactions
|
||||
sell-icons:
|
||||
symbol: 'B'
|
||||
allow-icon:
|
||||
material: IRON_BLOCK
|
||||
display:
|
||||
name: '<#00CED1><b>● <!b>Sell the fish'
|
||||
lore:
|
||||
- '<font:uniform><gradient:#E6E6FA:#48D1CC:#E6E6FA>You will earn <green>{money_formatted} coins</green> from the fish</gradient></font>'
|
||||
action:
|
||||
sound_action:
|
||||
type: sound
|
||||
value:
|
||||
key: 'minecraft:block.amethyst_block.place'
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
message_action:
|
||||
type: message
|
||||
value: 'You earned {money_formatted} coins from the fish! You can still earn {rest_formatted} more coins from the market today.'
|
||||
money_action:
|
||||
type: give-money
|
||||
value: '{money}'
|
||||
# Uncomment the command_action if needed
|
||||
# command_action:
|
||||
# type: command
|
||||
# value: 'money give {player} {money}'
|
||||
deny-icon:
|
||||
material: REDSTONE_BLOCK
|
||||
display:
|
||||
name: '<red><b>● <!b>Trade Denied'
|
||||
lore:
|
||||
- '<font:uniform><gradient:#E6E6FA:red:#E6E6FA>No items available to sell!</gradient></font>'
|
||||
action:
|
||||
sound_action:
|
||||
type: sound
|
||||
value:
|
||||
key: 'minecraft:entity.villager.no'
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
limit-icon:
|
||||
material: REDSTONE_BLOCK
|
||||
display:
|
||||
name: '<red><b>● <!b>Trade Denied'
|
||||
lore:
|
||||
- '<font:uniform><gradient:#E6E6FA:red:#E6E6FA>The total value exceeds the daily limit for earnings!</gradient></font>'
|
||||
action:
|
||||
sound_action:
|
||||
type: sound
|
||||
value:
|
||||
key: 'minecraft:block.anvil.land'
|
||||
source: 'player'
|
||||
volume: 1
|
||||
pitch: 1
|
||||
# Decorative icons for visual enhancement
|
||||
decorative-icons:
|
||||
glass-pane:
|
||||
symbol: 'A'
|
||||
material: BLACK_STAINED_GLASS_PANE
|
||||
display:
|
||||
name: ' '
|
||||
components:
|
||||
minecraft:hide_tooltip: {}
|
||||
# This section is only effective if "override-vanilla" is set to true
|
||||
# Meaning vanilla mechanics, such as lure enchantment, will no longer apply
|
||||
# You must configure their effects in CustomFishing instead
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=2.2.25
|
||||
project_version=2.2.26
|
||||
config_version=36
|
||||
project_group=net.momirealms
|
||||
|
||||
|
||||
Reference in New Issue
Block a user