mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-06 15:51:50 +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.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -88,6 +89,13 @@ public class ItemUtil {
|
|||||||
});
|
});
|
||||||
yamlConfiguration.createSection(fileName + ".enchantments", map);
|
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){
|
if (itemMeta.getItemFlags().size() > 0){
|
||||||
ArrayList<String> itemFlags = new ArrayList<>();
|
ArrayList<String> itemFlags = new ArrayList<>();
|
||||||
itemStack.getItemFlags().forEach(itemFlag -> {
|
itemStack.getItemFlags().forEach(itemFlag -> {
|
||||||
@@ -99,7 +107,9 @@ public class ItemUtil {
|
|||||||
NBTItem nbtItem = new NBTItem(itemStack);
|
NBTItem nbtItem = new NBTItem(itemStack);
|
||||||
|
|
||||||
Map<String, Object> map0 = compoundToMap(nbtItem);
|
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");
|
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("Lore")
|
||||||
|| key.equals("HideFlags")
|
|| key.equals("HideFlags")
|
||||||
|| key.equals("CustomModelData")
|
|| key.equals("CustomModelData")
|
||||||
|
|| key.equals("StoredEnchantments")
|
||||||
|| key.equals("Unbreakable")) return;
|
|| key.equals("Unbreakable")) return;
|
||||||
switch (nbtCompound.getType(key)){
|
switch (nbtCompound.getType(key)){
|
||||||
case NBTTagByte -> map.put(key, "(Byte) " + nbtCompound.getByte(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)));
|
nbtCompound.setLong(key, Long.valueOf(string.substring(7)));
|
||||||
}else if (string.startsWith("(Float) ")){
|
}else if (string.startsWith("(Float) ")){
|
||||||
nbtCompound.setFloat(key, Float.valueOf(string.substring(8)));
|
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)));
|
nbtCompound.setDouble(key, Double.valueOf(string.substring(9)));
|
||||||
}else if (string.startsWith("(Short) ")){
|
}else if (string.startsWith("(Short) ")){
|
||||||
nbtCompound.setShort(key, Short.valueOf(string.substring(8)));
|
nbtCompound.setShort(key, Short.valueOf(string.substring(8)));
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ rainbow_fish:
|
|||||||
custom-model-data: 1
|
custom-model-data: 1
|
||||||
|
|
||||||
# Custom NBT tags
|
# 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)
|
# (Int) (Byte) (String) (Float) (String) (Double) (Short) (Long) (UUID) (Boolean) (IntArray) (ByteArray)
|
||||||
nbt:
|
nbt:
|
||||||
itemsadder:
|
itemsadder:
|
||||||
|
|||||||
Reference in New Issue
Block a user