Skip to content

Commit

Permalink
Allow lava_cauldrons to kill minecarts. (#5507)
Browse files Browse the repository at this point in the history
* Allow lava cauldrons to kill minecarts.

Closes #5503.

* Simplify block drop.

* Use an ItemLists for Minecart killing blocks because Lava_Cauldron was
only added 1.17+
  • Loading branch information
LlmDl authored Dec 6, 2021
1 parent 5ee36b6 commit a1a7e77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.palmergames.bukkit.towny.listeners;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
Expand All @@ -18,6 +17,7 @@
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.event.executors.TownyActionEventExecutor;
import com.palmergames.bukkit.towny.utils.EntityTypeUtil;
import com.palmergames.bukkit.util.ItemLists;

/**
* Handle events for all Vehicle related events
Expand Down Expand Up @@ -108,9 +108,9 @@ public void onVehicleCollide(VehicleBlockCollisionEvent event) {
if (plugin.isError() || !TownyAPI.getInstance().isTownyWorld(event.getVehicle().getWorld()))
return;

if (event.getBlock().getType() == Material.CACTUS && event.getVehicle() instanceof Minecart) {
if (event.getVehicle() instanceof Minecart && ItemLists.MINECART_KILLERS.contains(event.getBlock().getType().name())) {
event.getVehicle().remove();
Bukkit.getWorld(event.getBlock().getWorld().getName()).dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(EntityTypeUtil.parseEntityToMaterial(event.getVehicle().getType())));
event.getBlock().getWorld().dropItemNaturally(event.getVehicle().getLocation(), new ItemStack(EntityTypeUtil.parseEntityToMaterial(event.getVehicle().getType())));
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/com/palmergames/bukkit/util/ItemLists.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ public class ItemLists {
* List of harvestable berries
*/
public static List<String> HARVESTABLE_BERRIES = new ArrayList<>(Arrays.asList("CAVE_VINES_PLANT","SWEET_BERRY_BUSH"));


/*
* List of blocks which will be allowed to kill Minecarts.
*/
public static List<String> MINECART_KILLERS = new ArrayList<>(Arrays.asList("CACTUS","LAVA_CAULDRON"));

/**
* Returns a pre-configured list from the GROUPS.
Expand Down

0 comments on commit a1a7e77

Please sign in to comment.