Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.coreprotect.listener.player;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
Expand Down Expand Up @@ -595,9 +596,11 @@ else if (type == Material.DRAGON_EGG) {
}

if (event.useItemInHand() != Event.Result.DENY) {
List<Material> entityBlockTypes = Arrays.asList(Material.ARMOR_STAND, Material.END_CRYSTAL, Material.BOW, Material.CROSSBOW, Material.TRIDENT, Material.EXPERIENCE_BOTTLE, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.ENDER_PEARL, Material.FIREWORK_ROCKET, Material.EGG, Material.SNOWBALL);
List<Material> entityBlockTypes = new ArrayList<>(Arrays.asList(Material.ARMOR_STAND, Material.END_CRYSTAL, Material.BOW, Material.CROSSBOW, Material.TRIDENT, Material.EXPERIENCE_BOTTLE, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.ENDER_PEARL, Material.FIREWORK_ROCKET, Material.EGG, Material.SNOWBALL));
try {
entityBlockTypes.add(Material.valueOf("WIND_CHARGE"));
entityBlockTypes.add(Material.valueOf("BLUE_EGG"));
entityBlockTypes.add(Material.valueOf("BROWN_EGG"));
}
catch (Exception e) {
// not running MC 1.21+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void onProjectileLaunch(ProjectileLaunchEvent event) {
String name = pair.getKey();
Object[] data = pair.getValue();
ItemStack itemStack = (ItemStack) data[3];
Material entityMaterial = EntityUtils.getEntityMaterial(event.getEntityType());
Material entityMaterial = EntityUtils.getEntityMaterial(event.getEntity());
boolean isBow = BOWS.contains(itemStack.getType());
if ((data[1].equals(key) || data[2].equals(key)) && (entityMaterial == itemStack.getType() || (itemStack.getType() == Material.LINGERING_POTION && entityMaterial == Material.SPLASH_POTION) || isBow)) {
boolean thrownItem = (itemStack.getType() != Material.FIREWORK_ROCKET && !isBow);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/coreprotect/utility/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import java.util.Locale;

import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;

import net.coreprotect.bukkit.BukkitAdapter;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.consumer.Queue;
import org.bukkit.entity.ThrowableProjectile;

public class EntityUtils extends Queue {

Expand Down Expand Up @@ -50,6 +52,14 @@ else if (internal) {
return id;
}

public static Material getEntityMaterial(final Entity entity) {
if (entity instanceof ThrowableProjectile) {
return ((ThrowableProjectile) entity).getItem().getType();
}

return getEntityMaterial(entity.getType());
}

public static Material getEntityMaterial(EntityType type) {
switch (type.name()) {
case "ARMOR_STAND":
Expand Down