Skip to content
Permalink
Browse files

Added an option to not damage players with MinecartRemoveEntities.

  • Loading branch information...
me4502 committed Mar 16, 2019
1 parent 8a70489 commit e6cf826d039c276d74b35b2c62c51a89a26066e3
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/main/java/com/sk89q/craftbook/mechanics/minecart/RemoveEntities.java
@@ -2,6 +2,7 @@

import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.minecart.RideableMinecart;
import org.bukkit.event.EventHandler;
@@ -26,6 +27,10 @@ public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {
if (!otherCarts && (event.getEntity() instanceof Minecart || event.getEntity().isInsideVehicle()))
return;

if (!players && event.getEntity() instanceof Player) {
return;
}

if(event.getVehicle() instanceof RideableMinecart && event.getVehicle().isEmpty() && !empty)
return;

@@ -53,6 +58,7 @@ public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {

private boolean otherCarts;
private boolean empty;
private boolean players;

@Override
public void loadConfiguration (YAMLProcessor config, String path) {
@@ -62,5 +68,8 @@ public void loadConfiguration (YAMLProcessor config, String path) {

config.setComment(path + "allow-empty-carts", "Allows the cart to be empty.");
empty = config.getBoolean(path + "allow-empty-carts", false);

config.setComment(path + "damage-players", "Allows the cart to damage and kill players.");
players = config.getBoolean(path + "damage-players", true);
}
}

0 comments on commit e6cf826

Please sign in to comment.
You can’t perform that action at this time.