diff --git a/README.md b/README.md index 44e78733..e6dd0e29 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,4 @@ https://afdian.net/@xiaomomi https://polymart.org/resource/customfishing.2723 ### About compilation -Some premium plugins are used as local libraries, but I give the links because I can't leak them on github. \ No newline at end of file +./gradlew build \ No newline at end of file diff --git a/build.gradle b/build.gradle index c88c39b9..a677bae8 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.3.2.0-hotfix' +version = '1.3.2.1' repositories { maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"} diff --git a/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java b/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java index 5fbfab3b..d9855e74 100644 --- a/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java +++ b/src/main/java/net/momirealms/customfishing/api/CustomFishingAPI.java @@ -24,7 +24,7 @@ import net.momirealms.customfishing.fishing.FishingCondition; import net.momirealms.customfishing.fishing.competition.Competition; import net.momirealms.customfishing.fishing.loot.DroppedItem; import net.momirealms.customfishing.fishing.loot.Item; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.manager.ConfigManager; import net.momirealms.customfishing.util.ItemStackUtils; import org.bukkit.Location; @@ -114,7 +114,7 @@ public class CustomFishingAPI { * @param player player * @return loots */ - public static List getLootsAt(Location location, Player player) { + public static List getLootsAt(Location location, Player player) { return CustomFishing.getInstance().getFishingManager().getPossibleLootList(new FishingCondition(location, player, null, null), false, CustomFishing.getInstance().getLootManager().getAllLoots()); } @@ -123,7 +123,7 @@ public class CustomFishingAPI { * @param location location * @return loots */ - public static List getLootsAt(Location location) { + public static List getLootsAt(Location location) { return CustomFishing.getInstance().getFishingManager().getPossibleLootList(new FishingCondition(location, null, null, null), false, CustomFishing.getInstance().getLootManager().getAllLoots()); } @@ -132,7 +132,7 @@ public class CustomFishingAPI { * @param id id * @return loot */ - public static Loot getLootByID(String id) { + public static LootImpl getLootByID(String id) { return CustomFishing.getInstance().getLootManager().getLoot(id); } @@ -144,7 +144,7 @@ public class CustomFishingAPI { */ @NotNull public static ItemStack getLootItemByID(String id) { - return CustomFishing.getInstance().getIntegrationManager().build(id); + return CustomFishing.getInstance().getIntegrationManager().build(id, null); } /** @@ -156,7 +156,7 @@ public class CustomFishingAPI { */ @NotNull public static ItemStack getLootItemByID(String id, @Nullable Player player) { - Loot loot = CustomFishing.getInstance().getLootManager().getLoot(id); + LootImpl loot = CustomFishing.getInstance().getLootManager().getLoot(id); if (!(loot instanceof DroppedItem droppedItem)) return new ItemStack(Material.AIR); return CustomFishing.getInstance().getFishingManager().getCustomFishingLootItemStack(droppedItem, player); } diff --git a/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java b/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java index bdd7507f..edeec827 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishFinderEvent.java @@ -17,7 +17,7 @@ package net.momirealms.customfishing.api.event; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -31,9 +31,9 @@ public class FishFinderEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlerList = new HandlerList(); private boolean cancelled; - private final List loots; + private final List loots; - public FishFinderEvent(@NotNull Player who, List loots) { + public FishFinderEvent(@NotNull Player who, List loots) { super(who); this.cancelled = false; this.loots = loots; @@ -59,7 +59,7 @@ public class FishFinderEvent extends PlayerEvent implements Cancellable { return getHandlerList(); } - public List getLoots() { + public List getLoots() { return loots; } } diff --git a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java index 09b225ee..1fe8b435 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java @@ -18,6 +18,8 @@ package net.momirealms.customfishing.api.event; import net.momirealms.customfishing.fishing.FishResult; +import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -31,17 +33,19 @@ public class FishResultEvent extends PlayerEvent implements Cancellable { private boolean cancelled; private boolean isDouble; private final FishResult result; - private final ItemStack loot; + private final ItemStack itemStack; private final String loot_id; + private final Loot loot; private static final HandlerList handlerList = new HandlerList(); - public FishResultEvent(@NotNull Player who, FishResult result, boolean isDouble, @Nullable ItemStack loot, @Nullable String loot_id) { + public FishResultEvent(@NotNull Player who, FishResult result, boolean isDouble, @Nullable ItemStack itemStack, @Nullable String loot_id, @Nullable Loot loot) { super(who); this.cancelled = false; this.result = result; this.isDouble = isDouble; - this.loot = loot; + this.itemStack = itemStack; this.loot_id = loot_id; + this.loot = loot; } @Override @@ -78,8 +82,8 @@ public class FishResultEvent extends PlayerEvent implements Cancellable { * @return loot id */ @Nullable - public ItemStack getLoot() { - return loot; + public ItemStack getItemStack() { + return itemStack; } public void setDouble(boolean willDouble) { @@ -100,4 +104,8 @@ public class FishResultEvent extends PlayerEvent implements Cancellable { public String getLootID() { return loot_id; } + + public Loot getLoot() { + return loot; + } } diff --git a/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java b/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java index 4a8395e9..626766cb 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/RodCastEvent.java @@ -18,6 +18,7 @@ package net.momirealms.customfishing.api.event; import net.momirealms.customfishing.fishing.Effect; +import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/DebugCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/DebugCommand.java index c3149ff0..762f19fd 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/DebugCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/DebugCommand.java @@ -5,7 +5,7 @@ import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.api.CustomFishingAPI; import net.momirealms.customfishing.commands.AbstractSubCommand; import net.momirealms.customfishing.fishing.Effect; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.integration.SeasonInterface; import net.momirealms.customfishing.util.AdventureUtils; import org.bukkit.command.CommandSender; @@ -62,13 +62,13 @@ public class DebugCommand extends AbstractSubCommand { return null; } - public ArrayList getLootProbability(Effect initialEffect, List possibleLoots) { - List availableLoots = new ArrayList<>(); + public ArrayList getLootProbability(Effect initialEffect, List possibleLoots) { + List availableLoots = new ArrayList<>(); HashMap as = initialEffect.getWeightAS(); HashMap md = initialEffect.getWeightMD(); double[] weights = new double[possibleLoots.size()]; int index = 0; - for (Loot loot : possibleLoots){ + for (LootImpl loot : possibleLoots){ double weight = loot.getWeight(); String group = loot.getGroup(); if (group != null){ diff --git a/src/main/java/net/momirealms/customfishing/commands/subcmd/StatisticsCommand.java b/src/main/java/net/momirealms/customfishing/commands/subcmd/StatisticsCommand.java index 6c375563..ac1d2b83 100644 --- a/src/main/java/net/momirealms/customfishing/commands/subcmd/StatisticsCommand.java +++ b/src/main/java/net/momirealms/customfishing/commands/subcmd/StatisticsCommand.java @@ -19,7 +19,7 @@ package net.momirealms.customfishing.commands.subcmd; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.commands.AbstractSubCommand; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.manager.ConfigManager; import net.momirealms.customfishing.manager.MessageManager; import net.momirealms.customfishing.util.AdventureUtils; @@ -59,7 +59,7 @@ public class StatisticsCommand extends AbstractSubCommand { AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.negativeStatistics); return true; } - Loot loot = CustomFishing.getInstance().getLootManager().getLoot(args.get(1)); + LootImpl loot = CustomFishing.getInstance().getLootManager().getLoot(args.get(1)); if (loot == null || loot.isDisableStats()) { AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.statisticsNotExists); return true; @@ -79,7 +79,7 @@ public class StatisticsCommand extends AbstractSubCommand { if (args.size() == 2) { return CustomFishing.getInstance().getLootManager().getAllLoots().stream() .filter(loot -> loot.getKey().startsWith(args.get(1)) && !loot.isDisableStats()) - .map(Loot::getKey) + .map(LootImpl::getKey) .collect(Collectors.toList()); } if (args.size() == 3) { diff --git a/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java b/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java index 09e64ef5..8b122904 100644 --- a/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java +++ b/src/main/java/net/momirealms/customfishing/data/PlayerStatisticsData.java @@ -19,7 +19,7 @@ package net.momirealms.customfishing.data; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.fishing.action.Action; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -68,7 +68,7 @@ public class PlayerStatisticsData { return joiner.toString(); } - public void addFishAmount(Loot loot, UUID uuid, int amount) { + public void addFishAmount(LootImpl loot, UUID uuid, int amount) { Integer previous = amountMap.get(loot.getKey()); if (previous == null) previous = 0; int after = previous + amount; @@ -79,7 +79,7 @@ public class PlayerStatisticsData { doSuccessTimesAction(previous, after, player, loot); } - private void doSuccessTimesAction(Integer previous, int after, Player player, Loot vanilla) { + private void doSuccessTimesAction(Integer previous, int after, Player player, LootImpl vanilla) { HashMap actionMap = vanilla.getSuccessTimesActions(); if (actionMap != null) { for (Map.Entry entry : actionMap.entrySet()) { diff --git a/src/main/java/net/momirealms/customfishing/fishing/BobberCheckTask.java b/src/main/java/net/momirealms/customfishing/fishing/BobberCheckTask.java index 63b748dc..74d6d07c 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/BobberCheckTask.java +++ b/src/main/java/net/momirealms/customfishing/fishing/BobberCheckTask.java @@ -20,7 +20,7 @@ package net.momirealms.customfishing.fishing; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; import net.momirealms.customfishing.CustomFishing; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.manager.ConfigManager; import net.momirealms.customfishing.manager.FishingManager; import net.momirealms.customfishing.util.AdventureUtils; @@ -140,7 +140,7 @@ public class BobberCheckTask implements Runnable { if (fishHook.isInWater()) { stop(); plugin.getScheduler().runTaskAsync(() -> { - List possibleLoots = new ArrayList<>(); + List possibleLoots = new ArrayList<>(); if (!(ConfigManager.needRodForLoot && !effect.hasSpecialRod())) { possibleLoots = fishingManager.getPossibleLootList(new FishingCondition(fishHook.getLocation(), player, rod, bait), false, plugin.getLootManager().getWaterLoots().values()); } @@ -195,7 +195,7 @@ public class BobberCheckTask implements Runnable { private void randomTime() { plugin.getScheduler().runTaskAsync(() -> { - List possibleLoots = new ArrayList<>(); + List possibleLoots = new ArrayList<>(); if (!(ConfigManager.needRodForLoot && !effect.hasSpecialRod())) { possibleLoots = fishingManager.getPossibleLootList(new FishingCondition(fishHook.getLocation(), player, rod, bait), false, plugin.getLootManager().getLavaLoots().values()); } diff --git a/src/main/java/net/momirealms/customfishing/fishing/loot/DroppedItem.java b/src/main/java/net/momirealms/customfishing/fishing/loot/DroppedItem.java index f5fe834d..37825282 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/loot/DroppedItem.java +++ b/src/main/java/net/momirealms/customfishing/fishing/loot/DroppedItem.java @@ -21,7 +21,7 @@ import net.momirealms.customfishing.fishing.MiniGameConfig; import net.momirealms.customfishing.object.LeveledEnchantment; import org.jetbrains.annotations.Nullable; -public class DroppedItem extends Loot { +public class DroppedItem extends LootImpl { private final boolean randomDurability; private LeveledEnchantment[] randomEnchants; diff --git a/src/main/java/net/momirealms/customfishing/fishing/loot/Loot.java b/src/main/java/net/momirealms/customfishing/fishing/loot/Loot.java index a32e63d6..4ce0a3b2 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/loot/Loot.java +++ b/src/main/java/net/momirealms/customfishing/fishing/loot/Loot.java @@ -1,20 +1,3 @@ -/* - * Copyright (C) <2022> - * - * 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 . - */ - package net.momirealms.customfishing.fishing.loot; import net.momirealms.customfishing.fishing.MiniGameConfig; @@ -23,122 +6,35 @@ import net.momirealms.customfishing.fishing.requirements.RequirementInterface; import java.util.HashMap; -public class Loot { +public interface Loot { - public static Loot EMPTY = new Loot("null", "null", new MiniGameConfig[0], 0, false, 0d, false, true); + MiniGameConfig[] getFishingGames(); - protected final String key; - protected final String nick; - protected String group; - protected boolean disableStats; - protected boolean disableBar; - protected final boolean showInFinder; - protected Action[] successActions; - protected Action[] failureActions; - protected Action[] hookActions; - protected Action[] consumeActions; - protected HashMap successTimesActions; - protected RequirementInterface[] requirements; - protected final MiniGameConfig[] fishingGames; - protected final int weight; - protected final double score; + String getKey(); - public Loot(String key, String nick, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, boolean disableBar, boolean disableStats) { - this.key = key; - this.nick = nick; - this.weight = weight; - this.showInFinder = showInFinder; - this.score = score; - this.fishingGames = fishingGames; - this.disableBar = disableBar; - this.disableStats = disableStats; - } + String getNick(); - public MiniGameConfig[] getFishingGames() { - return fishingGames; - } + String getGroup(); - public String getKey() { - return key; - } + boolean isShowInFinder(); - public String getNick() { - return nick; - } + Action[] getSuccessActions(); - public String getGroup() { - return group; - } + public Action[] getFailureActions(); - public void setGroup(String group) { - this.group = group; - } + public Action[] getConsumeActions(); - public boolean isShowInFinder() { - return showInFinder; - } + public Action[] getHookActions(); - public Action[] getSuccessActions() { - return successActions; - } + public int getWeight(); - public void setSuccessActions(Action[] successActions) { - this.successActions = successActions; - } + public double getScore(); - public Action[] getFailureActions() { - return failureActions; - } + public RequirementInterface[] getRequirements(); - public Action[] getConsumeActions() { - return consumeActions; - } + public boolean isDisableBar(); - public void setConsumeActions(Action[] consumeActions) { - this.consumeActions = consumeActions; - } + HashMap getSuccessTimesActions(); - public void setFailureActions(Action[] failureActions) { - this.failureActions = failureActions; - } - - public Action[] getHookActions() { - return hookActions; - } - - public void setHookActions(Action[] hookActions) { - this.hookActions = hookActions; - } - - public int getWeight() { - return weight; - } - - public double getScore() { - return score; - } - - public RequirementInterface[] getRequirements() { - return requirements; - } - - public void setRequirements(RequirementInterface[] requirements) { - this.requirements = requirements; - } - - public boolean isDisableBar() { - return disableBar; - } - - public HashMap getSuccessTimesActions() { - return successTimesActions; - } - - public void setSuccessTimesActions(HashMap successTimesActions) { - this.successTimesActions = successTimesActions; - } - - public boolean isDisableStats() { - return disableStats; - } + boolean isDisableStats(); } diff --git a/src/main/java/net/momirealms/customfishing/fishing/loot/LootImpl.java b/src/main/java/net/momirealms/customfishing/fishing/loot/LootImpl.java new file mode 100644 index 00000000..2c864ae9 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/fishing/loot/LootImpl.java @@ -0,0 +1,144 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + +package net.momirealms.customfishing.fishing.loot; + +import net.momirealms.customfishing.fishing.MiniGameConfig; +import net.momirealms.customfishing.fishing.action.Action; +import net.momirealms.customfishing.fishing.requirements.RequirementInterface; + +import java.util.HashMap; + +public class LootImpl implements Loot { + + public static LootImpl EMPTY = new LootImpl("null", "null", new MiniGameConfig[0], 0, false, 0d, false, true); + + protected final String key; + protected final String nick; + protected String group; + protected boolean disableStats; + protected boolean disableBar; + protected final boolean showInFinder; + protected Action[] successActions; + protected Action[] failureActions; + protected Action[] hookActions; + protected Action[] consumeActions; + protected HashMap successTimesActions; + protected RequirementInterface[] requirements; + protected final MiniGameConfig[] fishingGames; + protected final int weight; + protected final double score; + + public LootImpl(String key, String nick, MiniGameConfig[] fishingGames, int weight, boolean showInFinder, double score, boolean disableBar, boolean disableStats) { + this.key = key; + this.nick = nick; + this.weight = weight; + this.showInFinder = showInFinder; + this.score = score; + this.fishingGames = fishingGames; + this.disableBar = disableBar; + this.disableStats = disableStats; + } + + public MiniGameConfig[] getFishingGames() { + return fishingGames; + } + + public String getKey() { + return key; + } + + public String getNick() { + return nick; + } + + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + + public boolean isShowInFinder() { + return showInFinder; + } + + public Action[] getSuccessActions() { + return successActions; + } + + public void setSuccessActions(Action[] successActions) { + this.successActions = successActions; + } + + public Action[] getFailureActions() { + return failureActions; + } + + public Action[] getConsumeActions() { + return consumeActions; + } + + public void setConsumeActions(Action[] consumeActions) { + this.consumeActions = consumeActions; + } + + public void setFailureActions(Action[] failureActions) { + this.failureActions = failureActions; + } + + public Action[] getHookActions() { + return hookActions; + } + + public void setHookActions(Action[] hookActions) { + this.hookActions = hookActions; + } + + public int getWeight() { + return weight; + } + + public double getScore() { + return score; + } + + public RequirementInterface[] getRequirements() { + return requirements; + } + + public void setRequirements(RequirementInterface[] requirements) { + this.requirements = requirements; + } + + public boolean isDisableBar() { + return disableBar; + } + + public HashMap getSuccessTimesActions() { + return successTimesActions; + } + + public void setSuccessTimesActions(HashMap successTimesActions) { + this.successTimesActions = successTimesActions; + } + + public boolean isDisableStats() { + return disableStats; + } +} diff --git a/src/main/java/net/momirealms/customfishing/fishing/loot/Mob.java b/src/main/java/net/momirealms/customfishing/fishing/loot/Mob.java index 25860a85..8e8098d8 100644 --- a/src/main/java/net/momirealms/customfishing/fishing/loot/Mob.java +++ b/src/main/java/net/momirealms/customfishing/fishing/loot/Mob.java @@ -20,7 +20,7 @@ package net.momirealms.customfishing.fishing.loot; import net.momirealms.customfishing.fishing.MiniGameConfig; import org.jetbrains.annotations.NotNull; -public class Mob extends Loot{ +public class Mob extends LootImpl { private final String mobID; private final int mobLevel; diff --git a/src/main/java/net/momirealms/customfishing/integration/EnchantmentInterface.java b/src/main/java/net/momirealms/customfishing/integration/EnchantmentInterface.java index eb97f2a7..3e82381e 100644 --- a/src/main/java/net/momirealms/customfishing/integration/EnchantmentInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/EnchantmentInterface.java @@ -1,5 +1,6 @@ package net.momirealms.customfishing.integration; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.List; diff --git a/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java b/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java index e4772fa6..c72e7cd7 100644 --- a/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java +++ b/src/main/java/net/momirealms/customfishing/integration/ItemInterface.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable; public interface ItemInterface { @Nullable - ItemStack build(String id); + ItemStack build(String id, Player player); boolean loseCustomDurability(ItemStack itemStack, Player player); diff --git a/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java index a0f2bf2b..e27af9e7 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/CustomFishingItemImpl.java @@ -37,7 +37,7 @@ public class CustomFishingItemImpl implements ItemInterface { @Override @Nullable - public ItemStack build(String material) { + public ItemStack build(String material, Player player) { if (material.contains(":")) return null; return plugin.getLootManager().build(material); } diff --git a/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java index ed209236..03b091c9 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/ItemsAdderItemImpl.java @@ -28,7 +28,7 @@ public class ItemsAdderItemImpl implements ItemInterface { @Override @Nullable - public ItemStack build(String material) { + public ItemStack build(String material, Player player) { if (!material.startsWith("ItemsAdder:")) return null; material = material.substring(11); CustomStack customStack = CustomStack.getInstance(material); diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java index b2d35fa6..0009699f 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MMOItemsItemImpl.java @@ -34,7 +34,7 @@ public class MMOItemsItemImpl implements ItemInterface { @Nullable @Override - public ItemStack build(String material) { + public ItemStack build(String material, Player player) { if (!material.startsWith("MMOItems:")) return null; material = material.substring(9); String[] split = material.split(":"); diff --git a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java index c4dab518..ef887b61 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/MythicMobsItemImpl.java @@ -34,7 +34,7 @@ public class MythicMobsItemImpl implements ItemInterface { @Override @Nullable - public ItemStack build(String material) { + public ItemStack build(String material, Player player) { if (!material.startsWith("MythicMobs:")) return null; material = material.substring(11); if (mythicBukkit == null || mythicBukkit.isClosed()) { diff --git a/src/main/java/net/momirealms/customfishing/integration/item/NeigeItemsImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/NeigeItemsImpl.java new file mode 100644 index 00000000..8a435265 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/item/NeigeItemsImpl.java @@ -0,0 +1,38 @@ +package net.momirealms.customfishing.integration.item; + +import net.momirealms.customfishing.integration.ItemInterface; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Nullable; +import pers.neige.neigeitems.item.ItemDurability; +import pers.neige.neigeitems.item.ItemInfo; +import pers.neige.neigeitems.manager.ItemManager; +import pers.neige.neigeitems.utils.ItemUtils; + +public class NeigeItemsImpl implements ItemInterface { + + @Override + public @Nullable ItemStack build(String material, Player player) { + if (!material.startsWith("NeigeItems:")) return null; + material = material.substring(11); + return ItemManager.INSTANCE.getItemStack(material, player); + } + + @Override + public boolean loseCustomDurability(ItemStack itemStack, Player player) { + ItemInfo itemInfo = ItemUtils.isNiItem(itemStack); + if (itemInfo == null) return false; + ItemDurability.INSTANCE.damage(player, itemStack, 1, true, null); + return true; + } + + @Override + public @Nullable String getID(ItemStack itemStack) { + ItemInfo itemInfo = ItemUtils.isNiItem(itemStack); + if (itemInfo != null) { + return itemInfo.getId(); + } + return null; + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java b/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java index c5b34f84..a7c1247e 100644 --- a/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java +++ b/src/main/java/net/momirealms/customfishing/integration/item/OraxenItemImpl.java @@ -31,7 +31,7 @@ public class OraxenItemImpl implements ItemInterface { @Override @Nullable - public ItemStack build(String material) { + public ItemStack build(String material, Player player) { if (!material.startsWith("Oraxen:")) return null; material = material.substring(7); ItemBuilder itemBuilder = OraxenItems.getItemById(material); diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java b/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java index 97ebd5e0..45852217 100644 --- a/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java +++ b/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollCFQuest.java @@ -21,21 +21,31 @@ import com.electro2560.dev.cluescrolls.api.*; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.api.event.FishResultEvent; import net.momirealms.customfishing.fishing.FishResult; +import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public class ClueScrollCFQuest implements Listener { - private final CustomClue commonClue; + private final CustomClue idClue; + private final CustomClue groupClue; public ClueScrollCFQuest() { - commonClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "fish", new ClueConfigData("fish_id", DataType.STRING)); + idClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "fish", new ClueConfigData("fish_id", DataType.STRING)); + groupClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "group", new ClueConfigData("fish_group", DataType.STRING)); } @EventHandler public void onFish(FishResultEvent event) { if (event.isCancelled()) return; if (event.getResult() == FishResult.FAILURE) return; - commonClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("fish_id", event.getLoot_id())); + if (event.getLootID() != null) { + idClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("fish_id", event.getLootID())); + } + Loot loot = event.getLoot(); + if (loot != null && loot.getGroup() != null) { + groupClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("fish_group", loot.getGroup())); + } } } diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 03db72b7..3cc0472f 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -37,7 +37,7 @@ import net.momirealms.customfishing.fishing.bar.ModeTwoBar; import net.momirealms.customfishing.fishing.competition.Competition; import net.momirealms.customfishing.fishing.competition.CompetitionGoal; import net.momirealms.customfishing.fishing.loot.DroppedItem; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.fishing.loot.Mob; import net.momirealms.customfishing.fishing.mode.FishingGame; import net.momirealms.customfishing.fishing.mode.ModeOneGame; @@ -91,7 +91,7 @@ public class FishingManager extends Function { private final BreakBlockListener breakBlockListener; private final HashMap coolDown; private final HashMap hooks; - private final HashMap nextLoot; + private final HashMap nextLoot; private final HashMap nextEffect; private final HashMap vanillaLoot; private final ConcurrentHashMap fishingPlayerMap; @@ -247,7 +247,7 @@ public class FishingManager extends Function { this.nextEffect.put(player.getUniqueId(), initialEffect); if (ConfigManager.needRodToFish && !initialEffect.hasSpecialRod()) { - this.nextLoot.put(player.getUniqueId(), Loot.EMPTY); + this.nextLoot.put(player.getUniqueId(), LootImpl.EMPTY); return; } @@ -268,8 +268,8 @@ public class FishingManager extends Function { showBar(event.getPlayer()); } - public void getNextLoot(Player player, Effect initialEffect, List possibleLoots) { - List availableLoots = new ArrayList<>(); + public void getNextLoot(Player player, Effect initialEffect, List possibleLoots) { + List availableLoots = new ArrayList<>(); if (possibleLoots.size() == 0){ nextLoot.put(player.getUniqueId(), null); return; @@ -280,7 +280,7 @@ public class FishingManager extends Function { double[] weights = new double[possibleLoots.size()]; int index = 0; - for (Loot loot : possibleLoots){ + for (LootImpl loot : possibleLoots){ double weight = loot.getWeight(); String group = loot.getGroup(); if (group != null){ @@ -330,8 +330,8 @@ public class FishingManager extends Function { // if the player is noy playing the game if (fishingGame == null) { // get his next loot - Loot loot = nextLoot.get(uuid); - if (loot == Loot.EMPTY) return; + LootImpl loot = nextLoot.get(uuid); + if (loot == LootImpl.EMPTY) return; if (ConfigManager.enableVanillaLoot) { // Not a vanilla loot @@ -407,8 +407,8 @@ public class FishingManager extends Function { //not in fishing game BobberCheckTask bobberCheckTask = hookCheckTaskMap.get(uuid); if (bobberCheckTask != null && bobberCheckTask.isHooked()) { - Loot loot = nextLoot.get(uuid); - if (loot == Loot.EMPTY || loot == null) return; + LootImpl loot = nextLoot.get(uuid); + if (loot == LootImpl.EMPTY || loot == null) return; if (loot.isDisableBar()) { noBarLavaReelIn(event); return; @@ -445,7 +445,7 @@ public class FishingManager extends Function { event.setExpToDrop(0); final Player player = event.getPlayer(); final UUID uuid = player.getUniqueId(); - Loot loot = nextLoot.remove(uuid); + LootImpl loot = nextLoot.remove(uuid); VanillaLoot vanilla = vanillaLoot.remove(uuid); Effect effect = nextEffect.remove(uuid); if (vanilla != null) { @@ -467,7 +467,7 @@ public class FishingManager extends Function { final UUID uuid = player.getUniqueId(); BobberCheckTask bobberCheckTask = hookCheckTaskMap.remove(uuid); if (bobberCheckTask != null && bobberCheckTask.isHooked()) { - Loot loot = nextLoot.remove(uuid); + LootImpl loot = nextLoot.remove(uuid); VanillaLoot vanilla = vanillaLoot.remove(uuid); Effect effect = nextEffect.remove(uuid); if (vanilla != null) { @@ -488,7 +488,7 @@ public class FishingManager extends Function { public void proceedReelIn(Location hookLoc, Player player, FishingGame fishingGame) { fishingGame.cancel(); final UUID uuid = player.getUniqueId(); - Loot loot = nextLoot.remove(uuid); + LootImpl loot = nextLoot.remove(uuid); VanillaLoot vanilla = vanillaLoot.remove(uuid); Effect effect = nextEffect.remove(uuid); player.removePotionEffect(PotionEffectType.SLOW); @@ -516,7 +516,7 @@ public class FishingManager extends Function { private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier, double sizeMultiplier) { ItemStack drop = getCustomFishingLootItemStack(droppedItem, player, sizeMultiplier); - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_SPECIAL_ITEM, isDouble, drop, droppedItem.getKey()); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_SPECIAL_ITEM, isDouble, drop, droppedItem.getKey(), droppedItem); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; @@ -547,7 +547,7 @@ public class FishingManager extends Function { } public ItemStack getCustomFishingLootItemStack(DroppedItem droppedItem, @Nullable Player player, double sizeMultiplier) { - ItemStack drop = plugin.getIntegrationManager().build(droppedItem.getMaterial()); + ItemStack drop = plugin.getIntegrationManager().build(droppedItem.getMaterial(), player); if (drop.getType() != Material.AIR) { if (droppedItem.getRandomEnchants() != null) ItemStackUtils.addRandomEnchants(drop, droppedItem.getRandomEnchants()); @@ -564,7 +564,7 @@ public class FishingManager extends Function { ItemStack itemStack = McMMOTreasure.getTreasure(player); if (itemStack == null) return false; - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "vanilla"); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "mcMMO", null); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return true; @@ -584,7 +584,7 @@ public class FishingManager extends Function { } } - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "vanilla"); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "vanilla", null); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; @@ -600,7 +600,7 @@ public class FishingManager extends Function { Competition.currentCompetition.tryJoinCompetition(player); } - Loot vanilla = plugin.getLootManager().getVanilla_loot(); + LootImpl vanilla = plugin.getLootManager().getVanilla_loot(); addStats(player, vanilla, isDouble ? 2 : 1); if (vanilla.getSuccessActions() != null) @@ -630,18 +630,18 @@ public class FishingManager extends Function { } } - private void addStats(Player player, Loot loot, int amount) { + private void addStats(Player player, LootImpl loot, int amount) { player.setStatistic(Statistic.FISH_CAUGHT, player.getStatistic(Statistic.FISH_CAUGHT) + 1); if (!ConfigManager.enableStatistics) return; if (loot.isDisableStats()) return; plugin.getStatisticsManager().addFishAmount(player.getUniqueId(), loot, amount); } - private void summonMob(Player player, Loot loot, Location location, Mob mob, double scoreMultiplier) { + private void summonMob(Player player, LootImpl loot, Location location, Mob mob, double scoreMultiplier) { MobInterface mobInterface = plugin.getIntegrationManager().getMobInterface(); if (mobInterface == null) return; - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_MOB, false, null, loot.getKey()); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_MOB, false, null, loot.getKey(), loot); if (fishResultEvent.isCancelled()) { return; } @@ -731,8 +731,8 @@ public class FishingManager extends Function { return null; } - public void fail(Player player, Loot loot, boolean isVanilla) { - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.FAILURE, false, null, null); + public void fail(Player player, LootImpl loot, boolean isVanilla) { + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.FAILURE, false, null, null, null); Bukkit.getServer().getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; @@ -757,9 +757,9 @@ public class FishingManager extends Function { public void showBar(Player player) { final UUID uuid = player.getUniqueId(); if (fishingPlayerMap.get(uuid) != null) return; - Loot loot = nextLoot.get(uuid); + LootImpl loot = nextLoot.get(uuid); if (loot != null) { - if (loot == Loot.EMPTY) return; + if (loot == LootImpl.EMPTY) return; showFishingBar(player, loot); } } @@ -778,10 +778,10 @@ public class FishingManager extends Function { } } - public List getPossibleLootList(FishingCondition fishingCondition, boolean finder, Collection values) { - Stream stream = values.stream(); + public List getPossibleLootList(FishingCondition fishingCondition, boolean finder, Collection values) { + Stream stream = values.stream(); if (finder) { - stream = stream.filter(Loot::isShowInFinder); + stream = stream.filter(LootImpl::isShowInFinder); } return stream.filter(loot -> { RequirementInterface[] requirements = loot.getRequirements(); @@ -868,7 +868,7 @@ public class FishingManager extends Function { } FishingCondition fishingCondition = new FishingCondition(player.getLocation(), player, null, null); - List possibleLoots = getPossibleLootList(fishingCondition, true, plugin.getLootManager().getAllLoots()); + List possibleLoots = getPossibleLootList(fishingCondition, true, plugin.getLootManager().getAllLoots()); FishFinderEvent fishFinderEvent = new FishFinderEvent(player, possibleLoots); Bukkit.getPluginManager().callEvent(fishFinderEvent); @@ -885,7 +885,7 @@ public class FishingManager extends Function { AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.possibleLoots + stringJoiner); } - private void showFishingBar(Player player, @NotNull Loot loot) { + private void showFishingBar(Player player, @NotNull LootImpl loot) { MiniGameConfig game = loot.getFishingGames() != null ? loot.getFishingGames()[new Random().nextInt(loot.getFishingGames().length)] : plugin.getBarMechanicManager().getRandomGame(); @@ -1013,7 +1013,7 @@ public class FishingManager extends Function { if (nbtCompound == null) return; if (!nbtCompound.getString("type").equals("loot")) return; String lootKey = nbtCompound.getString("id"); - Loot loot = plugin.getLootManager().getLoot(lootKey); + LootImpl loot = plugin.getLootManager().getLoot(lootKey); if (loot == null) return; if (!(loot instanceof DroppedItem droppedItem)) return; final Player player = event.getPlayer(); diff --git a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java index ef62435c..c0becbc6 100644 --- a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java @@ -202,6 +202,10 @@ public class IntegrationManager extends Function { itemInterfaceList.add(new MythicMobsItemImpl()); hookMessage("MythicMobs"); } + if (pluginManager.isPluginEnabled("NeigeItems")) { + itemInterfaceList.add(new NeigeItemsImpl()); + hookMessage("NeigeItems"); + } itemInterfaceList.add(new CustomFishingItemImpl(plugin)); this.itemInterfaces = itemInterfaceList.toArray(new ItemInterface[0]); @@ -271,7 +275,18 @@ public class IntegrationManager extends Function { @NotNull public ItemStack build(String key) { for (ItemInterface itemInterface : getItemInterfaces()) { - ItemStack itemStack = itemInterface.build(key); + ItemStack itemStack = itemInterface.build(key, null); + if (itemStack != null) { + return itemStack; + } + } + return new ItemStack(Material.AIR); + } + + @NotNull + public ItemStack build(String key, Player player) { + for (ItemInterface itemInterface : getItemInterfaces()) { + ItemStack itemStack = itemInterface.build(key, player); if (itemStack != null) { return itemStack; } @@ -282,8 +297,8 @@ public class IntegrationManager extends Function { @Nullable public String getItemID(ItemStack itemStack) { if (itemStack == null || itemStack.getType() == Material.AIR) return null; - for (ItemInterface itemInterface : getItemInterfaces()) { - String id = itemInterface.getID(itemStack); + for (int i = 0, size = itemInterfaces.length; i < size; i++) { + String id = itemInterfaces[size - i - 1].getID(itemStack); if (id != null) { return id; } diff --git a/src/main/java/net/momirealms/customfishing/manager/LootManager.java b/src/main/java/net/momirealms/customfishing/manager/LootManager.java index 17286962..4ca242ff 100644 --- a/src/main/java/net/momirealms/customfishing/manager/LootManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/LootManager.java @@ -42,11 +42,11 @@ import java.util.*; public class LootManager extends Function { private final CustomFishing plugin; - private final HashMap waterLoots; - private final HashMap lavaLoots; + private final HashMap waterLoots; + private final HashMap lavaLoots; private final HashMap lootItems; private final HashMap> category; - private Loot vanilla_loot; + private LootImpl vanilla_loot; public LootManager(CustomFishing plugin) { this.plugin = plugin; @@ -64,7 +64,7 @@ public class LootManager extends Function { @Override public void load() { - this.vanilla_loot = new Loot( + this.vanilla_loot = new LootImpl( "vanilla", "vanilla", null, @@ -91,8 +91,8 @@ public class LootManager extends Function { } @Nullable - public Loot getLoot(String key) { - Loot loot = this.waterLoots.get(key); + public LootImpl getLoot(String key) { + LootImpl loot = this.waterLoots.get(key); if (loot == null) { loot = this.lavaLoots.get(key); } @@ -251,7 +251,7 @@ public class LootManager extends Function { } } - private void setActions(ConfigurationSection section, Loot loot) { + private void setActions(ConfigurationSection section, LootImpl loot) { loot.setSuccessActions(ConfigUtils.getActions(section.getConfigurationSection("action.success"), loot.getNick())); loot.setFailureActions(ConfigUtils.getActions(section.getConfigurationSection("action.failure"), loot.getNick())); loot.setHookActions(ConfigUtils.getActions(section.getConfigurationSection("action.hook"), loot.getNick())); @@ -259,7 +259,7 @@ public class LootManager extends Function { setSuccessAmountAction(section.getConfigurationSection("action.success-times"), loot); } - private void setSuccessAmountAction(ConfigurationSection section, Loot loot) { + private void setSuccessAmountAction(ConfigurationSection section, LootImpl loot) { if (section != null) { HashMap actionMap = new HashMap<>(); for (String amount : section.getKeys(false)) { @@ -286,28 +286,28 @@ public class LootManager extends Function { return gameConfigs; } - public HashMap getWaterLoots() { + public HashMap getWaterLoots() { return waterLoots; } - public HashMap getLavaLoots() { + public HashMap getLavaLoots() { return lavaLoots; } - public ArrayList getAllLoots() { - ArrayList loots = new ArrayList<>(waterLoots.values()); + public ArrayList getAllLoots() { + ArrayList loots = new ArrayList<>(waterLoots.values()); loots.addAll(getLavaLoots().values()); return loots; } public ArrayList getAllKeys() { ArrayList loots = new ArrayList<>(); - for (Map.Entry en : waterLoots.entrySet()) { + for (Map.Entry en : waterLoots.entrySet()) { if (en.getValue() instanceof DroppedItem) { loots.add(en.getKey()); } } - for (Map.Entry en : lavaLoots.entrySet()) { + for (Map.Entry en : lavaLoots.entrySet()) { if (en.getValue() instanceof DroppedItem) { loots.add(en.getKey()); } @@ -321,7 +321,7 @@ public class LootManager extends Function { } @NotNull - public Loot getVanilla_loot() { + public LootImpl getVanilla_loot() { return vanilla_loot; } } diff --git a/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java b/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java index 2e4c0f89..2e654676 100644 --- a/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/StatisticsManager.java @@ -19,7 +19,7 @@ package net.momirealms.customfishing.manager; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.data.PlayerStatisticsData; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.listener.JoinQuitListener; import net.momirealms.customfishing.object.DataFunction; import org.bukkit.Bukkit; @@ -94,7 +94,7 @@ public class StatisticsManager extends DataFunction { } } - public void addFishAmount(UUID uuid, Loot loot, int amount) { + public void addFishAmount(UUID uuid, LootImpl loot, int amount) { PlayerStatisticsData statisticsData = statisticsDataMap.get(uuid); if (statisticsData != null) { statisticsData.addFishAmount(loot, uuid, amount); diff --git a/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java b/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java index 542be5bb..b140da5e 100644 --- a/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java +++ b/src/main/java/net/momirealms/customfishing/util/ItemStackUtils.java @@ -25,7 +25,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.fishing.loot.DroppedItem; import net.momirealms.customfishing.fishing.loot.Item; -import net.momirealms.customfishing.fishing.loot.Loot; +import net.momirealms.customfishing.fishing.loot.LootImpl; import net.momirealms.customfishing.manager.ConfigManager; import net.momirealms.customfishing.object.LeveledEnchantment; import org.bukkit.Material; @@ -172,7 +172,7 @@ public class ItemStackUtils { } public static int givePlayerLoot(Player player, String key, int amount){ - Loot loot = CustomFishing.getInstance().getLootManager().getLoot(key); + LootImpl loot = CustomFishing.getInstance().getLootManager().getLoot(key); if (!(loot instanceof DroppedItem droppedItem)) return 0; ItemStack itemStack = CustomFishing.getInstance().getFishingManager().getCustomFishingLootItemStack(droppedItem, player); if (itemStack.getType() == Material.AIR) return 0; diff --git a/src/main/resources/contents/baits/default.yml b/src/main/resources/contents/baits/default.yml index f3d65af2..77214d4a 100644 --- a/src/main/resources/contents/baits/default.yml +++ b/src/main/resources/contents/baits/default.yml @@ -10,23 +10,13 @@ simple_bait: time: 0.85 difficulty: 1 -wild_bait: - material: paper - display: - name: 'Wild Bait' - lore: - - 'Decreases fishing time by 30%.' - custom-model-data: 50002 - effect: - time: 0.7 - magnet_bait: material: paper display: name: 'Magnet Bait' lore: - 'Increases the probability of better loots by 15%.' - custom-model-data: 50003 + custom-model-data: 50002 effect: weight-multiply: silver: 1.15 @@ -42,4 +32,14 @@ magnet_bait: - nature_fishing_cane - silver_fishing_rod - golden_fishing_rod - - star_fishing_rod \ No newline at end of file + - star_fishing_rod + +wild_bait: + material: paper + display: + name: 'Wild Bait' + lore: + - 'Decreases fishing time by 30%.' + custom-model-data: 50003 + effect: + time: 0.7 \ No newline at end of file