diff --git a/src/main/java/eu/m724/musicPlugin/item/ItemStorage.java b/src/main/java/eu/m724/musicPlugin/item/ItemStorage.java index 1f5abcb..fb053b7 100644 --- a/src/main/java/eu/m724/musicPlugin/item/ItemStorage.java +++ b/src/main/java/eu/m724/musicPlugin/item/ItemStorage.java @@ -24,6 +24,7 @@ public class ItemStorage { public static void init(MusicPlugin plugin) { INSTANCE = new ItemStorage(); INSTANCE.directory = new File(plugin.getDataFolder(), "storage"); + INSTANCE.directory.mkdir(); } static ItemStorage getInstance() { @@ -31,7 +32,7 @@ public class ItemStorage { } public PortableMediaPlayer getPortableMediaPlayer(int id) throws IOException { - var file = new File(directory, HexFormat.of().toHexDigits(id)); + var file = new File(directory, HexFormat.of().toHexDigits(id) + ".pmpdata.bin"); if (!file.exists()) return null; @@ -43,7 +44,7 @@ public class ItemStorage { var premium = buffer.get() == 1; - var eb = new byte[Byte.toUnsignedInt(buffer.get())]; + var eb = new byte[buffer.get() & 0xFF]; buffer.get(eb); var engraving = new String(eb, StandardCharsets.UTF_8); @@ -51,7 +52,7 @@ public class ItemStorage { } public void savePortableMediaPlayer(PortableMediaPlayer player) throws IOException { - var file = new File(directory, HexFormat.of().toHexDigits(player.id)); + var file = new File(directory, HexFormat.of().toHexDigits(player.id) + ".pmpdata.bin"); Files.write(file.toPath(), getData(player)); } diff --git a/src/main/java/eu/m724/musicPlugin/item/PortableMediaPlayer.java b/src/main/java/eu/m724/musicPlugin/item/PortableMediaPlayer.java index d31823a..21b839c 100644 --- a/src/main/java/eu/m724/musicPlugin/item/PortableMediaPlayer.java +++ b/src/main/java/eu/m724/musicPlugin/item/PortableMediaPlayer.java @@ -50,6 +50,7 @@ public class PortableMediaPlayer { var is = new ItemStack(Material.IRON_INGOT); var meta = is.getItemMeta(); + meta.setItemName("Portable music player"); meta.addEnchant(Enchantment.UNBREAKING, 1, false); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); meta.getPersistentDataContainer().set(namespacedKey, PersistentDataType.INTEGER, id);