Fishing is now more aggressive about over casting, added messages about fishing, removed vanilla rewards for exploiters

This commit is contained in:
nossr50
2019-03-18 00:26:49 -07:00
parent e3d2526939
commit fef9058e16
4 changed files with 49 additions and 12 deletions

View File

@ -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;

View File

@ -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) {