Prevent non-player entities riding in the Minecart Mount

This commit is contained in:
Sam 2018-03-03 15:30:35 +00:00 committed by Alexander Meech
parent b8c19d53af
commit 6a453b296c

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
@ -70,7 +71,25 @@ public class MountCart extends Mount<SingleEntityMountData<Minecart>>
}
}
}
@EventHandler
public void vehicleEnter(VehicleEnterEvent event)
{
if (event.getEntered() instanceof Player)
{
return;
}
for (SingleEntityMountData<Minecart> data : getActiveMounts().values())
{
if (data.getEntity().equals(event.getVehicle()))
{
event.setCancelled(true);
return;
}
}
}
@EventHandler
public void cancelBreak(VehicleDamageEvent event)
{
@ -79,6 +98,7 @@ public class MountCart extends Mount<SingleEntityMountData<Minecart>>
if (data.getEntity().equals(event.getVehicle()))
{
event.setCancelled(true);
return;
}
}
}