From 976bce4dbf08d87fe97fbf1201656e87c44f5b25 Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Wed, 19 Oct 2022 14:07:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B2=A9=E6=B5=86=E9=92=93=E9=B1=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customfishing/CustomFishing.java | 2 +- .../customfishing/manager/BonusManager.java | 1 + .../customfishing/manager/ConfigManager.java | 5 + .../customfishing/manager/FishingManager.java | 182 +++++++++++------- .../manager/IntegrationManager.java | 8 +- .../customfishing/manager/TotemManager.java | 10 +- .../object/fishing/BobberCheckTask.java | 127 ++++++++++++ .../customfishing/object/fishing/Bonus.java | 12 +- .../object/fishing/LavaEffect.java | 34 ++++ .../customfishing/util/ConfigUtil.java | 2 + src/main/resources/config.yml | 8 +- src/main/resources/plugin.yml | 6 +- src/main/resources/rods/default.yml | 1 + 13 files changed, 316 insertions(+), 82 deletions(-) create mode 100644 src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java create mode 100644 src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java diff --git a/src/main/java/net/momirealms/customfishing/CustomFishing.java b/src/main/java/net/momirealms/customfishing/CustomFishing.java index 8b6ba02d..accca61f 100644 --- a/src/main/java/net/momirealms/customfishing/CustomFishing.java +++ b/src/main/java/net/momirealms/customfishing/CustomFishing.java @@ -84,7 +84,7 @@ public final class CustomFishing extends JavaPlugin { this.lootManager = new LootManager(); this.layoutManager = new LayoutManager(); this.dataManager = new DataManager(); - this.totemManager = new TotemManager(integrationManager.getBlockInterface()); + this.totemManager = new TotemManager(); ConfigUtil.reload(); PluginCommand pluginCommand = new PluginCommand(); diff --git a/src/main/java/net/momirealms/customfishing/manager/BonusManager.java b/src/main/java/net/momirealms/customfishing/manager/BonusManager.java index b57ab063..c4eed82d 100644 --- a/src/main/java/net/momirealms/customfishing/manager/BonusManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/BonusManager.java @@ -153,6 +153,7 @@ public class BonusManager extends Function { case "difficulty" -> bonus.setDifficulty(config.getInt(key + ".modifier.difficulty")); case "double-loot" -> bonus.setDoubleLoot(config.getDouble(key + ".modifier.double-loot")); case "score" -> bonus.setScore(config.getDouble(key + ".modifier.score")); + case "lava-fishing" -> bonus.setCanLavaFishing(config.getBoolean(key + ".modifier.lava-fishing", false)); } }); return bonus; diff --git a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java index 0932577c..6c80f206 100644 --- a/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/ConfigManager.java @@ -45,6 +45,8 @@ public class ConfigManager { public static int failureFadeStay; public static int failureFadeOut; public static boolean useRedis; + public static int lavaMaxTime; + public static int lavaMinTime; public static void load() { ConfigUtil.update("config.yml"); @@ -97,6 +99,9 @@ public class ConfigManager { failureFadeStay = config.getInt("titles.failure.fade.stay", 30) * 50; failureFadeOut = config.getInt("titles.failure.fade.out", 10) * 50; + lavaMinTime = config.getInt("mechanics.lava-fishing.min-time", 100); + lavaMaxTime = config.getInt("mechanics.lava-fishing.max-time", 600) - lavaMinTime; + useRedis = false; if (enableCompetition && config.getBoolean("mechanics.fishing-competition.redis", false)) { YamlConfiguration configuration = ConfigUtil.getConfig("database.yml"); diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 42dc7529..ff95d50a 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -18,6 +18,7 @@ import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.object.action.ActionInterface; import net.momirealms.customfishing.object.fishing.*; import net.momirealms.customfishing.object.loot.DroppedItem; +import net.momirealms.customfishing.object.fishing.BobberCheckTask; import net.momirealms.customfishing.object.loot.Loot; import net.momirealms.customfishing.object.loot.Mob; import net.momirealms.customfishing.object.requirements.RequirementInterface; @@ -65,6 +66,7 @@ public class FishingManager extends Function { private final HashMap vanillaLoot; private final ConcurrentHashMap fishingPlayerCache; private final ConcurrentHashMap totemCache; + private final ConcurrentHashMap lavaFishing; public FishingManager() { this.playerFishListener = new PlayerFishListener(this); @@ -76,6 +78,7 @@ public class FishingManager extends Function { this.vanillaLoot = new HashMap<>(); this.fishingPlayerCache = new ConcurrentHashMap<>(); this.totemCache = new ConcurrentHashMap<>(); + this.lavaFishing = new ConcurrentHashMap<>(); load(); } @@ -112,7 +115,7 @@ public class FishingManager extends Function { final FishHook fishHook = event.getHook(); hooksCache.put(player, fishHook); - if (isCoolDown(player, 2000)) return; + if (isCoolDown(player, 500)) return; Bukkit.getScheduler().runTaskAsynchronously(CustomFishing.plugin, () -> { @@ -121,6 +124,7 @@ public class FishingManager extends Function { boolean noSpecialRod = true; boolean noRod = true; boolean noBait = true; + int lureLevel = 0; Bonus initialBonus = new Bonus(); initialBonus.setDifficulty(0); @@ -136,6 +140,7 @@ public class FishingManager extends Function { if (mainHandItemType == Material.FISHING_ROD) { noRod = false; enchantBonus(initialBonus, mainHandItem); + lureLevel = mainHandItem.getEnchantmentLevel(Enchantment.LURE); } NBTItem mainHandNBTItem = new NBTItem(mainHandItem); NBTCompound nbtCompound = mainHandNBTItem.getCompound("CustomFishing"); @@ -163,6 +168,7 @@ public class FishingManager extends Function { if (offHandItemType != Material.AIR){ if (noRod && offHandItemType == Material.FISHING_ROD) { enchantBonus(initialBonus, offHandItem); + lureLevel = offHandItem.getEnchantmentLevel(Enchantment.LURE); } NBTItem offHandNBTItem = new NBTItem(offHandItem); NBTCompound nbtCompound = offHandNBTItem.getCompound("CustomFishing"); @@ -202,14 +208,11 @@ public class FishingManager extends Function { return; } + fishHook.setMaxWaitTime((int) (fishHook.getMaxWaitTime() * initialBonus.getTime())); + fishHook.setMinWaitTime((int) (fishHook.getMinWaitTime() * initialBonus.getTime())); + nextBonus.put(player, initialBonus); - List possibleLoots = getPossibleLootList(new FishingCondition(fishHook.getLocation(), player), false); - List availableLoots = new ArrayList<>(); - if (possibleLoots.size() == 0){ - nextLoot.put(player, null); - return; - } if (ConfigManager.needRodForLoots && noSpecialRod){ if (!ConfigManager.enableVanillaLoot) AdventureUtil.playerMessage(player, MessageManager.prefix + MessageManager.noRod); nextLoot.put(player, null); @@ -219,54 +222,65 @@ public class FishingManager extends Function { } if ((ConfigManager.needRodForLoots || ConfigManager.needRodToFish) && noSpecialRod) return; - HashMap as = initialBonus.getWeightAS(); - HashMap md = initialBonus.getWeightMD(); - - double[] weights = new double[possibleLoots.size()]; - int index = 0; - for (Loot loot : possibleLoots){ - double weight = loot.getWeight(); - String group = loot.getGroup(); - if (group != null){ - if (as.get(group) != null){ - weight += as.get(group); - } - if (md.get(group) != null){ - weight *= md.get(group); - } - } - if (weight <= 0) continue; - availableLoots.add(loot); - weights[index++] = weight; - } - - double total = Arrays.stream(weights).sum(); - double[] weightRatios = new double[index]; - for (int i = 0; i < index; i++){ - weightRatios[i] = weights[i]/total; - } - - double[] weightRange = new double[index]; - double startPos = 0; - for (int i = 0; i < index; i++) { - weightRange[i] = startPos + weightRatios[i]; - startPos += weightRatios[i]; - } - - double random = Math.random(); - int pos = Arrays.binarySearch(weightRange, random); - - if (pos < 0) { - pos = -pos - 1; - } - if (pos < weightRange.length && random < weightRange[pos]) { - nextLoot.put(player, availableLoots.get(pos)); - return; - } - nextLoot.put(player, null); + BobberCheckTask bobberCheckTask = new BobberCheckTask(player, initialBonus, fishHook, this, lureLevel); + bobberCheckTask.runTaskTimer(CustomFishing.plugin, 1, 1); }); } + public void getNextLoot(Player player, Bonus initialBonus, List possibleLoots) { + List availableLoots = new ArrayList<>(); + if (possibleLoots.size() == 0){ + nextLoot.put(player, null); + return; + } + + HashMap as = initialBonus.getWeightAS(); + HashMap md = initialBonus.getWeightMD(); + + double[] weights = new double[possibleLoots.size()]; + int index = 0; + for (Loot loot : possibleLoots){ + double weight = loot.getWeight(); + String group = loot.getGroup(); + if (group != null){ + if (as.get(group) != null){ + weight += as.get(group); + } + if (md.get(group) != null){ + weight *= md.get(group); + } + } + if (weight <= 0) continue; + availableLoots.add(loot); + weights[index++] = weight; + } + + double total = Arrays.stream(weights).sum(); + double[] weightRatios = new double[index]; + for (int i = 0; i < index; i++){ + weightRatios[i] = weights[i]/total; + } + + double[] weightRange = new double[index]; + double startPos = 0; + for (int i = 0; i < index; i++) { + weightRange[i] = startPos + weightRatios[i]; + startPos += weightRatios[i]; + } + + double random = Math.random(); + int pos = Arrays.binarySearch(weightRange, random); + + if (pos < 0) { + pos = -pos - 1; + } + if (pos < weightRange.length && random < weightRange[pos]) { + nextLoot.put(player, availableLoots.get(pos)); + return; + } + nextLoot.put(player, null); + } + public void onCaughtFish(PlayerFishEvent event) { final Player player = event.getPlayer(); if (!(event.getCaught() instanceof Item item)) return; @@ -356,8 +370,15 @@ public class FishingManager extends Function { public void onReelIn(PlayerFishEvent event) { final Player player = event.getPlayer(); FishingPlayer fishingPlayer = fishingPlayerCache.remove(player); - if (fishingPlayer == null) return; - proceedReelIn(event, player, fishingPlayer); + if (fishingPlayer != null) { + proceedReelIn(event, player, fishingPlayer); + lavaFishing.remove(player); + return; + } + if (lavaFishing.containsKey(player)) { + showPlayerBar(player, nextLoot.get(player)); + event.setCancelled(true); + } } private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier) { @@ -594,16 +615,7 @@ public class FishingManager extends Function { } public void onInGround(PlayerFishEvent event) { - FishHook fishHook = event.getHook(); - - Block belowBlock = fishHook.getLocation().clone().subtract(0,1,0).getBlock(); - Block inBlock = fishHook.getLocation().getBlock(); - if (inBlock.getType() == Material.AIR && belowBlock.getType() == Material.ICE) { - - } - else if (inBlock.getType() == Material.LAVA) { - - } + //Empty } public void onMMOItemsRodCast(PlayerFishEvent event) { @@ -629,8 +641,8 @@ public class FishingManager extends Function { return false; } - private void enchantBonus(Bonus initialBonus, ItemStack mainHandItem) { - Map enchantments = mainHandItem.getEnchantments(); + private void enchantBonus(Bonus initialBonus, ItemStack itemStack) { + Map enchantments = itemStack.getEnchantments(); for (Map.Entry en : enchantments.entrySet()) { String key = en.getKey().getKey() + ":" + en.getValue(); Bonus enchantBonus = BonusManager.ENCHANTS.get(key); @@ -640,7 +652,7 @@ public class FishingManager extends Function { } } - private List getPossibleLootList(FishingCondition fishingCondition, boolean finder) { + public List getPossibleWaterLootList(FishingCondition fishingCondition, boolean finder) { List available = new ArrayList<>(); outer: for (Loot loot : LootManager.WATERLOOTS.values()) { @@ -661,6 +673,27 @@ public class FishingManager extends Function { return available; } + public List getPossibleLavaLootList(FishingCondition fishingCondition, boolean finder) { + List available = new ArrayList<>(); + outer: + for (Loot loot : LootManager.LAVALOOTS.values()) { + if (finder && !loot.isShowInFinder()) continue; + RequirementInterface[] requirements = loot.getRequirements(); + if (requirements == null){ + available.add(loot); + } + else { + for (RequirementInterface requirement : requirements){ + if (!requirement.isConditionMet(fishingCondition)){ + continue outer; + } + } + available.add(loot); + } + } + return available; + } + @Override public void onInteract(PlayerInteractEvent event) { ItemStack itemStack = event.getItem(); @@ -721,7 +754,7 @@ public class FishingManager extends Function { private void useFinder(Player player) { if (isCoolDown(player, ConfigManager.fishFinderCoolDown)) return; - List possibleLoots = getPossibleLootList(new FishingCondition(player.getLocation(), player), true); + List possibleLoots = getPossibleWaterLootList(new FishingCondition(player.getLocation(), player), true); FishFinderEvent fishFinderEvent = new FishFinderEvent(player, possibleLoots); Bukkit.getPluginManager().callEvent(fishFinderEvent); @@ -739,6 +772,9 @@ public class FishingManager extends Function { } private void showPlayerBar(Player player, @Nullable Loot loot){ + + if (loot == Loot.EMPTY) return; + Layout layout; if (loot != null && loot.getLayout() != null){ layout = loot.getLayout()[new Random().nextInt(loot.getLayout().length)]; @@ -802,6 +838,8 @@ public class FishingManager extends Function { nextLoot.remove(player); nextBonus.remove(player); vanillaLoot.remove(player); + BobberCheckTask task = lavaFishing.remove(player); + if (task != null) task.stop(); // prevent bar duplication FishHook fishHook = hooksCache.remove(player); if (fishHook != null) fishHook.remove(); @@ -833,4 +871,12 @@ public class FishingManager extends Function { public void removeTotem(ActivatedTotem activatedTotem) { totemCache.remove(activatedTotem); } + + public void addPlayerToLavaFishing(Player player, BobberCheckTask task) { + this.lavaFishing.put(player, task); + } + + public void removePlayerFromLavaFishing(Player player) { + this.lavaFishing.remove(player); + } } diff --git a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java index a8f8f479..6649fbe7 100644 --- a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java @@ -36,10 +36,6 @@ public class IntegrationManager extends Function { private PlaceholderManager placeholderManager; private AntiGriefInterface[] antiGriefs; - public IntegrationManager() { - load(); - } - @Override public void load() { @@ -67,7 +63,9 @@ public class IntegrationManager extends Function { this.blockInterface = new ItemsAdderBlockImpl(); } else if (pluginManager.getPlugin("Oraxen") != null) { this.blockInterface = new OraxenBlockImpl(); - } else this.blockInterface = new VanillaBlockImpl(); + } else { + this.blockInterface = new VanillaBlockImpl(); + } if (pluginManager.getPlugin("eco") != null) { EcoItemRegister.registerItems(); diff --git a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java index 658ff8f8..bb349bb3 100644 --- a/src/main/java/net/momirealms/customfishing/manager/TotemManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/TotemManager.java @@ -1,5 +1,6 @@ package net.momirealms.customfishing.manager; +import net.momirealms.customfishing.CustomFishing; import net.momirealms.customfishing.integration.BlockInterface; import net.momirealms.customfishing.object.Function; import net.momirealms.customfishing.object.action.ActionInterface; @@ -30,11 +31,6 @@ public class TotemManager extends Function { public static HashMap> CORES; public static HashMap BLOCKS; public static HashMap INVERTED; - private final BlockInterface blockInterface; - - public TotemManager(BlockInterface blockInterface) { - this.blockInterface = blockInterface; - } @Override public void unload() { @@ -213,6 +209,8 @@ public class TotemManager extends Function { public int checkLocationModel(OriginalModel model, Location location){ + BlockInterface blockInterface = CustomFishing.plugin.getIntegrationManager().getBlockInterface(); + CorePos corePos = model.getCorePos(); int xOffset = corePos.getX(); int yOffset = corePos.getY(); @@ -388,6 +386,8 @@ public class TotemManager extends Function { public void removeModel(FinalModel model, Location location, int id) { + BlockInterface blockInterface = CustomFishing.plugin.getIntegrationManager().getBlockInterface(); + CorePos corePos = model.getCorePos(); int xOffset = corePos.getX(); int yOffset = corePos.getY(); diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java b/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java new file mode 100644 index 00000000..df272716 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/object/fishing/BobberCheckTask.java @@ -0,0 +1,127 @@ +package net.momirealms.customfishing.object.fishing; + +import com.plotsquared.core.plot.PlotId; +import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.manager.ConfigManager; +import net.momirealms.customfishing.manager.FishingManager; +import net.momirealms.customfishing.object.loot.Loot; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.FishHook; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; +import org.bukkit.util.Vector; + +import java.util.List; +import java.util.Random; + +public class BobberCheckTask extends BukkitRunnable { + + private final FishHook fishHook; + private int timer; + private final Player player; + private final Bonus bonus; + private final FishingManager fishingManager; + private boolean hooked; + private boolean first_time; + private int jump_timer; + private final int lureLevel; + private BukkitTask cache_1; + private BukkitTask cache_2; + private BukkitTask cache_3; + + public BobberCheckTask(Player player, Bonus bonus, FishHook fishHook, FishingManager fishingManager, int lureLevel) { + this.fishHook = fishHook; + this.fishingManager = fishingManager; + this.player = player; + this.timer = 0; + this.bonus = bonus; + this.first_time = true; + this.jump_timer = 0; + this.lureLevel = lureLevel; + } + + @Override + public void run() { + timer ++; + if (!fishHook.isValid()) { + stop(); + return; + } + if (fishHook.getLocation().getBlock().getType() == Material.LAVA) { + if (!bonus.canLavaFishing()) { + stop(); + return; + } + if (hooked) { + jump_timer++; + if (jump_timer < 5) { + return; + } + jump_timer = 0; + fishHook.setVelocity(new Vector(0,0.24,0)); + return; + } + if (first_time) { + first_time = false; + randomTime(); + } + fishHook.setVelocity(new Vector(0, 0.12,0)); + return; + } + if (fishHook.isInWater()) { + List possibleLoots = fishingManager.getPossibleWaterLootList(new FishingCondition(fishHook.getLocation(), player), false); + fishingManager.getNextLoot(player, bonus, possibleLoots); + stop(); + return; + } + if (fishHook.isOnGround()) { + stop(); + return; + } + if (timer > 2400) { + stop(); + } + } + + public void stop() { + cancel(); + cancelTask(); + } + + public void cancelTask() { + if (cache_1 != null) { + cache_1.cancel(); + cache_1 = null; + } + if (cache_2 != null) { + cache_2.cancel(); + cache_2 = null; + } + if (cache_3 != null) { + cache_3.cancel(); + cache_3 = null; + } + } + + private void randomTime() { + List possibleLoots = fishingManager.getPossibleLavaLootList(new FishingCondition(fishHook.getLocation(), player), false); + fishingManager.getNextLoot(player, bonus, possibleLoots); + cancelTask(); + int random = new Random().nextInt(ConfigManager.lavaMaxTime) + ConfigManager.lavaMinTime; + random -= lureLevel * 100; + random *= bonus.getTime(); + if (random < ConfigManager.lavaMinTime) random = ConfigManager.lavaMinTime; + cache_1 = Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> { + hooked = true; + fishingManager.addPlayerToLavaFishing(player, this); + }, random); + cache_2 = Bukkit.getScheduler().runTaskLater(CustomFishing.plugin, () -> { + hooked = false; + first_time = true; + fishingManager.removePlayerFromLavaFishing(player); + }, random + 40); + cache_3 = new LavaEffect(fishHook.getLocation()).runTaskTimerAsynchronously(CustomFishing.plugin,random - 60,1); + } +} diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java b/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java index d85c0769..c49bd470 100644 --- a/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java +++ b/src/main/java/net/momirealms/customfishing/object/fishing/Bonus.java @@ -12,6 +12,7 @@ public class Bonus { private double score; private int difficulty; private double doubleLoot; + private boolean canLavaFishing; public HashMap getWeightMD() { return weightMD; @@ -61,9 +62,17 @@ public class Bonus { this.doubleLoot = doubleLoot; } + public boolean canLavaFishing() { + return canLavaFishing; + } + + public void setCanLavaFishing(boolean canLavaFishing) { + this.canLavaFishing = canLavaFishing; + } + public void addBonus(Bonus anotherBonus) { HashMap weightAS = anotherBonus.getWeightAS(); - if (weightAS != null){ + if (weightAS != null) { for (Map.Entry en : weightAS.entrySet()) { String group = en.getKey(); this.weightAS.put(group, Optional.ofNullable(this.weightAS.get(group)).orElse(0) + en.getValue()); @@ -80,5 +89,6 @@ public class Bonus { if (anotherBonus.getDoubleLoot() != 0) this.doubleLoot += anotherBonus.getDoubleLoot(); if (anotherBonus.getDifficulty() != 0) this.difficulty += anotherBonus.getDifficulty(); if (anotherBonus.getScore() != 0) this.score += (anotherBonus.getScore() - 1); + if (anotherBonus.canLavaFishing()) this.canLavaFishing = true; } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java b/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java new file mode 100644 index 00000000..6b173342 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/object/fishing/LavaEffect.java @@ -0,0 +1,34 @@ +package net.momirealms.customfishing.object.fishing; + +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.scheduler.BukkitRunnable; + + +public class LavaEffect extends BukkitRunnable { + + private final Location startLoc; + private final Location endLoc; + private final Location controlLoc; + private int timer; + + public LavaEffect(Location loc) { + this.startLoc = loc.clone().add(0,0.3,0); + this.endLoc = this.startLoc.clone().add((Math.random() * 16 - 8), startLoc.getY(), (Math.random() * 16 - 8)); + this.controlLoc = new Location(startLoc.getWorld(), (startLoc.getX() + endLoc.getX())/2 + Math.random() * 12 - 6, startLoc.getY(), (startLoc.getZ() + endLoc.getZ())/2 + Math.random() * 12 - 6); + } + + @Override + public void run() { + timer++; + if (timer > 60) { + cancel(); + } + else { + double t = (double) timer / 60; + Location particleLoc = endLoc.clone().multiply(Math.pow((1 - t), 2)).add(controlLoc.clone().multiply(2 * t * (1 - t))).add(startLoc.clone().multiply(Math.pow(t, 2))); + particleLoc.setY(startLoc.getY()); + startLoc.getWorld().spawnParticle(Particle.FLAME, particleLoc,1,0,0,0,0); + } + } +} diff --git a/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java b/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java index 237d1a17..344a2112 100644 --- a/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java +++ b/src/main/java/net/momirealms/customfishing/util/ConfigUtil.java @@ -38,6 +38,8 @@ public class ConfigUtil { CustomFishing.plugin.getCompetitionManager().load(); CustomFishing.plugin.getTotemManager().unload(); CustomFishing.plugin.getTotemManager().load(); + CustomFishing.plugin.getIntegrationManager().unload(); + CustomFishing.plugin.getIntegrationManager().load(); try { Reflection.load(); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 45c806fb..926f3de5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -22,6 +22,7 @@ worlds: mode: whitelist list: - world + - world_nether mechanics: @@ -48,7 +49,7 @@ mechanics: # The same to vanilla (refer to the wiki) # https://technical-minecraft.fandom.com/wiki/Fishing - need-open-water: true + need-open-water: false need-special-rod: # Players must use rods with CustomFishing's NBT Tags to get loots in CustomFishing but they can experience the special fishing mechanic. @@ -75,6 +76,11 @@ mechanics: # File/SQLite/MySql data-storage-mode: File + lava-fishing: + # ticks + min-time: 100 + max-time: 600 + titles: success: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index caa715cd..5837e011 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -25,4 +25,8 @@ commands: description: main command permission: customfishing.admin aliases: - - cfishing \ No newline at end of file + - cfishing + fishingbag: + usage: /fishingbag open + description: fishing bag command + permission: customfishing.user \ No newline at end of file diff --git a/src/main/resources/rods/default.yml b/src/main/resources/rods/default.yml index 269e1cfe..888ed941 100644 --- a/src/main/resources/rods/default.yml +++ b/src/main/resources/rods/default.yml @@ -18,6 +18,7 @@ silver_fishing_rod: display: name: 'Silver Fishing Rod' custom-model-data: 3 + can-fish-in-lave: true modifier: weight-add: silver: 20