mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Expand API for McMMOPlayerMasterAnglerEvent
This commit is contained in:
parent
827b894257
commit
19bf96ab33
@ -1,14 +1,53 @@
|
|||||||
package com.gmail.nossr50.events.skills.fishing;
|
package com.gmail.nossr50.events.skills.fishing;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class McMMOPlayerMasterAnglerEvent extends McMMOPlayerFishingEvent {
|
public class McMMOPlayerMasterAnglerEvent extends McMMOPlayerFishingEvent {
|
||||||
|
private int reducedMinWaitTime;
|
||||||
|
private int reducedMaxWaitTime;
|
||||||
|
private final FishingManager fishingManager;
|
||||||
|
|
||||||
public McMMOPlayerMasterAnglerEvent(@NotNull McMMOPlayer mcMMOPlayer) {
|
public McMMOPlayerMasterAnglerEvent(@NotNull McMMOPlayer mcMMOPlayer,
|
||||||
|
int reducedMinWaitTime,
|
||||||
|
int reducedMaxWaitTime,
|
||||||
|
FishingManager fishingManager) {
|
||||||
super(mcMMOPlayer);
|
super(mcMMOPlayer);
|
||||||
|
this.fishingManager = fishingManager;
|
||||||
|
this.reducedMinWaitTime = Math.max(reducedMinWaitTime, getReducedMinWaitTimeLowerBound());
|
||||||
|
this.reducedMaxWaitTime = Math.max(reducedMaxWaitTime, getReducedMaxWaitTimeLowerBound());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getReducedMinWaitTime() {
|
||||||
|
return reducedMinWaitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReducedMinWaitTime(int reducedMinWaitTime) {
|
||||||
|
if (reducedMinWaitTime < 0 || reducedMinWaitTime > reducedMaxWaitTime) {
|
||||||
|
throw new IllegalArgumentException("Reduced min wait time must be greater than or equal to 0" +
|
||||||
|
" and less than reduced max wait time.");
|
||||||
|
}
|
||||||
|
this.reducedMinWaitTime = Math.max(reducedMinWaitTime, getReducedMinWaitTimeLowerBound());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReducedMaxWaitTime() {
|
||||||
|
return reducedMaxWaitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReducedMaxWaitTime(int reducedMaxWaitTime) {
|
||||||
|
if (reducedMaxWaitTime < 0 || reducedMaxWaitTime < reducedMinWaitTime) {
|
||||||
|
throw new IllegalArgumentException("Reduced max wait time must be greater than or equal to 0" +
|
||||||
|
" and greater than reduced min wait time.");
|
||||||
|
}
|
||||||
|
this.reducedMaxWaitTime = Math.max(reducedMaxWaitTime, getReducedMaxWaitTimeLowerBound());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReducedMinWaitTimeLowerBound() {
|
||||||
|
return fishingManager.getMasterAnglerMinWaitLowerBound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReducedMaxWaitTimeLowerBound() {
|
||||||
|
return fishingManager.getMasterAnglerMaxWaitLowerBound();
|
||||||
|
}
|
||||||
}
|
}
|
@ -56,9 +56,17 @@ public class FishingManager extends SkillManager {
|
|||||||
private Item fishingCatch;
|
private Item fishingCatch;
|
||||||
private Location hookLocation;
|
private Location hookLocation;
|
||||||
private int fishCaughtCounter = 1;
|
private int fishCaughtCounter = 1;
|
||||||
|
private final int masterAnglerMinWaitLowerBound;
|
||||||
|
private final int masterAnglerMaxWaitLowerBound;
|
||||||
|
|
||||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
super(mcMMOPlayer, PrimarySkillType.FISHING);
|
super(mcMMOPlayer, PrimarySkillType.FISHING);
|
||||||
|
//Ticks for minWait and maxWait never go below this value
|
||||||
|
int bonusCapMin = mcMMO.p.getAdvancedConfig().getFishingReductionMinWaitCap();
|
||||||
|
int bonusCapMax = mcMMO.p.getAdvancedConfig().getFishingReductionMaxWaitCap();
|
||||||
|
|
||||||
|
this.masterAnglerMinWaitLowerBound = Math.max(bonusCapMin, 0);
|
||||||
|
this.masterAnglerMaxWaitLowerBound = Math.max(bonusCapMax, masterAnglerMinWaitLowerBound + 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canShake(Entity target) {
|
public boolean canShake(Entity target) {
|
||||||
@ -254,13 +262,6 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param fishHook target fish hook
|
* @param fishHook target fish hook
|
||||||
*/
|
*/
|
||||||
public void processMasterAngler(@NotNull FishHook fishHook, int lureLevel) {
|
public void processMasterAngler(@NotNull FishHook fishHook, int lureLevel) {
|
||||||
McMMOPlayerMasterAnglerEvent event = new McMMOPlayerMasterAnglerEvent(mmoPlayer);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MasterAnglerCompatibilityLayer masterAnglerCompatibilityLayer = (MasterAnglerCompatibilityLayer) mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer();
|
MasterAnglerCompatibilityLayer masterAnglerCompatibilityLayer = (MasterAnglerCompatibilityLayer) mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer();
|
||||||
|
|
||||||
if (masterAnglerCompatibilityLayer != null) {
|
if (masterAnglerCompatibilityLayer != null) {
|
||||||
@ -280,12 +281,8 @@ public class FishingManager extends SkillManager {
|
|||||||
int minWaitReduction = getMasterAnglerTickMinWaitReduction(masterAnglerRank, boatBonus);
|
int minWaitReduction = getMasterAnglerTickMinWaitReduction(masterAnglerRank, boatBonus);
|
||||||
int maxWaitReduction = getMasterAnglerTickMaxWaitReduction(masterAnglerRank, boatBonus, convertedLureBonus);
|
int maxWaitReduction = getMasterAnglerTickMaxWaitReduction(masterAnglerRank, boatBonus, convertedLureBonus);
|
||||||
|
|
||||||
//Ticks for minWait and maxWait never go below this value
|
int reducedMinWaitTime = getReducedTicks(minWaitTicks, minWaitReduction, masterAnglerMinWaitLowerBound);
|
||||||
int bonusCapMin = mcMMO.p.getAdvancedConfig().getFishingReductionMinWaitCap();
|
int reducedMaxWaitTime = getReducedTicks(maxWaitTicks, maxWaitReduction, masterAnglerMaxWaitLowerBound);
|
||||||
int bonusCapMax = mcMMO.p.getAdvancedConfig().getFishingReductionMaxWaitCap();
|
|
||||||
|
|
||||||
int reducedMinWaitTime = getReducedTicks(minWaitTicks, minWaitReduction, bonusCapMin);
|
|
||||||
int reducedMaxWaitTime = getReducedTicks(maxWaitTicks, maxWaitReduction, bonusCapMax);
|
|
||||||
|
|
||||||
boolean badValuesFix = false;
|
boolean badValuesFix = false;
|
||||||
|
|
||||||
@ -295,11 +292,23 @@ public class FishingManager extends SkillManager {
|
|||||||
badValuesFix = true;
|
badValuesFix = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final McMMOPlayerMasterAnglerEvent event =
|
||||||
|
new McMMOPlayerMasterAnglerEvent(mmoPlayer, reducedMinWaitTime, reducedMaxWaitTime, this);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
reducedMaxWaitTime = event.getReducedMaxWaitTime();
|
||||||
|
reducedMinWaitTime = event.getReducedMinWaitTime();
|
||||||
|
|
||||||
if (mmoPlayer.isDebugMode()) {
|
if (mmoPlayer.isDebugMode()) {
|
||||||
mmoPlayer.getPlayer().sendMessage(ChatColor.GOLD + "Master Angler Debug");
|
mmoPlayer.getPlayer().sendMessage(ChatColor.GOLD + "Master Angler Debug");
|
||||||
|
|
||||||
if (badValuesFix) {
|
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(ChatColor.RED + "Bad values were applied and corrected," +
|
||||||
|
" check your configs, minWaitLowerBound 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));
|
||||||
@ -326,8 +335,8 @@ public class FishingManager extends SkillManager {
|
|||||||
mmoPlayer.getPlayer().sendMessage("");
|
mmoPlayer.getPlayer().sendMessage("");
|
||||||
|
|
||||||
mmoPlayer.getPlayer().sendMessage(ChatColor.DARK_AQUA + "Caps / Limits (edit in advanced.yml)");
|
mmoPlayer.getPlayer().sendMessage(ChatColor.DARK_AQUA + "Caps / Limits (edit in advanced.yml)");
|
||||||
mmoPlayer.getPlayer().sendMessage("Lowest possible max wait ticks " + bonusCapMax);
|
mmoPlayer.getPlayer().sendMessage("Lowest possible minWaitLowerBound wait ticks " + masterAnglerMinWaitLowerBound);
|
||||||
mmoPlayer.getPlayer().sendMessage("Lowest possible min wait ticks " + bonusCapMin);
|
mmoPlayer.getPlayer().sendMessage("Lowest possible min wait ticks " + masterAnglerMaxWaitLowerBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
masterAnglerCompatibilityLayer.setMaxWaitTime(fishHook, reducedMaxWaitTime);
|
masterAnglerCompatibilityLayer.setMaxWaitTime(fishHook, reducedMaxWaitTime);
|
||||||
@ -724,4 +733,12 @@ public class FishingManager extends SkillManager {
|
|||||||
private int getVanillaXpMultiplier() {
|
private int getVanillaXpMultiplier() {
|
||||||
return getVanillaXPBoostModifier();
|
return getVanillaXPBoostModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMasterAnglerMinWaitLowerBound() {
|
||||||
|
return masterAnglerMinWaitLowerBound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMasterAnglerMaxWaitLowerBound() {
|
||||||
|
return masterAnglerMaxWaitLowerBound;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user