Eject players from Minecarts if they cast a fishing rod (Anti-AFK)

This commit is contained in:
nossr50 2019-03-23 21:01:40 -07:00
parent 6d19239db7
commit b68bbad766

View File

@ -34,6 +34,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; 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(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(); mcMMOPlayer.getFishingManager().setFishingRodCastTimestamp();
} }
} }