Fix deprecation in ItemStackBuilder

This commit is contained in:
Marc Baloup 2023-04-10 19:16:42 +02:00
parent 4259e5eccd
commit ba896e689a

View File

@ -1,15 +1,9 @@
package fr.pandacube.lib.paper.util; package fr.pandacube.lib.paper.util;
import java.util.Arrays; import com.destroystokyo.paper.Namespaced;
import java.util.Collection; import com.google.common.collect.Streams;
import java.util.Collections; import fr.pandacube.lib.chat.Chat;
import java.util.List; import net.kyori.adventure.text.Component;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import fr.pandacube.lib.chat.ChatStatic;
import fr.pandacube.lib.util.Log;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -18,13 +12,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import com.google.common.collect.Streams; import java.util.Arrays;
import java.util.Collection;
import fr.pandacube.lib.chat.Chat; import java.util.Collections;
import fr.pandacube.lib.chat.Chat.FormatableChat; import java.util.List;
import net.kyori.adventure.text.Component; import java.util.Set;
import net.kyori.adventure.text.format.TextDecoration; import java.util.function.Consumer;
import net.kyori.adventure.text.format.TextDecoration.State;
import static fr.pandacube.lib.chat.ChatStatic.chatComponent; import static fr.pandacube.lib.chat.ChatStatic.chatComponent;
@ -182,11 +175,19 @@ public class ItemStackBuilder {
} }
public ItemStackBuilder canDestroy(Set<Material> destroyable) { public ItemStackBuilder canDestroy(Set<Material> destroyable) {
return meta(m -> m.setCanDestroy(destroyable)); return canDestroy(destroyable.stream().map(m -> (Namespaced) m.getKey()).toList());
} }
public ItemStackBuilder canPlaceOn(Set<Material> placeOn) { public ItemStackBuilder canPlaceOn(Set<Material> placeOn) {
return meta(m -> m.setCanPlaceOn(placeOn)); return canPlaceOn(placeOn.stream().map(m -> (Namespaced) m.getKey()).toList());
}
public ItemStackBuilder canDestroy(Collection<Namespaced> destroyable) {
return meta(m -> m.setDestroyableKeys(destroyable));
}
public ItemStackBuilder canPlaceOn(Collection<Namespaced> placeOn) {
return meta(m -> m.setPlaceableKeys(placeOn));
} }
public ItemStackBuilder damage(int d) { public ItemStackBuilder damage(int d) {