Skip to content

Commit

Permalink
add a message
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAHuman-xD committed Apr 8, 2024
1 parent 0c9b2a8 commit 55f030e
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void activate(@Nonnull Player p, @Nonnull Item rune) {
}

Location l = rune.getLocation();
Collection<Entity> entities = l.getWorld().getNearbyEntities(l, RANGE, RANGE, RANGE, this::findCompatibleItem);
Collection<Entity> entities = l.getWorld().getNearbyEntities(l, RANGE, RANGE, RANGE, entity -> findCompatibleItem(p, entity));
Optional<Entity> optional = entities.stream().findFirst();

if (optional.isPresent()) {
Expand Down Expand Up @@ -118,10 +118,10 @@ private void activate(@Nonnull Player p, @Nonnull Item rune) {
}
}

private boolean findCompatibleItem(Entity entity) {
private boolean findCompatibleItem(Player player, Entity entity) {
if (entity instanceof Item item) {
ItemStack itemStack = item.getItemStack();
return !isUnbreakable(itemStack) && !isItem(itemStack) && !isDisallowed(itemStack);
return !isUnbreakable(itemStack) && !isItem(itemStack) && !isDisallowed(player, itemStack);
}

return false;
Expand Down Expand Up @@ -151,14 +151,18 @@ public static boolean isUnbreakable(@Nullable ItemStack item) {
}
}

public static boolean isDisallowed(ItemStack itemStack) {
public static boolean isDisallowed(Player player, ItemStack itemStack) {
final SlimefunItem slimefunItem = SlimefunItem.getByItem(itemStack);
if (slimefunItem == null) {
return false;
}

final String id = slimefunItem.getId();
final String addon = slimefunItem.getAddon().getName();
return BLACKLIST.containsKey(addon) && BLACKLIST.get(addon).contains(id);
if (BLACKLIST.containsKey(addon) && BLACKLIST.get(addon).contains(id)) {
player.sendMessage(ChatColor.LIGHT_PURPLE + "You can't make this item unbreakable!");
return true;
}
return false;
}
}

0 comments on commit 55f030e

Please sign in to comment.