9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-23 08:59:34 +00:00

1.3.0-beta-7

This commit is contained in:
Xiao-MoMi
2023-03-14 21:09:39 +08:00
parent 62a0a5015a
commit cc9e59a576
41 changed files with 589 additions and 370 deletions

View File

@@ -4,7 +4,7 @@ plugins {
} }
group = 'net.momirealms' group = 'net.momirealms'
version = '1.3.0-beta-5' version = '1.3.0-beta-7'
repositories { repositories {
mavenCentral() mavenCentral()
@@ -22,6 +22,7 @@ repositories {
dependencies { dependencies {
compileOnly fileTree(dir:'libs',includes:['*.jar']) compileOnly fileTree(dir:'libs',includes:['*.jar'])
implementation fileTree(dir:'libs',includes:['BiomeAPI.jar']) implementation fileTree(dir:'libs',includes:['BiomeAPI.jar'])
compileOnly('com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT')
compileOnly('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT') compileOnly('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT')
compileOnly('com.github.angeschossen:LandsAPI:6.26.18') compileOnly('com.github.angeschossen:LandsAPI:6.26.18')
compileOnly('com.zaxxer:HikariCP:5.0.1') compileOnly('com.zaxxer:HikariCP:5.0.1')

Binary file not shown.

Binary file not shown.

View File

@@ -1 +0,0 @@
https://polymart.org/resource/customcrops.2625

Binary file not shown.

Binary file not shown.

View File

@@ -64,6 +64,7 @@ public final class CustomFishing extends JavaPlugin {
this.versionHelper = new VersionHelper(this); this.versionHelper = new VersionHelper(this);
this.fishingManager = new FishingManager(this); this.fishingManager = new FishingManager(this);
this.dataManager = new DataManager(this); this.dataManager = new DataManager(this);
this.statisticsManager = new StatisticsManager(this);
this.integrationManager = new IntegrationManager(this); this.integrationManager = new IntegrationManager(this);
this.competitionManager = new CompetitionManager(this); this.competitionManager = new CompetitionManager(this);
this.effectManager = new EffectManager(this); this.effectManager = new EffectManager(this);
@@ -73,7 +74,6 @@ public final class CustomFishing extends JavaPlugin {
this.sellManager = new SellManager(this); this.sellManager = new SellManager(this);
this.bagDataManager = new BagDataManager(this); this.bagDataManager = new BagDataManager(this);
this.offsetManager = new OffsetManager(this); this.offsetManager = new OffsetManager(this);
this.statisticsManager = new StatisticsManager(this);
this.reload(); this.reload();
this.registerCommands(); this.registerCommands();
this.registerQuests(); this.registerQuests();

View File

@@ -23,13 +23,13 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class FishHookEvent extends PlayerEvent implements Cancellable { public class MiniGameStartEvent extends PlayerEvent implements Cancellable {
private boolean cancelled; private boolean cancelled;
private int difficulty; private int difficulty;
private static final HandlerList handlerList = new HandlerList(); private static final HandlerList handlerList = new HandlerList();
public FishHookEvent(@NotNull Player who, int difficulty) { public MiniGameStartEvent(@NotNull Player who, int difficulty) {
super(who); super(who);
this.cancelled = false; this.cancelled = false;
this.difficulty = difficulty; this.difficulty = difficulty;

View File

@@ -41,6 +41,10 @@ public class RodCastEvent extends PlayerEvent implements Cancellable {
return this.isCancelled; return this.isCancelled;
} }
/**
* If cancelled, PlayerFishEvent would also be cancelled
* @param cancel true if you wish to cancel this event
*/
@Override @Override
public void setCancelled(boolean cancel) { public void setCancelled(boolean cancel) {
this.isCancelled = cancel; this.isCancelled = cancel;

View File

@@ -32,7 +32,6 @@ public class TotemActivationEvent extends PlayerEvent implements Cancellable {
private final Location location; private final Location location;
private static final HandlerList handlerList = new HandlerList(); private static final HandlerList handlerList = new HandlerList();
public TotemActivationEvent(@NotNull Player who, Location location, TotemConfig totem) { public TotemActivationEvent(@NotNull Player who, Location location, TotemConfig totem) {
super(who); super(who);
this.cancelled = false; this.cancelled = false;

View File

@@ -74,7 +74,7 @@ public class BaitCommand extends AbstractSubCommand {
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.notOnline.replace("{Player}", args.get(1))); AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.notOnline.replace("{Player}", args.get(1)));
return true; return true;
} }
if (!CustomFishing.getInstance().getEffectManager().getBaitItems().containsKey(args.get(1))) { if (!CustomFishing.getInstance().getEffectManager().getBaitItems().containsKey(args.get(2))) {
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.itemNotExist); AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.itemNotExist);
return true; return true;
} }

View File

@@ -32,27 +32,33 @@ import java.util.stream.Collectors;
public class PlayerStatisticsData { public class PlayerStatisticsData {
private final ConcurrentHashMap<String, Integer> amountMap; private final ConcurrentHashMap<String, Integer> amountMap;
private final LootManager lootManager; private int total_catch_amount;
public PlayerStatisticsData() { public PlayerStatisticsData() {
this.amountMap = new ConcurrentHashMap<>(); this.amountMap = new ConcurrentHashMap<>();
this.lootManager = CustomFishing.getInstance().getLootManager(); this.total_catch_amount = 0;
} }
public PlayerStatisticsData(ConfigurationSection section) { public PlayerStatisticsData(ConfigurationSection section) {
this.lootManager = CustomFishing.getInstance().getLootManager();
this.amountMap = new ConcurrentHashMap<>(); this.amountMap = new ConcurrentHashMap<>();
this.total_catch_amount = 0;
for (String key : section.getKeys(false)) { for (String key : section.getKeys(false)) {
amountMap.put(key, section.getInt(key)); int amount = section.getInt(key);
total_catch_amount += amount;
amountMap.put(key, amount);
} }
} }
public PlayerStatisticsData(String longText) { public PlayerStatisticsData(String longText) {
this.lootManager = CustomFishing.getInstance().getLootManager(); this.total_catch_amount = 0;
this.amountMap = (ConcurrentHashMap<String, Integer>) Arrays.stream(longText.split(";")) this.amountMap = (ConcurrentHashMap<String, Integer>) Arrays.stream(longText.split(";"))
.map(element -> element.split(":")) .map(element -> element.split(":"))
.filter(pair -> pair.length == 2) .filter(pair -> pair.length == 2)
.collect(Collectors.toConcurrentMap(pair -> pair[0], pair -> Integer.parseInt(pair[1]))); .collect(Collectors.toConcurrentMap(pair -> pair[0], pair -> {
int amount = Integer.parseInt(pair[1]);
total_catch_amount += amount;
return amount;
}));
} }
public String getLongText() { public String getLongText() {
@@ -63,14 +69,19 @@ public class PlayerStatisticsData {
return joiner.toString(); return joiner.toString();
} }
public void addFishAmount(Loot loot, int amount, UUID uuid) { public void addFishAmount(Loot loot, UUID uuid, int amount) {
Integer previous = amountMap.get(loot.getKey()); Integer previous = amountMap.get(loot.getKey());
if (previous == null) previous = 0; if (previous == null) previous = 0;
int after = previous + amount; int after = previous + amount;
amountMap.put(loot.getKey(), after); amountMap.put(loot.getKey(), after);
total_catch_amount += amount;
Player player = Bukkit.getPlayer(uuid); Player player = Bukkit.getPlayer(uuid);
if (player == null) return; if (player == null) return;
HashMap<Integer, Action[]> actionMap = loot.getSuccessTimesActions(); doSuccessTimesAction(previous, after, player, loot);
}
private void doSuccessTimesAction(Integer previous, int after, Player player, Loot vanilla) {
HashMap<Integer, Action[]> actionMap = vanilla.getSuccessTimesActions();
if (actionMap != null) { if (actionMap != null) {
for (Map.Entry<Integer, Action[]> entry : actionMap.entrySet()) { for (Map.Entry<Integer, Action[]> entry : actionMap.entrySet()) {
if (entry.getKey() > previous && entry.getKey() <= after) { if (entry.getKey() > previous && entry.getKey() <= after) {
@@ -97,7 +108,7 @@ public class PlayerStatisticsData {
* @return percent * @return percent
*/ */
public double getCategoryUnlockProgress(String category) { public double getCategoryUnlockProgress(String category) {
List<String> categories = lootManager.getCategories(category); List<String> categories = CustomFishing.getInstance().getLootManager().getCategories(category);
if (categories == null) return -1d; if (categories == null) return -1d;
double total = categories.size(); double total = categories.size();
double unlocked = 0; double unlocked = 0;
@@ -110,7 +121,7 @@ public class PlayerStatisticsData {
} }
public int getCategoryTotalFishAmount(String category) { public int getCategoryTotalFishAmount(String category) {
List<String> categories = lootManager.getCategories(category); List<String> categories = CustomFishing.getInstance().getLootManager().getCategories(category);
if (categories == null) return -1; if (categories == null) return -1;
int total = 0; int total = 0;
for (String value : categories) { for (String value : categories) {
@@ -130,4 +141,8 @@ public class PlayerStatisticsData {
public void setData(String key, int value) { public void setData(String key, int value) {
amountMap.put(key, value); amountMap.put(key, value);
} }
public int getTotalCatchAmount() {
return total_catch_amount;
}
} }

View File

@@ -29,6 +29,10 @@ public class ModeThreeBar extends FishingBar {
private final int fish_offset; private final int fish_offset;
private final int fish_start_position; private final int fish_start_position;
private final int success_position; private final int success_position;
private final double ultimate_strain;
private final double normal_increase;
private final double struggling_increase;
private final double strain_loss;
public ModeThreeBar(ConfigurationSection section) { public ModeThreeBar(ConfigurationSection section) {
super(section); super(section);
@@ -40,6 +44,10 @@ public class ModeThreeBar extends FishingBar {
this.fish_offset = section.getInt("arguments.fish-offset"); this.fish_offset = section.getInt("arguments.fish-offset");
this.fish_start_position = section.getInt("arguments.fish-start-position"); this.fish_start_position = section.getInt("arguments.fish-start-position");
this.success_position = section.getInt("arguments.success-position"); this.success_position = section.getInt("arguments.success-position");
this.ultimate_strain = section.getDouble("arguments.ultimate-strain", 50);
this.normal_increase = section.getDouble("arguments.normal-pull-strain-increase", 1);
this.struggling_increase = section.getDouble("arguments.struggling-strain-increase", 2);
this.strain_loss = section.getDouble("arguments.loosening-strain-loss", 2);
} }
public String getFish_image() { public String getFish_image() {
@@ -73,4 +81,20 @@ public class ModeThreeBar extends FishingBar {
public String[] getStruggling_fish_image() { public String[] getStruggling_fish_image() {
return struggling_fish_image; return struggling_fish_image;
} }
public double getUltimate_strain() {
return ultimate_strain;
}
public double getNormal_increase() {
return normal_increase;
}
public double getStruggling_increase() {
return struggling_increase;
}
public double getStrain_loss() {
return strain_loss;
}
} }

View File

@@ -32,6 +32,9 @@ public class ModeTwoBar extends FishingBar {
private final int fish_icon_width; private final int fish_icon_width;
private final String[] progress; private final String[] progress;
private final double punishment; private final double punishment;
private final double water_resistance;
private final double pulling_strength;
private final double loosening_loss;
public ModeTwoBar(ConfigurationSection section) { public ModeTwoBar(ConfigurationSection section) {
super(section); super(section);
@@ -44,6 +47,9 @@ public class ModeTwoBar extends FishingBar {
this.fish_icon_width = section.getInt("arguments.fish-icon-width"); this.fish_icon_width = section.getInt("arguments.fish-icon-width");
this.punishment = section.getDouble("arguments.punishment"); this.punishment = section.getDouble("arguments.punishment");
this.progress = section.getStringList("progress").toArray(new String[0]); this.progress = section.getStringList("progress").toArray(new String[0]);
this.water_resistance = section.getDouble("arguments.water-resistance", 0.15);
this.pulling_strength = section.getDouble("arguments.pulling-strength", 0.45);
this.loosening_loss = section.getDouble("arguments.loosening-strength-loss", 0.3);
} }
public int getRandomTimeRequirement() { public int getRandomTimeRequirement() {
@@ -81,4 +87,16 @@ public class ModeTwoBar extends FishingBar {
public double getPunishment() { public double getPunishment() {
return punishment; return punishment;
} }
public double getWater_resistance() {
return water_resistance;
}
public double getPulling_strength() {
return pulling_strength;
}
public double getLoosening_loss() {
return loosening_loss;
}
} }

View File

@@ -31,7 +31,7 @@ import java.util.Objects;
public class Item { public class Item {
private final String key; private final String key;
private int amount; private final int amount;
private final Material material; private final Material material;
private String name; private String name;
private List<String> lore; private List<String> lore;
@@ -42,6 +42,8 @@ public class Item {
private List<LeveledEnchantment> enchantment; private List<LeveledEnchantment> enchantment;
private Map<String, Object> nbt; private Map<String, Object> nbt;
private String totem; private String totem;
private boolean headStackable;
private String[] cfTag;
public Item(Material material, String key) { public Item(Material material, String key) {
this.material = material; this.material = material;
@@ -80,6 +82,7 @@ public class Item {
} }
if (section.contains("head64")) { if (section.contains("head64")) {
this.setHead64(section.getString("head64")); this.setHead64(section.getString("head64"));
this.setHeadStackable(section.getBoolean("head-stackable", false));
} }
if (section.contains("totem")) { if (section.contains("totem")) {
this.setTotem(section.getString("totem")); this.setTotem(section.getString("totem"));
@@ -170,6 +173,22 @@ public class Item {
this.totem = totem; this.totem = totem;
} }
public boolean isHeadStackable() {
return headStackable;
}
public void setHeadStackable(boolean headStackable) {
this.headStackable = headStackable;
}
public String[] getCfTag() {
return cfTag;
}
public void setCfTag(String[] cfTag) {
this.cfTag = cfTag;
}
public Item cloneWithPrice(double price){ public Item cloneWithPrice(double price){
Item newItem = new Item(this.material, this.key); Item newItem = new Item(this.material, this.key);
if (this.lore != null){ if (this.lore != null){

View File

@@ -59,17 +59,17 @@ public class ModeThreeGame extends FishingGame {
} }
if (player.isSneaking()) { if (player.isSneaking()) {
if (struggling_time > 0) { if (struggling_time > 0) {
strain += (2 + ((double) difficulty / 5)); strain += (modeThreeBar.getStruggling_increase() + ((double) difficulty / 5));
fish_position -= 1; fish_position -= 1;
} }
else { else {
strain += 1; strain += modeThreeBar.getNormal_increase();
fish_position -= 2; fish_position -= 2;
} }
} }
else { else {
fish_position++; fish_position++;
strain -= 2; strain -= modeThreeBar.getStrain_loss();
} }
if (fish_position < modeThreeBar.getSuccess_position() - modeThreeBar.getFish_icon_width() - 1) { if (fish_position < modeThreeBar.getSuccess_position() - modeThreeBar.getFish_icon_width() - 1) {
cancel(); cancel();
@@ -82,7 +82,7 @@ public class ModeThreeGame extends FishingGame {
fishingManager.removeFishingPlayer(player); fishingManager.removeFishingPlayer(player);
return; return;
} }
if (fish_position + modeThreeBar.getFish_icon_width() > modeThreeBar.getBar_effective_width() || strain > 50) { if (fish_position + modeThreeBar.getFish_icon_width() > modeThreeBar.getBar_effective_width() || strain > modeThreeBar.getUltimate_strain()) {
cancel(); cancel();
FishHook fishHook = fishingManager.getBobber(player); FishHook fishHook = fishingManager.getBobber(player);
if (fishHook != null) { if (fishHook != null) {
@@ -102,10 +102,9 @@ public class ModeThreeGame extends FishingGame {
+ (struggling_time > 0 ? modeThreeBar.getStruggling_fish_image()[timer] : modeThreeBar.getFish_image()) + (struggling_time > 0 ? modeThreeBar.getStruggling_fish_image()[timer] : modeThreeBar.getFish_image())
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getBar_effective_width() - fish_position - modeThreeBar.getFish_icon_width()) + "</font>" + "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getBar_effective_width() - fish_position - modeThreeBar.getFish_icon_width()) + "</font>"
+ "</font>"; + "</font>";
if (strain > 50) strain = 50; strain = Math.max(0, Math.min(strain, modeThreeBar.getUltimate_strain()));
if (strain < 0) strain = 0;
AdventureUtil.playerTitle(player, AdventureUtil.playerTitle(player,
title.replace("{strain}", modeThreeBar.getStrain()[(int) ((strain / 50) * modeThreeBar.getStrain().length)]) title.replace("{strain}", modeThreeBar.getStrain()[(int) ((strain / modeThreeBar.getUltimate_strain()) * modeThreeBar.getStrain().length)])
, bar,0,500,0 , bar,0,500,0
); );
} }

View File

@@ -95,8 +95,7 @@ public class ModeTwoGame extends FishingGame {
+ modeTwoBar.getFish_image() + modeTwoBar.getFish_image()
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getBar_effective_width() - fish_position - modeTwoBar.getFish_icon_width() + 1)) + "</font>" + "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars((int) (modeTwoBar.getBar_effective_width() - fish_position - modeTwoBar.getFish_icon_width() + 1)) + "</font>"
+ "</font>"; + "</font>";
if (hold_time > time_requirement) hold_time = time_requirement; hold_time = Math.max(0, Math.min(hold_time, time_requirement));
if (hold_time < 0) hold_time = 0;
AdventureUtil.playerTitle(player, AdventureUtil.playerTitle(player,
title.replace("{progress}", modeTwoBar.getProgress()[(int) ((hold_time / time_requirement) * modeTwoBar.getProgress().length)]) title.replace("{progress}", modeTwoBar.getProgress()[(int) ((hold_time / time_requirement) * modeTwoBar.getProgress().length)])
, bar,0,500,0 , bar,0,500,0
@@ -114,21 +113,21 @@ public class ModeTwoGame extends FishingGame {
private void fraction() { private void fraction() {
if (judgement_velocity > 0) { if (judgement_velocity > 0) {
judgement_velocity -= 0.15; judgement_velocity -= modeTwoBar.getWater_resistance();
if (judgement_velocity < 0) judgement_velocity = 0; if (judgement_velocity < 0) judgement_velocity = 0;
} }
else { else {
judgement_velocity += 0.15; judgement_velocity += modeTwoBar.getWater_resistance();
if (judgement_velocity > 0) judgement_velocity = 0; if (judgement_velocity > 0) judgement_velocity = 0;
} }
} }
private void reduceV() { private void reduceV() {
fish_velocity -= 0.3; fish_velocity -= modeTwoBar.getLoosening_loss();
} }
private void addV() { private void addV() {
fish_velocity += 0.45; fish_velocity += modeTwoBar.getPulling_strength();
} }
private void calibrate() { private void calibrate() {

View File

@@ -20,6 +20,6 @@ package net.momirealms.customfishing.fishing.requirements;
import net.momirealms.customfishing.fishing.FishingCondition; import net.momirealms.customfishing.fishing.FishingCondition;
public interface RequirementInterface { public interface RequirementInterface {
boolean isConditionMet(FishingCondition fishingCondition);
boolean isConditionMet(FishingCondition fishingCondition);
} }

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.enchantment; package net.momirealms.customfishing.integration.enchantment;
import net.advancedplugins.ae.api.AEAPI; import net.advancedplugins.ae.api.AEAPI;

View File

@@ -1,3 +1,20 @@
/*
* 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.integration.enchantment; package net.momirealms.customfishing.integration.enchantment;
import net.momirealms.customfishing.integration.EnchantmentInterface; import net.momirealms.customfishing.integration.EnchantmentInterface;

View File

@@ -21,6 +21,8 @@ import com.willfp.eco.core.items.CustomItem;
import de.tr7zw.changeme.nbtapi.NBTCompound; import de.tr7zw.changeme.nbtapi.NBTCompound;
import de.tr7zw.changeme.nbtapi.NBTItem; import de.tr7zw.changeme.nbtapi.NBTItem;
import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.fishing.loot.Item;
import net.momirealms.customfishing.util.ItemStackUtil;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -30,7 +32,7 @@ public class EcoItemRegister {
public static void registerItems() { public static void registerItems() {
// Rods // Rods
for (Map.Entry<String, ItemStack> entry : CustomFishing.getInstance().getEffectManager().getRodItems().entrySet()) { for (Map.Entry<String, Item> entry : CustomFishing.getInstance().getEffectManager().getRodItems().entrySet()) {
new CustomItem( new CustomItem(
new NamespacedKey(CustomFishing.getInstance(), "rod_" + entry.getKey()), new NamespacedKey(CustomFishing.getInstance(), "rod_" + entry.getKey()),
itemStack -> { itemStack -> {
@@ -44,11 +46,11 @@ public class EcoItemRegister {
return false; return false;
} }
}, },
entry.getValue() ItemStackUtil.getFromItem(entry.getValue())
).register(); ).register();
} }
// Baits // Baits
for (Map.Entry<String, ItemStack> entry : CustomFishing.getInstance().getEffectManager().getBaitItems().entrySet()) { for (Map.Entry<String, Item> entry : CustomFishing.getInstance().getEffectManager().getBaitItems().entrySet()) {
new CustomItem( new CustomItem(
new NamespacedKey(CustomFishing.getInstance(), "bait_" + entry.getKey()), new NamespacedKey(CustomFishing.getInstance(), "bait_" + entry.getKey()),
itemStack -> { itemStack -> {
@@ -62,11 +64,11 @@ public class EcoItemRegister {
return false; return false;
} }
}, },
entry.getValue() ItemStackUtil.getFromItem(entry.getValue())
).register(); ).register();
} }
// Utils // Utils
for (Map.Entry<String, ItemStack> entry : CustomFishing.getInstance().getEffectManager().getUtilItems().entrySet()) { for (Map.Entry<String, Item> entry : CustomFishing.getInstance().getEffectManager().getUtilItems().entrySet()) {
new CustomItem( new CustomItem(
new NamespacedKey(CustomFishing.getInstance(), "util_" + entry.getKey()), new NamespacedKey(CustomFishing.getInstance(), "util_" + entry.getKey()),
itemStack -> { itemStack -> {
@@ -80,7 +82,7 @@ public class EcoItemRegister {
return false; return false;
} }
}, },
entry.getValue() ItemStackUtil.getFromItem(entry.getValue())
).register(); ).register();
} }
} }

View File

@@ -35,7 +35,7 @@ public class MMOItemsItemImpl implements ItemInterface {
if (!material.startsWith("MMOItems:")) return null; if (!material.startsWith("MMOItems:")) return null;
material = material.substring(9); material = material.substring(9);
String[] split = StringUtils.split(material, ":"); String[] split = StringUtils.split(material, ":");
MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1]); MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1].toUpperCase());
return mmoItem == null ? null : mmoItem.newBuilder().build(); return mmoItem == null ? null : mmoItem.newBuilder().build();
} }

View File

@@ -1,5 +1,23 @@
/*
* 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.integration.job; package net.momirealms.customfishing.integration.job;
import com.willfp.ecojobs.EcoJobsPlugin;
import com.willfp.ecojobs.api.EcoJobsAPI; import com.willfp.ecojobs.api.EcoJobsAPI;
import com.willfp.ecojobs.jobs.Job; import com.willfp.ecojobs.jobs.Job;
import com.willfp.ecojobs.jobs.Jobs; import com.willfp.ecojobs.jobs.Jobs;
@@ -8,18 +26,12 @@ import org.bukkit.entity.Player;
public class EcoJobsImpl implements JobInterface { public class EcoJobsImpl implements JobInterface {
private final EcoJobsAPI api;
public EcoJobsImpl() {
this.api = EcoJobsAPI.getInstance();
}
@Override @Override
public void addXp(Player player, double amount) { public void addXp(Player player, double amount) {
Job job = api.getActiveJob(player); Job job = EcoJobsAPI.getInstance().getActiveJob(player);
if (job == null) return; if (job == null) return;
if (job.getId().equals("fisherman")) { if (job.getId().equals("fisherman")) {
api.giveJobExperience(player, job, amount); EcoJobsAPI.getInstance().giveJobExperience(player, job, amount);
} }
} }
@@ -27,6 +39,6 @@ public class EcoJobsImpl implements JobInterface {
public int getLevel(Player player) { public int getLevel(Player player) {
Job job = Jobs.getByID("fisherman"); Job job = Jobs.getByID("fisherman");
if (job == null) return 0; if (job == null) return 0;
return api.getJobLevel(player, job); return EcoJobsAPI.getInstance().getJobLevel(player, job);
} }
} }

View File

@@ -0,0 +1,13 @@
package net.momirealms.customfishing.integration.mob;
import net.momirealms.customfishing.fishing.loot.Mob;
import net.momirealms.customfishing.integration.MobInterface;
import org.bukkit.Location;
public class EliteMobsMobImpl implements MobInterface {
@Override
public void summon(Location playerLoc, Location summonLoc, Mob mob) {
}
}

View File

@@ -2,16 +2,17 @@ package net.momirealms.customfishing.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.manager.StatisticsManager;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class StatisticsPapi extends PlaceholderExpansion { public class StatisticsPapi extends PlaceholderExpansion {
private final CustomFishing plugin; private final StatisticsManager statisticsManager;
public StatisticsPapi(CustomFishing plugin) { public StatisticsPapi(CustomFishing plugin) {
this.plugin = plugin; this.statisticsManager = plugin.getStatisticsManager();
} }
@Override @Override
@@ -26,7 +27,7 @@ public class StatisticsPapi extends PlaceholderExpansion {
@Override @Override
public @NotNull String getVersion() { public @NotNull String getVersion() {
return "1.0"; return "1.1";
} }
@Override @Override
@@ -38,23 +39,26 @@ public class StatisticsPapi extends PlaceholderExpansion {
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) { public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
String[] args = params.split("_", 2); String[] args = params.split("_", 2);
switch (args[0]) { switch (args[0]) {
case "total" -> {
return String.valueOf(statisticsManager.getTotalFishAmount(player.getUniqueId()));
}
case "amount" -> { case "amount" -> {
if (args[1].equals("")) return "lack args"; if (args[1].equals("")) return "lack args";
return String.valueOf(plugin.getStatisticsManager().getFishAmount(player.getUniqueId(), args[1])); return String.valueOf(statisticsManager.getFishAmount(player.getUniqueId(), args[1]));
} }
case "hascaught" -> { case "hascaught" -> {
if (args[1].equals("")) return "lack args"; if (args[1].equals("")) return "lack args";
return String.valueOf(plugin.getStatisticsManager().hasFished(player.getUniqueId(), args[1])); return String.valueOf(statisticsManager.hasFished(player.getUniqueId(), args[1]));
} }
case "category" -> { case "category" -> {
String[] moreArgs = args[1].split("_", 2); String[] moreArgs = args[1].split("_", 2);
if (moreArgs[1].equals("")) return "lack args"; if (moreArgs[1].equals("")) return "lack args";
switch (moreArgs[0]) { switch (moreArgs[0]) {
case "total" -> { case "total" -> {
return String.valueOf(plugin.getStatisticsManager().getCategoryTotalFishAmount(player.getUniqueId(), moreArgs[1])); return String.valueOf(statisticsManager.getCategoryTotalFishAmount(player.getUniqueId(), moreArgs[1]));
} }
case "progress" -> { case "progress" -> {
String progress = String.format("%.1f", plugin.getStatisticsManager().getCategoryUnlockProgress(player.getUniqueId(), moreArgs[1])); String progress = String.format("%.1f", statisticsManager.getCategoryUnlockProgress(player.getUniqueId(), moreArgs[1]));
return progress.equals("100.0") ? "100" : progress; return progress.equals("100.0") ? "100" : progress;
} }
} }

View File

@@ -46,7 +46,6 @@ public class ConfigManager {
public static boolean convertMMOItems; public static boolean convertMMOItems;
public static boolean preventPickUp; public static boolean preventPickUp;
public static boolean enableFishingBag; public static boolean enableFishingBag;
public static boolean otherLootHasFishingBar;
public static boolean allRodsFishInLava; public static boolean allRodsFishInLava;
public static boolean enableSuccessTitle; public static boolean enableSuccessTitle;
public static String[] successTitle; public static String[] successTitle;
@@ -101,7 +100,6 @@ public class ConfigManager {
private static void loadMechanics(YamlConfiguration config) { private static void loadMechanics(YamlConfiguration config) {
disableBar = config.getBoolean("mechanics.disable-bar-mechanic", false); disableBar = config.getBoolean("mechanics.disable-bar-mechanic", false);
instantBar = config.getBoolean("mechanics.instant-bar", false); instantBar = config.getBoolean("mechanics.instant-bar", false);
otherLootHasFishingBar = config.getBoolean("mechanics.other-loots.fishing-bar", true);
enableVanillaLoot = config.getBoolean("mechanics.other-loots.vanilla.enable", true); enableVanillaLoot = config.getBoolean("mechanics.other-loots.vanilla.enable", true);
vanillaLootRatio = config.getDouble("mechanics.other-loots.vanilla.ratio", 0.4); vanillaLootRatio = config.getDouble("mechanics.other-loots.vanilla.ratio", 0.4);
enableMcMMOLoot = config.getBoolean("mechanics.other-loots.mcMMO.enable", false); enableMcMMOLoot = config.getBoolean("mechanics.other-loots.mcMMO.enable", false);

View File

@@ -26,6 +26,7 @@ import net.momirealms.customfishing.util.ItemStackUtil;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.File; import java.io.File;
@@ -36,12 +37,13 @@ import java.util.Set;
public class EffectManager extends Function { public class EffectManager extends Function {
private final CustomFishing plugin; private final CustomFishing plugin;
private final HashMap<String, ItemStack> baitItems; private final HashMap<String, Item> baitItems;
private final HashMap<String, Effect> baitEffects; private final HashMap<String, Effect> baitEffects;
private final HashMap<String, ItemStack> rodItems; private final HashMap<String, Item> rodItems;
private final HashMap<String, Effect> rodEffects; private final HashMap<String, Effect> rodEffects;
private final HashMap<String, Item> utilItems;
private final HashMap<String, Effect> utilEffects;
private final HashMap<String, Effect> enchantEffects; private final HashMap<String, Effect> enchantEffects;
private final HashMap<String, ItemStack> utilItems;
public EffectManager(CustomFishing plugin) { public EffectManager(CustomFishing plugin) {
this.plugin = plugin; this.plugin = plugin;
@@ -51,6 +53,7 @@ public class EffectManager extends Function {
this.rodItems = new HashMap<>(); this.rodItems = new HashMap<>();
this.utilItems = new HashMap<>(); this.utilItems = new HashMap<>();
this.enchantEffects = new HashMap<>(); this.enchantEffects = new HashMap<>();
this.utilEffects = new HashMap<>();
} }
@Override @Override
@@ -67,7 +70,9 @@ public class EffectManager extends Function {
this.baitItems.clear(); this.baitItems.clear();
this.rodEffects.clear(); this.rodEffects.clear();
this.rodItems.clear(); this.rodItems.clear();
this.utilItems.clear();
this.enchantEffects.clear(); this.enchantEffects.clear();
this.utilEffects.clear();
} }
private void loadUtil() { private void loadUtil() {
@@ -77,6 +82,7 @@ public class EffectManager extends Function {
plugin.saveResource("utils" + File.separator + "fish_finder.yml", false); plugin.saveResource("utils" + File.separator + "fish_finder.yml", false);
plugin.saveResource("utils" + File.separator + "totem_items.yml", false); plugin.saveResource("utils" + File.separator + "totem_items.yml", false);
plugin.saveResource("utils" + File.separator + "splash_items.yml", false); plugin.saveResource("utils" + File.separator + "splash_items.yml", false);
plugin.saveResource("utils" + File.separator + "fisherman_talismans.yml", false);
} }
File[] files = util_file.listFiles(); File[] files = util_file.listFiles();
if (files == null) return; if (files == null) return;
@@ -85,10 +91,14 @@ public class EffectManager extends Function {
YamlConfiguration config = YamlConfiguration.loadConfiguration(file); YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
Set<String> keys = config.getKeys(false); Set<String> keys = config.getKeys(false);
for (String key : keys) { for (String key : keys) {
ConfigurationSection itemSection = config.getConfigurationSection(key); ConfigurationSection utilSection = config.getConfigurationSection(key);
if (itemSection == null) continue; if (utilSection == null) continue;
Item item = new Item(itemSection, key); Item item = new Item(utilSection, key);
utilItems.put(key, ItemStackUtil.addIdentifier(ItemStackUtil.getFromItem(item), "util", key)); item.setCfTag(new String[] {"util", key});
utilItems.put(key, item);
if (utilSection.contains("effect")) {
utilEffects.put(key, getEffect(utilSection.getConfigurationSection("effect")));
}
} }
} }
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + utilItems.size() + " <gray>util(s)"); AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + utilItems.size() + " <gray>util(s)");
@@ -134,7 +144,8 @@ public class EffectManager extends Function {
ConfigurationSection baitSection = config.getConfigurationSection(key); ConfigurationSection baitSection = config.getConfigurationSection(key);
if (baitSection == null) continue; if (baitSection == null) continue;
Item item = new Item(baitSection, key); Item item = new Item(baitSection, key);
baitItems.put(key, ItemStackUtil.addIdentifier(ItemStackUtil.getFromItem(item), "bait", key)); item.setCfTag(new String[] {"bait", key});
baitItems.put(key, item);
if (baitSection.contains("effect")) { if (baitSection.contains("effect")) {
baitEffects.put(key, getEffect(baitSection.getConfigurationSection("effect"))); baitEffects.put(key, getEffect(baitSection.getConfigurationSection("effect")));
} }
@@ -160,7 +171,8 @@ public class EffectManager extends Function {
if (rodSection == null) continue; if (rodSection == null) continue;
rodSection.set("material", "fishing_rod"); rodSection.set("material", "fishing_rod");
Item item = new Item(rodSection, key); Item item = new Item(rodSection, key);
rodItems.put(key, ItemStackUtil.addIdentifier(ItemStackUtil.getFromItem(item), "rod", key)); item.setCfTag(new String[] {"rod", key});
rodItems.put(key, item);
if (rodSection.contains("effect")) { if (rodSection.contains("effect")) {
rodEffects.put(key, getEffect(rodSection.getConfigurationSection("effect"))); rodEffects.put(key, getEffect(rodSection.getConfigurationSection("effect")));
} }
@@ -196,11 +208,12 @@ public class EffectManager extends Function {
} }
@Nullable @Nullable
public ItemStack getBaitItem(String key) { public Item getBaitItem(String key) {
return baitItems.get(key); return baitItems.get(key);
} }
public HashMap<String, ItemStack> getBaitItems() { @NotNull
public HashMap<String, Item> getBaitItems() {
return baitItems; return baitItems;
} }
@@ -209,16 +222,18 @@ public class EffectManager extends Function {
return baitEffects.get(key); return baitEffects.get(key);
} }
@NotNull
public HashMap<String, Effect> getBaitEffects() { public HashMap<String, Effect> getBaitEffects() {
return baitEffects; return baitEffects;
} }
@Nullable @Nullable
public ItemStack getRodItem(String key) { public Item getRodItem(String key) {
return rodItems.get(key); return rodItems.get(key);
} }
public HashMap<String, ItemStack> getRodItems() { @NotNull
public HashMap<String, Item> getRodItems() {
return rodItems; return rodItems;
} }
@@ -227,6 +242,7 @@ public class EffectManager extends Function {
return rodEffects.get(key); return rodEffects.get(key);
} }
@NotNull
public HashMap<String, Effect> getRodEffects() { public HashMap<String, Effect> getRodEffects() {
return rodEffects; return rodEffects;
} }
@@ -236,16 +252,28 @@ public class EffectManager extends Function {
return enchantEffects.get(key); return enchantEffects.get(key);
} }
@NotNull
public HashMap<String, Effect> getEnchantEffects() { public HashMap<String, Effect> getEnchantEffects() {
return enchantEffects; return enchantEffects;
} }
@Nullable @Nullable
public ItemStack getUtilItem(String key) { public Item getUtilItem(String key) {
return utilItems.get(key); return utilItems.get(key);
} }
public HashMap<String, ItemStack> getUtilItems() { @NotNull
public HashMap<String, Item> getUtilItems() {
return utilItems; return utilItems;
} }
@NotNull
public HashMap<String, Effect> getUtilEffects() {
return utilEffects;
}
@Nullable
public Effect getUtilEffect(String key) {
return utilEffects.get(key);
}
} }

View File

@@ -162,8 +162,6 @@ public class FishingManager extends Function {
hooks.put(player, fishHook); hooks.put(player, fishHook);
if (isCoolDown(player, 500)) return; if (isCoolDown(player, 500)) return;
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
boolean noSpecialRod = true; boolean noSpecialRod = true;
@@ -192,15 +190,17 @@ public class FishingManager extends Function {
NBTItem mainHandNBTItem = new NBTItem(mainHandItem); NBTItem mainHandNBTItem = new NBTItem(mainHandItem);
NBTCompound nbtCompound = mainHandNBTItem.getCompound("CustomFishing"); NBTCompound nbtCompound = mainHandNBTItem.getCompound("CustomFishing");
if (nbtCompound != null) { if (nbtCompound != null) {
if (nbtCompound.getString("type").equals("rod")) { String type = nbtCompound.getString("type");
Effect rodEffect = plugin.getEffectManager().getRodEffect(nbtCompound.getString("id")); String id = nbtCompound.getString("id");
if (type.equals("rod")) {
Effect rodEffect = plugin.getEffectManager().getRodEffect(id);
if (rodEffect != null){ if (rodEffect != null){
initialEffect.addEffect(rodEffect); initialEffect.addEffect(rodEffect);
noSpecialRod = false; noSpecialRod = false;
} }
} }
else if (nbtCompound.getString("type").equals("bait")) { else if (type.equals("bait")) {
Effect baitEffect = plugin.getEffectManager().getBaitEffect(nbtCompound.getString("id")); Effect baitEffect = plugin.getEffectManager().getBaitEffect(id);
if (baitEffect != null) { if (baitEffect != null) {
initialEffect.addEffect(baitEffect); initialEffect.addEffect(baitEffect);
baitItem = mainHandItem.clone(); baitItem = mainHandItem.clone();
@@ -221,17 +221,19 @@ public class FishingManager extends Function {
NBTItem offHandNBTItem = new NBTItem(offHandItem); NBTItem offHandNBTItem = new NBTItem(offHandItem);
NBTCompound nbtCompound = offHandNBTItem.getCompound("CustomFishing"); NBTCompound nbtCompound = offHandNBTItem.getCompound("CustomFishing");
if (nbtCompound != null) { if (nbtCompound != null) {
if (noBait && nbtCompound.getString("type").equals("bait")) { String type = nbtCompound.getString("type");
Effect baitEffect = plugin.getEffectManager().getBaitEffect(nbtCompound.getString("id")); String id = nbtCompound.getString("id");
if (noBait && type.equals("bait")) {
Effect baitEffect = plugin.getEffectManager().getBaitEffect(id);
if (baitEffect != null){ if (baitEffect != null){
initialEffect.addEffect(baitEffect); initialEffect.addEffect(baitEffect);
offHandItem.setAmount(offHandItem.getAmount() - 1);
baitItem = offHandItem.clone(); baitItem = offHandItem.clone();
offHandItem.setAmount(offHandItem.getAmount() - 1);
noBait = false; noBait = false;
} }
} }
else if (noSpecialRod && nbtCompound.getString("type").equals("rod")) { else if (noSpecialRod && type.equals("rod")) {
Effect rodEffect = plugin.getEffectManager().getRodEffect(nbtCompound.getString("id")); Effect rodEffect = plugin.getEffectManager().getRodEffect(id);
if (rodEffect != null) { if (rodEffect != null) {
initialEffect.addEffect(rodEffect); initialEffect.addEffect(rodEffect);
noSpecialRod = false; noSpecialRod = false;
@@ -247,28 +249,40 @@ public class FishingManager extends Function {
} }
} }
if (ConfigManager.enableFishingBag && noBait) { if (ConfigManager.enableFishingBag) {
Inventory baitInv = plugin.getBagDataManager().getPlayerBagData(player.getUniqueId()); Inventory fishingBag = plugin.getBagDataManager().getPlayerBagData(player.getUniqueId());
if (baitInv != null) { HashSet<String> uniqueUtils = new HashSet<>(4);
for (int i = 0; i < baitInv.getSize(); i++) { if (fishingBag != null) {
ItemStack itemStack = baitInv.getItem(i); for (int i = 0; i < fishingBag.getSize(); i++) {
ItemStack itemStack = fishingBag.getItem(i);
if (itemStack == null || itemStack.getType() == Material.AIR) continue; if (itemStack == null || itemStack.getType() == Material.AIR) continue;
NBTItem nbtItem = new NBTItem(itemStack); NBTItem nbtItem = new NBTItem(itemStack);
NBTCompound cfCompound = nbtItem.getCompound("CustomFishing"); NBTCompound cfCompound = nbtItem.getCompound("CustomFishing");
if (cfCompound == null) continue; if (cfCompound == null) continue;
if (!cfCompound.getString("type").equals("bait")) continue; String type = cfCompound.getString("type");
Effect baitEffect = plugin.getEffectManager().getBaitEffect(cfCompound.getString("id")); String id = cfCompound.getString("id");
if (baitEffect != null) { if (noBait && type.equals("bait")) {
Effect baitEffect = plugin.getEffectManager().getBaitEffect(id);
if (baitEffect != null && itemStack.getAmount() > 0) {
noBait = false;
initialEffect.addEffect(baitEffect); initialEffect.addEffect(baitEffect);
baitItem = itemStack.clone(); baitItem = itemStack.clone();
itemStack.setAmount(itemStack.getAmount() - 1); itemStack.setAmount(itemStack.getAmount() - 1);
break; }
}
else if (type.equals("util")) {
Effect utilEffect = plugin.getEffectManager().getUtilEffect(id);
if (utilEffect != null && !uniqueUtils.contains(id)) {
initialEffect.addEffect(utilEffect);
uniqueUtils.add(id);
}
} }
} }
} }
} }
RodCastEvent rodCastEvent = new RodCastEvent(player, initialEffect); RodCastEvent rodCastEvent = new RodCastEvent(player, initialEffect);
Bukkit.getPluginManager().callEvent(rodCastEvent);
if (rodCastEvent.isCancelled()) { if (rodCastEvent.isCancelled()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@@ -297,7 +311,11 @@ public class FishingManager extends Function {
BobberCheckTask bobberCheckTask = new BobberCheckTask(plugin, player, initialEffect, fishHook, this, lureLevel, entityID); BobberCheckTask bobberCheckTask = new BobberCheckTask(plugin, player, initialEffect, fishHook, this, lureLevel, entityID);
bobberCheckTask.runTaskTimer(plugin, 1, 1); bobberCheckTask.runTaskTimer(plugin, 1, 1);
hookCheckTaskMap.put(player, bobberCheckTask); hookCheckTaskMap.put(player, bobberCheckTask);
}); }
public void onBite(PlayerFishEvent event) {
if (ConfigManager.disableBar || !ConfigManager.instantBar) return;
showBar(event.getPlayer());
} }
public void getNextLoot(Player player, Effect initialEffect, List<Loot> possibleLoots) { public void getNextLoot(Player player, Effect initialEffect, List<Loot> possibleLoots) {
@@ -364,8 +382,9 @@ public class FishingManager extends Function {
} }
FishingGame fishingGame = fishingPlayerMap.remove(player); FishingGame fishingGame = fishingPlayerMap.remove(player);
// if the player is noy playing the game
if (fishingGame == null) { if (fishingGame == null) {
// get his next loot
Loot loot = nextLoot.get(player); Loot loot = nextLoot.get(player);
if (loot == Loot.EMPTY) return; if (loot == Loot.EMPTY) return;
@@ -378,19 +397,20 @@ public class FishingManager extends Function {
noBarWaterReelIn(event); noBarWaterReelIn(event);
return; return;
} }
showFishingBar(player, loot);
} }
else { else {
vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop())); vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
showFishingBar(player, plugin.getLootManager().getVanilla_loot());
} }
event.setCancelled(true); event.setCancelled(true);
showFishingBar(player, loot);
} }
// Is vanilla loot // Is vanilla loot
else { else {
if (ConfigManager.otherLootHasFishingBar) { if (!plugin.getLootManager().getVanilla_loot().isDisableBar()) {
event.setCancelled(true); event.setCancelled(true);
vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop())); vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
showFishingBar(player, null); showFishingBar(player, plugin.getLootManager().getVanilla_loot());
} }
//else vanilla fishing mechanic //else vanilla fishing mechanic
} }
@@ -419,6 +439,51 @@ public class FishingManager extends Function {
} }
} }
public void onReelIn(PlayerFishEvent event) {
final Player player = event.getPlayer();
if (ConfigManager.disableBar) {
noBarLavaReelIn(event);
return;
}
//in fishing game
FishingGame fishingGame = fishingPlayerMap.remove(player);
if (fishingGame != null) {
proceedReelIn(event.getHook().getLocation(), player, fishingGame);
hookCheckTaskMap.remove(player);
return;
}
//not in fishing game
BobberCheckTask bobberCheckTask = hookCheckTaskMap.get(player);
if (bobberCheckTask != null && bobberCheckTask.isHooked()) {
Loot loot = nextLoot.get(player);
if (loot == Loot.EMPTY) return;
if (loot.isDisableBar()) {
noBarLavaReelIn(event);
return;
}
showFishingBar(player, loot);
event.setCancelled(true);
}
}
public void onCaughtEntity(PlayerFishEvent event) {
final Player player = event.getPlayer();
FishingGame fishingGame = fishingPlayerMap.remove(player);
if (fishingGame != null) {
Entity entity = event.getCaught();
if (entity != null && entity.getType() == EntityType.ARMOR_STAND) {
proceedReelIn(event.getHook().getLocation(), player, fishingGame);
}
else {
fishingGame.cancel();
nextEffect.remove(player);
nextLoot.remove(player);
AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.hookOther);
}
}
}
private void noBarWaterReelIn(PlayerFishEvent event) { private void noBarWaterReelIn(PlayerFishEvent event) {
Entity entity = event.getCaught(); Entity entity = event.getCaught();
if (!(entity instanceof Item item)) { if (!(entity instanceof Item item)) {
@@ -495,34 +560,6 @@ public class FishingManager extends Function {
} }
} }
public void onReelIn(PlayerFishEvent event) {
final Player player = event.getPlayer();
if (ConfigManager.disableBar) {
noBarLavaReelIn(event);
return;
}
//in fishing
FishingGame fishingGame = fishingPlayerMap.remove(player);
if (fishingGame != null) {
proceedReelIn(event.getHook().getLocation(), player, fishingGame);
hookCheckTaskMap.remove(player);
return;
}
//not in fishing
BobberCheckTask bobberCheckTask = hookCheckTaskMap.get(player);
if (bobberCheckTask != null && bobberCheckTask.isHooked()) {
Loot loot = nextLoot.get(player);
if (loot == Loot.EMPTY) return;
if (loot.isDisableBar()) {
noBarLavaReelIn(event);
return;
}
showFishingBar(player, loot);
event.setCancelled(true);
}
}
private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier, double sizeMultiplier) { private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier, double sizeMultiplier) {
ItemStack drop = getCustomFishingLootItemStack(droppedItem, player, 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());
@@ -558,16 +595,6 @@ public class FishingManager extends Function {
ItemStackUtil.addRandomDamage(drop); ItemStackUtil.addRandomDamage(drop);
if (ConfigManager.preventPickUp) if (ConfigManager.preventPickUp)
ItemStackUtil.addOwner(drop, player.getName()); ItemStackUtil.addOwner(drop, player.getName());
if (ConfigManager.addTagToFish)
ItemStackUtil.addIdentifier(drop, "loot", droppedItem.getKey());
if (drop.getType() == Material.PLAYER_HEAD) {
NBTItem nbtItem = new NBTItem(drop);
NBTCompound nbtCompound = nbtItem.getCompound("SkullOwner");
if (nbtCompound != null && !nbtCompound.hasTag("Id")) {
nbtCompound.setUUID("Id", UUID.randomUUID());
drop.setItemMeta(nbtItem.getItem().getItemMeta());
}
}
ItemStackUtil.addExtraMeta(drop, droppedItem, sizeMultiplier); ItemStackUtil.addExtraMeta(drop, droppedItem, sizeMultiplier);
} }
return drop; return drop;
@@ -577,21 +604,53 @@ public class FishingManager extends Function {
ItemStack itemStack = McMMOTreasure.getTreasure(player); ItemStack itemStack = McMMOTreasure.getTreasure(player);
if (itemStack == null) return false; if (itemStack == null) return false;
FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "mcmmo"); FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "vanilla");
Bukkit.getPluginManager().callEvent(fishResultEvent); Bukkit.getPluginManager().callEvent(fishResultEvent);
if (fishResultEvent.isCancelled()) { if (fishResultEvent.isCancelled()) {
return true; return true;
} }
doVanillaActions(player, location, itemStack, fishResultEvent.isDouble());
player.giveExp(new Random().nextInt(24), true);
return true;
}
private void dropVanillaLoot(Player player, VanillaLoot vanillaLoot, Location location, boolean isDouble) {
ItemStack itemStack = vanillaLoot.getItemStack();
if (ConfigManager.enableMcMMOLoot && Math.random() < ConfigManager.mcMMOLootChance){
ItemStack mcMMOItemStack = McMMOTreasure.getTreasure(player);
if (mcMMOItemStack != null){
itemStack = mcMMOItemStack;
}
}
FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "vanilla");
Bukkit.getPluginManager().callEvent(fishResultEvent);
if (fishResultEvent.isCancelled()) {
return;
}
doVanillaActions(player, location, itemStack, fishResultEvent.isDouble());
player.giveExp(vanillaLoot.getXp(), true);
}
private void doVanillaActions(Player player, Location location, ItemStack itemStack, boolean isDouble) {
if (Competition.currentCompetition != null) { if (Competition.currentCompetition != null) {
Competition.currentCompetition.refreshData(player, 0, fishResultEvent.isDouble()); Competition.currentCompetition.refreshData(player, (float) plugin.getLootManager().getVanilla_loot().getScore(), isDouble);
Competition.currentCompetition.tryAddBossBarToPlayer(player); Competition.currentCompetition.tryAddBossBarToPlayer(player);
} }
player.giveExp(new Random().nextInt(24), true); Loot vanilla = plugin.getLootManager().getVanilla_loot();
dropItem(player, location, fishResultEvent.isDouble(), itemStack); addStats(player.getUniqueId(), vanilla, isDouble ? 2 : 1);
if (vanilla.getSuccessActions() != null) {
for (Action action : vanilla.getSuccessActions())
action.doOn(player, null);
}
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
dropItem(player, location, isDouble, itemStack);
sendSuccessTitle(player, itemStack); sendSuccessTitle(player, itemStack);
return true;
} }
private void dropItem(Player player, Location location, boolean isDouble, ItemStack itemStack) { private void dropItem(Player player, Location location, boolean isDouble, ItemStack itemStack) {
@@ -612,34 +671,6 @@ public class FishingManager extends Function {
plugin.getStatisticsManager().addFishAmount(uuid, loot, amount); plugin.getStatisticsManager().addFishAmount(uuid, loot, amount);
} }
private void dropVanillaLoot(Player player, VanillaLoot vanillaLoot, Location location, boolean isDouble) {
ItemStack itemStack;
itemStack = vanillaLoot.getItemStack();
if (ConfigManager.enableMcMMOLoot && Math.random() < ConfigManager.mcMMOLootChance){
ItemStack mcMMOItemStack = McMMOTreasure.getTreasure(player);
if (mcMMOItemStack != null){
itemStack = mcMMOItemStack;
}
}
FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CATCH_VANILLA_ITEM, isDouble, itemStack, "vanilla");
Bukkit.getPluginManager().callEvent(fishResultEvent);
if (fishResultEvent.isCancelled()) {
return;
}
if (Competition.currentCompetition != null){
Competition.currentCompetition.refreshData(player, 0, fishResultEvent.isDouble());
Competition.currentCompetition.tryAddBossBarToPlayer(player);
}
player.giveExp(vanillaLoot.getXp(), true);
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
dropItem(player, location, isDouble, itemStack);
sendSuccessTitle(player, itemStack);
}
private void summonMob(Player player, Loot loot, Location location, Mob mob, double scoreMultiplier) { private void summonMob(Player player, Loot loot, Location location, Mob mob, double scoreMultiplier) {
MobInterface mobInterface = plugin.getIntegrationManager().getMobInterface(); MobInterface mobInterface = plugin.getIntegrationManager().getMobInterface();
if (mobInterface == null) return; if (mobInterface == null) return;
@@ -681,8 +712,7 @@ public class FishingManager extends Function {
private void sendSuccessTitle(Player player, String loot) { private void sendSuccessTitle(Player player, String loot) {
if (!ConfigManager.enableSuccessTitle) return; if (!ConfigManager.enableSuccessTitle) return;
Bukkit.getScheduler().runTaskLater(plugin, () -> { Bukkit.getScheduler().runTaskLater(plugin, () -> AdventureUtil.playerTitle(
AdventureUtil.playerTitle(
player, player,
ConfigManager.successTitle[new Random().nextInt(ConfigManager.successTitle.length)] ConfigManager.successTitle[new Random().nextInt(ConfigManager.successTitle.length)]
.replace("{loot}", loot) .replace("{loot}", loot)
@@ -693,8 +723,7 @@ public class FishingManager extends Function {
ConfigManager.successFadeIn, ConfigManager.successFadeIn,
ConfigManager.successFadeStay, ConfigManager.successFadeStay,
ConfigManager.successFadeOut ConfigManager.successFadeOut
); ), 8);
}, 8);
} }
private void sendSuccessTitle(Player player, ItemStack itemStack) { private void sendSuccessTitle(Player player, ItemStack itemStack) {
@@ -703,16 +732,14 @@ public class FishingManager extends Function {
Component titleComponent = getTitleComponent(itemStack, title); Component titleComponent = getTitleComponent(itemStack, title);
String subTitle = ConfigManager.successSubTitle[new Random().nextInt(ConfigManager.successSubTitle.length)]; String subTitle = ConfigManager.successSubTitle[new Random().nextInt(ConfigManager.successSubTitle.length)];
Component subtitleComponent = getTitleComponent(itemStack, subTitle); Component subtitleComponent = getTitleComponent(itemStack, subTitle);
Bukkit.getScheduler().runTaskLater(plugin, () -> { Bukkit.getScheduler().runTaskLater(plugin, () -> AdventureUtil.playerTitle(
AdventureUtil.playerTitle(
player, player,
titleComponent, titleComponent,
subtitleComponent, subtitleComponent,
ConfigManager.successFadeIn, ConfigManager.successFadeIn,
ConfigManager.successFadeStay, ConfigManager.successFadeStay,
ConfigManager.successFadeOut ConfigManager.successFadeOut
); ), 8);
}, 8);
} }
private void loseDurability(Player player) { private void loseDurability(Player player) {
@@ -750,46 +777,20 @@ public class FishingManager extends Function {
} }
if (!ConfigManager.enableFailureTitle) return; if (!ConfigManager.enableFailureTitle) return;
Bukkit.getScheduler().runTaskLater(plugin, () -> { Bukkit.getScheduler().runTaskLater(plugin, () -> AdventureUtil.playerTitle(
AdventureUtil.playerTitle(
player, player,
ConfigManager.failureTitle[new Random().nextInt(ConfigManager.failureTitle.length)], ConfigManager.failureTitle[new Random().nextInt(ConfigManager.failureTitle.length)],
ConfigManager.failureSubTitle[new Random().nextInt(ConfigManager.failureSubTitle.length)], ConfigManager.failureSubTitle[new Random().nextInt(ConfigManager.failureSubTitle.length)],
ConfigManager.failureFadeIn, ConfigManager.failureFadeIn,
ConfigManager.failureFadeStay, ConfigManager.failureFadeStay,
ConfigManager.failureFadeOut ConfigManager.failureFadeOut
); ), 8);
}, 8);
}
public void onCaughtEntity(PlayerFishEvent event) {
final Player player = event.getPlayer();
FishingGame fishingGame = fishingPlayerMap.remove(player);
if (fishingGame != null) {
Entity entity = event.getCaught();
if (entity != null && entity.getType() == EntityType.ARMOR_STAND) {
proceedReelIn(event.getHook().getLocation(), player, fishingGame);
}
else {
fishingGame.cancel();
nextEffect.remove(player);
nextLoot.remove(player);
AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.hookOther);
}
}
} }
public void onFailedAttempt(PlayerFishEvent event) { public void onFailedAttempt(PlayerFishEvent event) {
//Empty //Empty
} }
public void onBite(PlayerFishEvent event) {
if (ConfigManager.disableBar) return;
if (!ConfigManager.instantBar) return;
final Player player = event.getPlayer();
showBar(player);
}
public void showBar(Player player) { public void showBar(Player player) {
if (fishingPlayerMap.get(player) != null) return; if (fishingPlayerMap.get(player) != null) return;
Loot loot = nextLoot.get(player); Loot loot = nextLoot.get(player);
@@ -933,33 +934,34 @@ public class FishingManager extends Function {
AdventureUtil.playerMessage(player, stringBuilder.substring(0, stringBuilder.length() - MessageManager.splitChar.length())); AdventureUtil.playerMessage(player, stringBuilder.substring(0, stringBuilder.length() - MessageManager.splitChar.length()));
} }
private void showFishingBar(Player player, @Nullable Loot loot){ private void showFishingBar(Player player, @NotNull Loot loot) {
MiniGameConfig game = (loot != null && loot.getFishingGames() != null) MiniGameConfig game = loot.getFishingGames() != null
? loot.getFishingGames()[new Random().nextInt(loot.getFishingGames().length)] ? loot.getFishingGames()[new Random().nextInt(loot.getFishingGames().length)]
: plugin.getBarMechanicManager().getRandomGame(); : plugin.getBarMechanicManager().getRandomGame();
int difficult = game.getRandomDifficulty() + nextEffect.getOrDefault(player, new Effect()).getDifficulty(); int difficult = game.getRandomDifficulty() + nextEffect.getOrDefault(player, new Effect()).getDifficulty();
FishHookEvent fishHookEvent = new FishHookEvent(player, Math.min(10, Math.max(1, difficult))); MiniGameStartEvent miniGameStartEvent = new MiniGameStartEvent(player, Math.min(10, Math.max(1, difficult)));
Bukkit.getPluginManager().callEvent(fishHookEvent); Bukkit.getPluginManager().callEvent(miniGameStartEvent);
if (miniGameStartEvent.isCancelled()) {
return;
}
FishingBar fishingBar = game.getRandomBar(); FishingBar fishingBar = game.getRandomBar();
FishingGame fishingGame = null; FishingGame fishingGame = null;
if (fishingBar instanceof ModeOneBar modeOneBar) { if (fishingBar instanceof ModeOneBar modeOneBar) {
fishingGame = new ModeOneGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, fishHookEvent.getDifficulty(), modeOneBar); fishingGame = new ModeOneGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, miniGameStartEvent.getDifficulty(), modeOneBar);
} }
else if (fishingBar instanceof ModeTwoBar modeTwoBar) { else if (fishingBar instanceof ModeTwoBar modeTwoBar) {
fishingGame = new ModeTwoGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, fishHookEvent.getDifficulty(), modeTwoBar); fishingGame = new ModeTwoGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, miniGameStartEvent.getDifficulty(), modeTwoBar);
} }
else if (fishingBar instanceof ModeThreeBar modeThreeBar) { else if (fishingBar instanceof ModeThreeBar modeThreeBar) {
fishingGame = new ModeThreeGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, fishHookEvent.getDifficulty(), modeThreeBar); fishingGame = new ModeThreeGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, miniGameStartEvent.getDifficulty(), modeThreeBar);
} }
if (fishingGame != null) { if (fishingGame != null) {
fishingGame.runTaskTimer(plugin, 0, 1); fishingGame.runTaskTimer(plugin, 0, 1);
fishingPlayerMap.put(player, fishingGame); fishingPlayerMap.put(player, fishingGame);
} }
if (vanillaLoot.get(player) == null && loot != null){
for (Action action : loot.getHookActions()) { for (Action action : loot.getHookActions()) {
action.doOn(player, null); action.doOn(player, null);
} }
}
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, game.getTime() * 20,3)); player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, game.getTime() * 20,3));
} }
@@ -974,11 +976,6 @@ public class FishingManager extends Function {
removeBobber(player); removeBobber(player);
} }
@Nullable
public FishingGame getFishingPlayer(Player player) {
return fishingPlayerMap.get(player);
}
public void removeFishingPlayer(Player player) { public void removeFishingPlayer(Player player) {
fishingPlayerMap.remove(player); fishingPlayerMap.remove(player);
} }

View File

@@ -36,6 +36,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.File; import java.io.File;
@@ -46,8 +47,9 @@ public class LootManager extends Function {
private final CustomFishing plugin; private final CustomFishing plugin;
private final HashMap<String, Loot> waterLoots; private final HashMap<String, Loot> waterLoots;
private final HashMap<String, Loot> lavaLoots; private final HashMap<String, Loot> lavaLoots;
private final HashMap<String, ItemStack> lootItems; private final HashMap<String, Item> lootItems;
private final HashMap<String, List<String>> category; private final HashMap<String, List<String>> category;
private Loot vanilla_loot;
public LootManager(CustomFishing plugin) { public LootManager(CustomFishing plugin) {
this.plugin = plugin; this.plugin = plugin;
@@ -59,12 +61,22 @@ public class LootManager extends Function {
@Nullable @Nullable
public ItemStack build(String key) { public ItemStack build(String key) {
ItemStack itemStack = this.lootItems.get(key); Item item = lootItems.get(key);
return itemStack == null ? null : itemStack.clone(); return item == null || item.getMaterial() == Material.AIR ? new ItemStack(Material.AIR) : ItemStackUtil.getFromItem(item);
} }
@Override @Override
public void load() { public void load() {
this.vanilla_loot = new Loot(
"vanilla",
"vanilla",
null,
0,
false,
0,
false,
false
);
this.loadItems(); this.loadItems();
this.loadMobs(); this.loadMobs();
this.loadCategories(); this.loadCategories();
@@ -78,6 +90,7 @@ public class LootManager extends Function {
this.lavaLoots.clear(); this.lavaLoots.clear();
this.lootItems.clear(); this.lootItems.clear();
this.category.clear(); this.category.clear();
this.vanilla_loot = null;
} }
@Nullable @Nullable
@@ -183,7 +196,6 @@ public class LootManager extends Function {
if (lootSection == null) continue; if (lootSection == null) continue;
if (!lootSection.getBoolean("enable", true)) continue; if (!lootSection.getBoolean("enable", true)) continue;
String material = lootSection.getString("material","COD"); String material = lootSection.getString("material","COD");
DroppedItem loot = new DroppedItem( DroppedItem loot = new DroppedItem(
key, key,
lootSection.contains("nick") ? lootSection.getString("nick") : AdventureUtil.replaceLegacy(lootSection.getString("display.name", key)), lootSection.contains("nick") ? lootSection.getString("nick") : AdventureUtil.replaceLegacy(lootSection.getString("display.name", key)),
@@ -226,15 +238,17 @@ public class LootManager extends Function {
setActions(lootSection, loot); setActions(lootSection, loot);
setRequirements(lootSection.getConfigurationSection("requirements"), loot); setRequirements(lootSection.getConfigurationSection("requirements"), loot);
if (key.equals("vanilla")) {
vanilla_loot = loot;
continue;
}
if (lootSection.getBoolean("in-lava", false)) lavaLoots.put(key, loot); if (lootSection.getBoolean("in-lava", false)) lavaLoots.put(key, loot);
else waterLoots.put(key, loot); else waterLoots.put(key, loot);
//not a CustomFishing loot //not a CustomFishing loot
if (material.contains(":")) continue; if (material.contains(":")) continue;
Item item = new Item(lootSection, key); Item item = new Item(lootSection, key);
if (item.getMaterial() == Material.AIR) lootItems.put(key, new ItemStack(Material.AIR)); if (ConfigManager.addTagToFish) item.setCfTag(new String[] {"loot", key});
else lootItems.put(key, ItemStackUtil.getFromItem(item)); lootItems.put(key, item);
} }
} }
} }
@@ -353,4 +367,9 @@ public class LootManager extends Function {
public List<String> getCategories(String categoryID) { public List<String> getCategories(String categoryID) {
return category.get(categoryID); return category.get(categoryID);
} }
@NotNull
public Loot getVanilla_loot() {
return vanilla_loot;
}
} }

View File

@@ -101,7 +101,7 @@ public class StatisticsManager extends DataFunction {
public void addFishAmount(UUID uuid, Loot loot, int amount) { public void addFishAmount(UUID uuid, Loot loot, int amount) {
PlayerStatisticsData statisticsData = statisticsDataMap.get(uuid); PlayerStatisticsData statisticsData = statisticsDataMap.get(uuid);
if (statisticsData != null) { if (statisticsData != null) {
statisticsData.addFishAmount(loot, amount, uuid); statisticsData.addFishAmount(loot, uuid, amount);
} }
} }
@@ -113,6 +113,14 @@ public class StatisticsManager extends DataFunction {
return -1; return -1;
} }
public int getTotalFishAmount(UUID uuid) {
PlayerStatisticsData statisticsData = statisticsDataMap.get(uuid);
if (statisticsData != null) {
return statisticsData.getTotalCatchAmount();
}
return -1;
}
public boolean hasFished(UUID uuid, String key) { public boolean hasFished(UUID uuid, String key) {
PlayerStatisticsData statisticsData = statisticsDataMap.get(uuid); PlayerStatisticsData statisticsData = statisticsDataMap.get(uuid);
if (statisticsData != null) { if (statisticsData != null) {

View File

@@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.fishing.loot.Item;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@@ -116,13 +117,13 @@ public class ArmorStandUtil {
return equipPacket; return equipPacket;
} }
public static void sendAnimationToPlayer(Location location, Player player, String item, int time) { public static void sendAnimationToPlayer(Location location, Player player, String key, int time) {
int id = new Random().nextInt(Integer.MAX_VALUE); int id = new Random().nextInt(Integer.MAX_VALUE);
ItemStack itemStack = CustomFishing.getInstance().getEffectManager().getUtilItem(item); Item item = CustomFishing.getInstance().getEffectManager().getUtilItem(key);
if (itemStack == null) return; if (item == null) return;
CustomFishing.getProtocolManager().sendServerPacket(player, getSpawnPacket(id, location.clone().subtract(0,1,0))); CustomFishing.getProtocolManager().sendServerPacket(player, getSpawnPacket(id, location.clone().subtract(0,1,0)));
CustomFishing.getProtocolManager().sendServerPacket(player, getMetaPacket(id)); CustomFishing.getProtocolManager().sendServerPacket(player, getMetaPacket(id));
CustomFishing.getProtocolManager().sendServerPacket(player, getEquipPacket(id, itemStack)); CustomFishing.getProtocolManager().sendServerPacket(player, getEquipPacket(id, ItemStackUtil.getFromItem(item)));
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomFishing.getInstance(), () -> { Bukkit.getScheduler().runTaskLaterAsynchronously(CustomFishing.getInstance(), () -> {
CustomFishing.getProtocolManager().sendServerPacket(player, getDestroyPacket(id)); CustomFishing.getProtocolManager().sendServerPacket(player, getDestroyPacket(id));
}, time); }, time);

View File

@@ -27,6 +27,7 @@ import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.fishing.loot.DroppedItem; import net.momirealms.customfishing.fishing.loot.DroppedItem;
import net.momirealms.customfishing.fishing.loot.Item; import net.momirealms.customfishing.fishing.loot.Item;
import net.momirealms.customfishing.fishing.loot.Loot; import net.momirealms.customfishing.fishing.loot.Loot;
import net.momirealms.customfishing.manager.ConfigManager;
import net.momirealms.customfishing.object.LeveledEnchantment; import net.momirealms.customfishing.object.LeveledEnchantment;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -88,8 +89,14 @@ public class ItemStackUtil {
lore.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<!i>" + line))); lore.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<!i>" + line)));
}); });
} }
if (item.getCfTag() != null) {
NBTCompound cfCompound = nbtItem.addCompound("CustomFishing");
cfCompound.setString("type", item.getCfTag()[0]);
cfCompound.setString("id", item.getCfTag()[1]);
}
if (item.getHead64() != null) { if (item.getHead64() != null) {
NBTCompound nbtCompound = nbtItem.addCompound("SkullOwner"); NBTCompound nbtCompound = nbtItem.addCompound("SkullOwner");
nbtCompound.setUUID("Id", item.isHeadStackable() ? UUID.nameUUIDFromBytes(item.getKey().getBytes()) : UUID.randomUUID());
NBTListCompound texture = nbtCompound.addCompound("Properties").getCompoundList("textures").addCompound(); NBTListCompound texture = nbtCompound.addCompound("Properties").getCompoundList("textures").addCompound();
texture.setString("Value", item.getHead64()); texture.setString("Value", item.getHead64());
} }
@@ -170,23 +177,26 @@ public class ItemStackUtil {
} }
public static void givePlayerRod(Player player, String rodKey, int amount){ public static void givePlayerRod(Player player, String rodKey, int amount){
ItemStack itemStack = CustomFishing.getInstance().getEffectManager().getRodItem(rodKey); Item item = CustomFishing.getInstance().getEffectManager().getRodItem(rodKey);
if (itemStack == null) return; if (item == null) return;
ItemStack itemStack = getFromItem(item);
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
player.getInventory().addItem(itemStack); player.getInventory().addItem(itemStack);
} }
} }
public static void givePlayerBait(Player player, String baitKey, int amount){ public static void givePlayerBait(Player player, String baitKey, int amount){
ItemStack itemStack = CustomFishing.getInstance().getEffectManager().getBaitItem(baitKey); Item item = CustomFishing.getInstance().getEffectManager().getBaitItem(baitKey);
if (itemStack == null) return; if (item == null) return;
ItemStack itemStack = getFromItem(item);
itemStack.setAmount(amount); itemStack.setAmount(amount);
player.getInventory().addItem(itemStack); player.getInventory().addItem(itemStack);
} }
public static void givePlayerUtil(Player player, String utilKey, int amount){ public static void givePlayerUtil(Player player, String utilKey, int amount){
ItemStack itemStack = CustomFishing.getInstance().getEffectManager().getUtilItem(utilKey); Item item = CustomFishing.getInstance().getEffectManager().getUtilItem(utilKey);
if (itemStack == null) return; if (item == null) return;
ItemStack itemStack = getFromItem(item);
itemStack.setAmount(amount); itemStack.setAmount(amount);
player.getInventory().addItem(itemStack); player.getInventory().addItem(itemStack);
} }

View File

@@ -84,6 +84,6 @@ public class JedisUtil {
} }
public static boolean isPoolEnabled() { public static boolean isPoolEnabled() {
return jedisPool != null; return !(jedisPool == null || jedisPool.isClosed());
} }
} }

View File

@@ -518,6 +518,9 @@ bar_10:
judgment-area-offset: -160 judgment-area-offset: -160
judgment-area-width: 33 judgment-area-width: 33
fish-icon-width: 8 fish-icon-width: 8
water-resistance: 0.15
pulling-strength: 0.45
loosening-strength-loss: 0.3
hold-time-requirements: hold-time-requirements:
- 3 - 3
- 4 - 4
@@ -557,6 +560,10 @@ bar_11:
fish-start-position: 170 fish-start-position: 170
fish-icon-width: 8 fish-icon-width: 8
success-position: 21 success-position: 21
ultimate-strain: 50
normal-pull-strain-increase: 1
struggling-strain-increase: 2
loosening-strain-loss: 2
strain: strain:
- '<font:customfishing:icons>뀑</font>' - '<font:customfishing:icons>뀑</font>'
- '<font:customfishing:icons>뀒</font>' - '<font:customfishing:icons>뀒</font>'

View File

@@ -1,5 +1,5 @@
# Don't change # Don't change
config-version: '18' config-version: '19'
# bStats # bStats
metrics: true metrics: true
@@ -36,9 +36,6 @@ mechanics:
# other loots # other loots
# 其他战利品 # 其他战利品
other-loots: other-loots:
# Should other loots have the same fishing mechanic CustomFishing provides
# 其他战利品是否有插件提供的钓鱼特性
fishing-bar: true
# 原版战利品 # 原版战利品
vanilla: vanilla:
enable: true enable: true

View File

@@ -4,7 +4,6 @@ wooden_rod:
lore: lore:
- '<gray>Its just an ordinary fishing rod' - '<gray>Its just an ordinary fishing rod'
- '<gray>But it''s quite friendly to a starter!' - '<gray>But it''s quite friendly to a starter!'
# Click here to learn how modifier system works: https://www.yuque.com/docs/share/4842ac5f-b5ea-4568-acef-d510f8bc9064?# 《Modifier System》
effect: effect:
difficulty: -1 difficulty: -1

View File

@@ -0,0 +1,13 @@
fisherman_talismans:
material: player_head
display:
name: '<blue>Fisherman Talismans'
lore:
- ''
- '<gray>Fishing would be easier when keeping'
- '<gray>the talismans in the fishing bag'
- ''
- '<gold>The effect cannot be stacked'
head64: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWQzZmVjNGI3M2E1ZThlMWY1Y2FiOTBjZDBhMzgzMDJmMzdiMDBjNzEzY2EwNmM4NDkzMDBmOGZkMTFlNWVjMiJ9fX0=
effect:
difficulty: -1