@@ -0,0 +1,2359 @@
+package com.darkbyte.programs.darkinventory.events;%0A%0Aimport java.io.BufferedWriter;%0Aimport java.io.File;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0A%0Aimport javax.swing.JOptionPane;%0A%0Apublic class NewItemEvent implements Event %7B%0A%0A%09@Override%0A%09public void run() %7B%0A%09%09String name;%0A%09%09String description;%0A%09%09int quantity = 0;%0A%09%09boolean quantitySet = false;%0A%09%09String type;%0A%09%09File itemsDirectory = new File(%22items/%22);%0A%09%09File itemFile;%0A%09%09%0A%09%09if(!itemsDirectory.exists()) %7B%0A%09%09%09itemsDirectory.mkdir();%0A%09%09%7D%0A%09%09%0A%09%09name = JOptionPane.showInputDialog(null, %22What is the name of the item you would like to create?%22, %22Name%22, JOptionPane.QUESTION_MESSAGE);%0A%09%09if(name.equals(JOptionPane.CANCEL_OPTION) %7C%7C name.equals(JOptionPane.CLOSED_OPTION)) return;%0A%09%09description = JOptionPane.showInputDialog(null, %22What would you like the description for this item to be?%22, %22Description%22, JOptionPane.QUESTION_MESSAGE);%0A%09%09if(description.equals(JOptionPane.CANCEL_OPTION) %7C%7C description.equals(JOptionPane.CLOSED_OPTION)) return;%0A%09%09while(!quantitySet) %7B%0A%09%09%09try %7B%0A%09%09%09%09quantity = Integer.parseInt(JOptionPane.showInputDialog(null, %22How much of this product should there be?%22, %22Quantity%22, JOptionPane.QUESTION_MESSAGE));%0A%09%09%09%09quantitySet = true;%0A%09%09%09%7D catch(NumberFormatException e) %7B%0A%09%09%09%09JOptionPane.showMessageDialog(null, %22The quantity must be a whole number!%22, %22Error%22, JOptionPane.ERROR_MESSAGE);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09type = JOptionPane.showInputDialog(null, %22What type of item is this?%22, %22Type%22, JOptionPane.QUESTION_MESSAGE);%0A%09%09if(type.equals(JOptionPane.CANCEL_OPTION) %7C%7C type.equals(JOptionPane.CLOSED_OPTION)) return;%0A%09%09%0A%09%09itemFile = new File(itemsDirectory, name + %22.darkinventfile%22);%0A%09%09%0A%09%09if(itemFile.exists()) %7B%0A%09%09%09JOptionPane.showMessageDialog(null, %22This item already exists!%22, %22Error%22, JOptionPane.ERROR_MESSAGE);%0A%09%09%7D else %7B%0A%09%09%09try(BufferedWriter writer = new BufferedWriter(new FileWriter(itemFile))) %7B%0A%09%09%09%09itemFile.createNewFile();%0A%09%09%09%09writer.write(%22name: %22 + name.replaceAll(%22 %22, %22-%22) + %22%5Cn%22);%0A%09%09%09%09writer.write(%22description: %22 + description.replaceAll(%22 %22, %22-%22) + %22%5Cn%22);%0A%09%09%09%09writer.write(%22quantity: %22 + new Integer(quantity).toString() + %22%5Cn%22);%0A%09%09%09%09writer.write(%22type: %22 + type.replaceAll(%22 %22, %22-%22) + %22%5Cn%22);%0A%09%09%09%7D catch(IOException e) %7B%0A%09%09%09%09JOptionPane.showMessageDialog(null, %22A fatal error occurred whilst creating the file!%22, %22Error%22, JOptionPane.ERROR_MESSAGE);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Create NewItemEvent.java