diff --git a/Changelog.txt b/Changelog.txt index ecebaff20..70591966c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,9 @@ Key: Version 2.1.19 Improved Fishing AFK detection Fixed a bug where Fishing AFK detection did not work on a new exploit + Fishing now drops several hints to players if they are triggering the exploit detection + Added messages to warn players about fishing in the same spot + Added messages to warn players about casting too often Version 2.1.18 You will need to add Kelp to your experience.yml file for this fix to be fully functional diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index fbd841aab..eda9ae132 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -29,7 +29,6 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block; @@ -320,10 +319,23 @@ public class PlayerListener implements Listener { return; } + Entity caught = event.getCaught(); FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); - Entity caught = event.getCaught(); - //event.setExpToDrop(event.getExpToDrop()); //Redundant? + //Fishing Too Often + if(event.getState() != PlayerFishEvent.State.CAUGHT_ENTITY && fishingManager.isFishingTooOften()) + { + event.setExpToDrop(0); + event.setCancelled(true); + + if(caught instanceof Item) + { + Item caughtItem = (Item) caught; + caughtItem.remove(); + } + + return; + } switch (event.getState()) { case FISHING: @@ -333,8 +345,15 @@ public class PlayerListener implements Listener { } return; case CAUGHT_FISH: - if(fishingManager.exploitPrevention(event.getHook().getLocation().toVector())) + if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) + { + event.setExpToDrop(0); + event.setCancelled(true); + Item caughtItem = (Item) caught; + caughtItem.remove(); return; + } + fishingManager.handleFishing((Item) caught); fishingManager.setFishingTarget(); return; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 62696dca1..fb479f55e 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -15,6 +15,7 @@ import com.gmail.nossr50.datatypes.treasure.Rarity; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.player.NotificationManager; @@ -59,7 +60,21 @@ public class FishingManager extends SkillManager { return getSkillLevel() >= RankUtils.getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER); } - public boolean exploitPrevention(Vector centerOfCastVector) { + public boolean isFishingTooOften() + { + long currentTime = System.currentTimeMillis(); + boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10)); + + if(hasFished) + { + getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scared")); + fishingTimestamp = currentTime; + } + + return hasFished; + } + + public boolean isExploitingFishing(Vector centerOfCastVector) { /*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); @@ -70,12 +85,6 @@ public class FishingManager extends SkillManager { if(lastFishingBoundingBox == null) lastFishingBoundingBox = makeBoundingBox(centerOfCastVector); - long currentTime = System.currentTimeMillis(); - boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10)); - - if(hasFished) - fishingTimestamp = currentTime; - BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); boolean sameTarget = lastFishingBoundingBox.overlaps(newCastBoundingBox); @@ -83,8 +92,12 @@ public class FishingManager extends SkillManager { //If the new bounding box does not intersect with the old one, then update our bounding box reference if(!sameTarget) lastFishingBoundingBox = newCastBoundingBox; + else + { + getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scarcity")); + } - return hasFished || sameTarget; + return sameTarget; } public static BoundingBox makeBoundingBox(Vector centerOfCastVector) { diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 6df1f5c84..d0e983632 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -217,6 +217,8 @@ Excavation.Skills.GigaDrillBreaker.Refresh=[[GREEN]]Your [[YELLOW]]Giga Drill Br Excavation.Skills.GigaDrillBreaker.Other.Off=Giga Drill Breaker[[GREEN]] has worn off for [[YELLOW]]{0} Excavation.Skills.GigaDrillBreaker.Other.On=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]Giga Drill Breaker! #FISHING +Fishing.Scarcity=[[YELLOW]]&oThis area is suffering from overfishing, try fishing in a new area. +Fishing.Scared=[[GRAY]]&oChaotic movements will scare fish! Fishing.Ability.Info=Magic Hunter: [[GRAY]] **Improves With Treasure Hunter Rank** Fishing.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (SHAKE) Fishing.Ability.Locked.1=LOCKED UNTIL {0}+ SKILL (ICE FISHING)