From b68bbad76642470194ac5708ff105cd422a3d52c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 23 Mar 2019 21:01:40 -0700 Subject: [PATCH] Eject players from Minecarts if they cast a fishing rod (Anti-AFK) --- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 55c1a8776..5b169b8d4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -34,6 +34,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.*; +import org.bukkit.entity.minecart.PoweredMinecart; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -649,6 +650,12 @@ public class PlayerListener implements Listener { { if(heldItem.getType() == Material.FISHING_ROD || player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD) { + if(player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart)) + { + player.getVehicle().eject(); + player.setVelocity(player.getEyeLocation().getDirection().multiply(10)); + } + mcMMOPlayer.getFishingManager().setFishingRodCastTimestamp(); } }