public static void loadItem(File file) { String itemName = FilenameUtils.removeExtension(file.getName()); XmlItemStack item = null; try { item = serializer.read(XmlItemStack.class, file); } catch (Exception e) { e.printStackTrace(); } if (item == null) { return; } items.put(itemName, item.getItemStack()); Chat.debug( String.format( "Loaded item %s", StringUtil.joinString(Messages.itemInfo(item.getItemStack()), "\n", 0))); }
public static boolean saveItem(String name, ItemStack item) { if (items.containsKey(name)) { return false; } XmlItemStack xmlItemStack = XmlItemStack.fromItem(item); File itemFile = new File(String.format("%s/%s.xml", Commons.ITEM_DATA_FOLDER, name)); boolean saved = true; try { serializer.write(xmlItemStack, itemFile); items.put(name, item); } catch (Exception e) { e.printStackTrace(); saved = true; } return saved; }