First 1.21.3 drafts

This commit is contained in:
2024-11-26 16:30:24 +01:00
parent df37fa1564
commit d6202f9596
5 changed files with 107 additions and 11 deletions
@@ -21,7 +21,9 @@ package de.steamwar.inventory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.steamwar.core.Core;
import de.steamwar.core.FlatteningWrapper;
import de.steamwar.core.VersionDependent;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
@@ -30,10 +32,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class SWItem {
private static final ISWItem impl = VersionDependent.getVersionImpl(Core.getInstance());
private ItemStack itemStack;
private ItemMeta itemMeta;
private InvCallback callback;
@@ -107,7 +112,7 @@ public class SWItem {
itemMeta.setDisplayName(name);
if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore);
if (enchanted) itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
if (enchanted) itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true);
itemStack.setItemMeta(itemMeta);
}
callback = c;
@@ -144,12 +149,9 @@ public class SWItem {
private void hideAttributes() {
if (itemMeta == null) return;
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
itemMeta.addItemFlags(ItemFlag.HIDE_DESTROYS);
itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
for (ItemFlag flag : impl.getHideFlags()) {
itemMeta.addItemFlags(flag);
}
}
public ItemStack getItemStack() {
@@ -192,10 +194,16 @@ public class SWItem {
public void setEnchanted(boolean enchanted) {
if (enchanted){
itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true);
} else {
itemMeta.removeEnchant(Enchantment.DURABILITY);
itemMeta.removeEnchant(impl.getDurabilityEnchantment());
}
itemStack.setItemMeta(itemMeta);
}
public interface ISWItem {
Collection<ItemFlag> getHideFlags();
Enchantment getDurabilityEnchantment();
}
}