mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fix Lure above 3 breaking fishing
This commit is contained in:
parent
f346d3b758
commit
cfcdcd1676
@ -1,3 +1,9 @@
|
|||||||
|
Version 2.1.158
|
||||||
|
Fixed a bug where Lure level 4 and above would break fishing with the new Master Angler
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Master Angler will emulate the effects of Lure if the level is higher than 3 instead of attempting to stack with it to avoid a vanilla Minecraft bug where fish are never caught
|
||||||
|
|
||||||
Version 2.1.157
|
Version 2.1.157
|
||||||
Fixed a NPE that prevented mctop (Leaderboards) from working
|
Fixed a NPE that prevented mctop (Leaderboards) from working
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>2.1.157</version>
|
<version>2.1.158-SNAPSHOT</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -92,7 +92,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
// MASTER ANGLER
|
// MASTER ANGLER
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
maMinWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMinWaitReduction(RankUtils.getRank(player, SubSkillType.FISHING_MASTER_ANGLER), false));
|
maMinWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMinWaitReduction(RankUtils.getRank(player, SubSkillType.FISHING_MASTER_ANGLER), false));
|
||||||
maMaxWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMaxWaitReduction(RankUtils.getRank(player, SubSkillType.FISHING_MASTER_ANGLER), false));
|
maMaxWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMaxWaitReduction(RankUtils.getRank(player, SubSkillType.FISHING_MASTER_ANGLER), false, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.minecart.PoweredMinecart;
|
import org.bukkit.entity.minecart.PoweredMinecart;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -387,7 +388,21 @@ public class PlayerListener implements Listener {
|
|||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case FISHING:
|
case FISHING:
|
||||||
if (fishingManager.canMasterAngler()) {
|
if (fishingManager.canMasterAngler()) {
|
||||||
fishingManager.masterAngler(event.getHook());
|
int lureLevel = 0;
|
||||||
|
ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
|
//Grab lure level
|
||||||
|
if(inHand != null && inHand.getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) {
|
||||||
|
if(inHand.getItemMeta().hasEnchants()) {
|
||||||
|
for(Enchantment enchantment : inHand.getItemMeta().getEnchants().keySet()) {
|
||||||
|
if(enchantment.toString().toLowerCase().contains("lure")) {
|
||||||
|
lureLevel = inHand.getEnchantmentLevel(enchantment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fishingManager.masterAngler(event.getHook(), lureLevel);
|
||||||
fishingManager.setFishingTarget();
|
fishingManager.setFishingTarget();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -8,14 +8,16 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class MasterAnglerTask extends BukkitRunnable {
|
public class MasterAnglerTask extends BukkitRunnable {
|
||||||
private final @NotNull FishHook fishHook;
|
private final @NotNull FishHook fishHook;
|
||||||
private final @NotNull FishingManager fishingManager;
|
private final @NotNull FishingManager fishingManager;
|
||||||
|
private final int lureLevel;
|
||||||
|
|
||||||
public MasterAnglerTask(@NotNull FishHook fishHook, @NotNull FishingManager fishingManager) {
|
public MasterAnglerTask(@NotNull FishHook fishHook, @NotNull FishingManager fishingManager, int lureLevel) {
|
||||||
this.fishHook = fishHook;
|
this.fishHook = fishHook;
|
||||||
this.fishingManager = fishingManager;
|
this.fishingManager = fishingManager;
|
||||||
|
this.lureLevel = lureLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fishingManager.processMasterAngler(fishHook);
|
fishingManager.processMasterAngler(fishHook, lureLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,8 +247,8 @@ public class FishingManager extends SkillManager {
|
|||||||
EventUtils.callFakeFishEvent(getPlayer(), hook);
|
EventUtils.callFakeFishEvent(getPlayer(), hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void masterAngler(@NotNull FishHook hook) {
|
public void masterAngler(@NotNull FishHook hook, int lureLevel) {
|
||||||
new MasterAnglerTask(hook, this).runTaskLater(mcMMO.p, 0); //We run later to get the lure bonus applied
|
new MasterAnglerTask(hook, this, lureLevel).runTaskLater(mcMMO.p, 0); //We run later to get the lure bonus applied
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -256,7 +256,7 @@ public class FishingManager extends SkillManager {
|
|||||||
* Reduced tick time on fish hook, etc
|
* Reduced tick time on fish hook, etc
|
||||||
* @param fishHook target fish hook
|
* @param fishHook target fish hook
|
||||||
*/
|
*/
|
||||||
public void processMasterAngler(@NotNull FishHook fishHook) {
|
public void processMasterAngler(@NotNull FishHook fishHook, int lureLevel) {
|
||||||
MasterAnglerCompatibilityLayer masterAnglerCompatibilityLayer = (MasterAnglerCompatibilityLayer) mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer();
|
MasterAnglerCompatibilityLayer masterAnglerCompatibilityLayer = (MasterAnglerCompatibilityLayer) mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer();
|
||||||
|
|
||||||
if(masterAnglerCompatibilityLayer != null) {
|
if(masterAnglerCompatibilityLayer != null) {
|
||||||
@ -264,10 +264,17 @@ public class FishingManager extends SkillManager {
|
|||||||
int minWaitTicks = masterAnglerCompatibilityLayer.getMinWaitTime(fishHook);
|
int minWaitTicks = masterAnglerCompatibilityLayer.getMinWaitTime(fishHook);
|
||||||
|
|
||||||
int masterAnglerRank = RankUtils.getRank(mmoPlayer, SubSkillType.FISHING_MASTER_ANGLER);
|
int masterAnglerRank = RankUtils.getRank(mmoPlayer, SubSkillType.FISHING_MASTER_ANGLER);
|
||||||
|
int convertedLureBonus = 0;
|
||||||
|
|
||||||
|
//This avoids a Minecraft bug where lure levels above 3 break fishing
|
||||||
|
if(lureLevel > 3) {
|
||||||
|
masterAnglerCompatibilityLayer.setApplyLure(fishHook, false);
|
||||||
|
convertedLureBonus = lureLevel * 100;
|
||||||
|
}
|
||||||
|
|
||||||
boolean boatBonus = isInBoat();
|
boolean boatBonus = isInBoat();
|
||||||
int minWaitReduction = getMasterAnglerTickMinWaitReduction(masterAnglerRank, boatBonus);
|
int minWaitReduction = getMasterAnglerTickMinWaitReduction(masterAnglerRank, boatBonus);
|
||||||
int maxWaitReduction = getMasterAnglerTickMaxWaitReduction(masterAnglerRank, boatBonus);
|
int maxWaitReduction = getMasterAnglerTickMaxWaitReduction(masterAnglerRank, boatBonus, convertedLureBonus);
|
||||||
|
|
||||||
//Ticks for minWait and maxWait never go below this value
|
//Ticks for minWait and maxWait never go below this value
|
||||||
int bonusCapMin = AdvancedConfig.getInstance().getFishingReductionMinWaitCap();
|
int bonusCapMin = AdvancedConfig.getInstance().getFishingReductionMinWaitCap();
|
||||||
@ -276,9 +283,21 @@ public class FishingManager extends SkillManager {
|
|||||||
int reducedMinWaitTime = getReducedTicks(minWaitTicks, minWaitReduction, bonusCapMin);
|
int reducedMinWaitTime = getReducedTicks(minWaitTicks, minWaitReduction, bonusCapMin);
|
||||||
int reducedMaxWaitTime = getReducedTicks(maxWaitTicks, maxWaitReduction, bonusCapMax);
|
int reducedMaxWaitTime = getReducedTicks(maxWaitTicks, maxWaitReduction, bonusCapMax);
|
||||||
|
|
||||||
|
boolean badValuesFix = false;
|
||||||
|
|
||||||
|
//If we find bad values correct it
|
||||||
|
if(reducedMaxWaitTime < reducedMinWaitTime) {
|
||||||
|
reducedMaxWaitTime = reducedMinWaitTime + 100;
|
||||||
|
badValuesFix = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(mmoPlayer.isDebugMode()) {
|
if(mmoPlayer.isDebugMode()) {
|
||||||
mmoPlayer.getPlayer().sendMessage(ChatColor.GOLD + "Master Angler Debug");
|
mmoPlayer.getPlayer().sendMessage(ChatColor.GOLD + "Master Angler Debug");
|
||||||
|
|
||||||
|
if(badValuesFix) {
|
||||||
|
mmoPlayer.getPlayer().sendMessage(ChatColor.RED + "Bad values were applied and corrected, check your configs, max wait should never be lower than min wait.");
|
||||||
|
}
|
||||||
|
|
||||||
mmoPlayer.getPlayer().sendMessage("ALLOW STACK WITH LURE: " + masterAnglerCompatibilityLayer.getApplyLure(fishHook));
|
mmoPlayer.getPlayer().sendMessage("ALLOW STACK WITH LURE: " + masterAnglerCompatibilityLayer.getApplyLure(fishHook));
|
||||||
mmoPlayer.getPlayer().sendMessage("MIN TICK REDUCTION: " + minWaitReduction);
|
mmoPlayer.getPlayer().sendMessage("MIN TICK REDUCTION: " + minWaitReduction);
|
||||||
mmoPlayer.getPlayer().sendMessage("MAX TICK REDUCTION: " + maxWaitReduction);
|
mmoPlayer.getPlayer().sendMessage("MAX TICK REDUCTION: " + maxWaitReduction);
|
||||||
@ -321,13 +340,15 @@ public class FishingManager extends SkillManager {
|
|||||||
return mmoPlayer.getPlayer().isInsideVehicle() && mmoPlayer.getPlayer().getVehicle() instanceof Boat;
|
return mmoPlayer.getPlayer().isInsideVehicle() && mmoPlayer.getPlayer().getVehicle() instanceof Boat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMasterAnglerTickMaxWaitReduction(int masterAnglerRank, boolean boatBonus) {
|
public int getMasterAnglerTickMaxWaitReduction(int masterAnglerRank, boolean boatBonus, int emulatedLureBonus) {
|
||||||
int totalBonus = AdvancedConfig.getInstance().getFishingReductionMaxWaitTicks() * masterAnglerRank;
|
int totalBonus = AdvancedConfig.getInstance().getFishingReductionMaxWaitTicks() * masterAnglerRank;
|
||||||
|
|
||||||
if(boatBonus) {
|
if(boatBonus) {
|
||||||
totalBonus += getFishingBoatMaxWaitReduction();
|
totalBonus += getFishingBoatMaxWaitReduction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totalBonus += emulatedLureBonus;
|
||||||
|
|
||||||
return totalBonus;
|
return totalBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user