Prevent non-player entities riding in the Minecart Mount
This commit is contained in:
parent
b8c19d53af
commit
6a453b296c
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user