mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
1.1.0
This commit is contained in:
@@ -25,6 +25,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.io.File;
|
||||
@@ -88,6 +89,13 @@ public class ItemUtil {
|
||||
});
|
||||
yamlConfiguration.createSection(fileName + ".enchantments", map);
|
||||
}
|
||||
if (itemMeta instanceof EnchantmentStorageMeta enchantmentStorageMeta){
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
enchantmentStorageMeta.getStoredEnchants().forEach(((enchantment, level) -> {
|
||||
map.put(String.valueOf(enchantment.getKey()), level);
|
||||
}));
|
||||
yamlConfiguration.createSection(fileName + ".enchantments", map);
|
||||
}
|
||||
if (itemMeta.getItemFlags().size() > 0){
|
||||
ArrayList<String> itemFlags = new ArrayList<>();
|
||||
itemStack.getItemFlags().forEach(itemFlag -> {
|
||||
@@ -99,7 +107,9 @@ public class ItemUtil {
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
|
||||
Map<String, Object> map0 = compoundToMap(nbtItem);
|
||||
yamlConfiguration.createSection(fileName + ".nbt", map0);
|
||||
if (map0.size() != 0){
|
||||
yamlConfiguration.createSection(fileName + ".nbt", map0);
|
||||
}
|
||||
|
||||
File file = new File(CustomFishing.instance.getDataFolder(), File.separator + "loots" + File.separator + fileName + ".yml");
|
||||
|
||||
@@ -119,6 +129,7 @@ public class ItemUtil {
|
||||
|| key.equals("Lore")
|
||||
|| key.equals("HideFlags")
|
||||
|| key.equals("CustomModelData")
|
||||
|| key.equals("StoredEnchantments")
|
||||
|| key.equals("Unbreakable")) return;
|
||||
switch (nbtCompound.getType(key)){
|
||||
case NBTTagByte -> map.put(key, "(Byte) " + nbtCompound.getByte(key));
|
||||
|
||||
@@ -86,7 +86,7 @@ public class NBTUtil {
|
||||
nbtCompound.setLong(key, Long.valueOf(string.substring(7)));
|
||||
}else if (string.startsWith("(Float) ")){
|
||||
nbtCompound.setFloat(key, Float.valueOf(string.substring(8)));
|
||||
} else if (string.startsWith("(Double) ")){
|
||||
}else if (string.startsWith("(Double) ")){
|
||||
nbtCompound.setDouble(key, Double.valueOf(string.substring(9)));
|
||||
}else if (string.startsWith("(Short) ")){
|
||||
nbtCompound.setShort(key, Short.valueOf(string.substring(8)));
|
||||
|
||||
@@ -35,7 +35,7 @@ rainbow_fish:
|
||||
custom-model-data: 1
|
||||
|
||||
# Custom NBT tags
|
||||
# If you are not sure about the NBT tag. You can use command '/customfishing export xxx' and get it in 'CustomFishing/export' folder
|
||||
# If you are not sure about the NBT tag. You can use command '/cfishing import xxx' and get it in 'CustomFishing/export' folder
|
||||
# (Int) (Byte) (String) (Float) (String) (Double) (Short) (Long) (UUID) (Boolean) (IntArray) (ByteArray)
|
||||
nbt:
|
||||
itemsadder:
|
||||
|
||||
Reference in New Issue
Block a user