Propose: Add an option for Exploiting Fishing. (#4619)

* feat: Add exploiting option for fishing

* Update experience.yml

Let's change how this was named

* Update ExperienceConfig.java

Let's change how this was named

Co-authored-by: Robert Alan Chapton <nossr50@gmail.com>
This commit is contained in:
tunagohan 2021-09-23 07:11:54 +09:00 committed by GitHub
parent 162c605dac
commit 7fc6577196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 8 deletions

View File

@ -155,6 +155,9 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
public boolean isNPCInteractionPrevented() { return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true); } public boolean isNPCInteractionPrevented() { return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true); }
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); } public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
public int getFishingExploitingOptionMoveRange() { return config.getInt("Fishing_ExploitFix_Options.MoveRange", 3); }
public int getFishingExploitingOptionOverFishLimit() { return config.getInt("Fishing_ExploitFix_Options.OverFishLimit", 10); }
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); } public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); } public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); }

View File

@ -449,7 +449,7 @@ public class PlayerListener implements Listener {
if(caught instanceof Item) { if(caught instanceof Item) {
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3)); player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
event.setExpToDrop(0); event.setExpToDrop(0);
Item caughtItem = (Item) caught; Item caughtItem = (Item) caught;
caughtItem.remove(); caughtItem.remove();

View File

@ -43,7 +43,6 @@ import java.util.*;
public class FishingManager extends SkillManager { public class FishingManager extends SkillManager {
public static final int FISHING_ROD_CAST_CD_MILLISECONDS = 100; public static final int FISHING_ROD_CAST_CD_MILLISECONDS = 100;
public static final int OVERFISH_LIMIT = 10;
private final long FISHING_COOLDOWN_SECONDS = 1000L; private final long FISHING_COOLDOWN_SECONDS = 1000L;
private long fishingRodCastTimestamp = 0L; private long fishingRodCastTimestamp = 0L;
@ -143,20 +142,21 @@ public class FishingManager extends SkillManager {
else else
fishCaughtCounter = 1; fishCaughtCounter = 1;
if(fishCaughtCounter + 1 == OVERFISH_LIMIT) if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit())
{ {
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", 3)); getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
} }
//If the new bounding box does not intersect with the old one, then update our bounding box reference //If the new bounding box does not intersect with the old one, then update our bounding box reference
if(!sameTarget) if(!sameTarget)
lastFishingBoundingBox = newCastBoundingBox; lastFishingBoundingBox = newCastBoundingBox;
return sameTarget && fishCaughtCounter >= OVERFISH_LIMIT; return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
} }
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) { public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
return BoundingBox.of(centerOfCastVector, 1, 1, 1); int exploitingRange = ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange();
return BoundingBox.of(centerOfCastVector, exploitingRange / 2, 1, exploitingRange / 2);
} }
public void setFishingTarget() { public void setFishingTarget() {

View File

@ -39,6 +39,9 @@ ExploitFix:
# mcMMO normally doesn't process attacks against an Entity if it is an NPC from another plugin # mcMMO normally doesn't process attacks against an Entity if it is an NPC from another plugin
# Of course, mcMMO doesn't know for sure whether or not something is an NPC, it checks a few known things, see our source code to see how # Of course, mcMMO doesn't know for sure whether or not something is an NPC, it checks a few known things, see our source code to see how
PreventPluginNPCInteraction: true PreventPluginNPCInteraction: true
Fishing_ExploitFix_Options:
MoveRange: 3
OverFishLimit: 10
Experience_Bars: Experience_Bars:
# Turn this to false if you wanna disable XP bars # Turn this to false if you wanna disable XP bars
Enable: true Enable: true