1212
1313public class HouseUtil {
1414
15- public static final Map <UUID , House > HOUSES = new HashMap <>();
15+ public static final Map <String , House > HOUSES = new HashMap <>();
1616
1717 /**
1818 *
19- * @param uuid UUID of house
2019 * @param name Name of house
2120 * @param cost cost of house
2221 * @param doorLocation exact location of door to be clicked
@@ -26,15 +25,15 @@ public class HouseUtil {
2625 * @return this is the house object after it has been created
2726 */
2827
29- public static House createHouse (UUID uuid , String name , double cost , String [] doorLocation , String [] arrivalLocation ,
28+ public static House createHouse (String name , double cost , String [] doorLocation , String [] arrivalLocation ,
3029 Map <UUID , String []> instances , Map <UUID , String []> instanceLocation ) {
3130
32- House house = new House (uuid , name , cost , doorLocation , arrivalLocation , instances , instanceLocation );
31+ House house = new House (name . toLowerCase () , cost , doorLocation , arrivalLocation , instances , instanceLocation );
3332
34- HOUSES .put (uuid , house );
33+ HOUSES .put (name , house );
3534
3635 try {
37- saveHouse (uuid );
36+ saveHouse (name );
3837 } catch (IOException e ) {
3938 throw new RuntimeException (e );
4039 }
@@ -44,35 +43,34 @@ public static House createHouse(UUID uuid, String name, double cost, String[] do
4443
4544 /**
4645 *
47- * @param uuid UUID of house
46+ * @param name Name of house
4847 */
49- public static void deleteHouse (UUID uuid ) {
50- HOUSES .remove (uuid );
51- File file = new File (ThunderDataEngine .getPlugin ().getDataFolder ().getAbsolutePath () + "/HouseData/" + uuid + ".json" );
48+ public static void deleteHouse (String name ) {
49+ HOUSES .remove (name );
50+ File file = new File (ThunderDataEngine .getPlugin ().getDataFolder ().getAbsolutePath () + "/HouseData/" + name + ".json" );
5251 if (file .exists ()) {
5352 file .delete ();
5453 }
5554 }
5655
5756 /**
5857 *
59- * @param uuid UUID of house
58+ * @param name Name of house
6059 * @return the house object to be found
6160 */
62- public static House findHouse (UUID uuid ) {
63- return HOUSES .get (uuid );
61+ public static House findHouse (String name ) {
62+ return HOUSES .get (name );
6463 }
6564
6665 /**
6766 *
68- * @param uuid UUID of house
67+ * @param name Name of house
6968 * @param newHouse House object to pass in
7069 * @return the house the has been updated
7170 */
72- public static House updateHouse (UUID uuid , House newHouse ) {
73- House house = HOUSES .get (uuid );
71+ public static House updateHouse (String name , House newHouse ) {
72+ House house = HOUSES .get (name );
7473
75- house .setUUID (newHouse .getUUID ());
7674 house .setName (newHouse .getName ());
7775 house .setCost (newHouse .getCost ());
7876 house .setDoorLocation (newHouse .getDoorLocation ());
@@ -85,19 +83,19 @@ public static House updateHouse(UUID uuid, House newHouse) {
8583
8684 /**
8785 *
88- * @param uuid UUID of house
86+ * @param name Name of house
8987 * @throws IOException an exception?
9088 */
91- public static void saveHouse (UUID uuid ) throws IOException {
89+ public static void saveHouse (String name ) throws IOException {
9290
9391 Gson gson = new GsonBuilder ().setPrettyPrinting ().create ();
94- File file = new File (ThunderDataEngine .getPlugin ().getDataFolder ().getAbsolutePath () + "/HouseData/" + uuid + ".json" );
92+ File file = new File (ThunderDataEngine .getPlugin ().getDataFolder ().getAbsolutePath () + "/HouseData/" + name + ".json" );
9593 if (!file .exists ()) {
9694 file .getParentFile ().mkdir ();
9795 }
9896
9997 file .createNewFile ();
100- House house = HOUSES .get (uuid );
98+ House house = HOUSES .get (name );
10199 if (house != null ) {
102100 Writer writer = new FileWriter (file , false );
103101 gson .toJson (house , writer );
@@ -108,31 +106,31 @@ public static void saveHouse(UUID uuid) throws IOException {
108106
109107 /**
110108 *
111- * @param uuid UUID of house
109+ * @param name Name of house
112110 * @throws FileNotFoundException an exception?
113111 */
114- public static void loadHouse (UUID uuid ) throws FileNotFoundException {
112+ public static void loadHouse (String name ) throws FileNotFoundException {
115113 Gson gson = new Gson ();
116- File file = new File (ThunderDataEngine .getPlugin ().getDataFolder ().getAbsolutePath () + "/HouseData/" + uuid + ".json" );
114+ File file = new File (ThunderDataEngine .getPlugin ().getDataFolder ().getAbsolutePath () + "/HouseData/" + name + ".json" );
117115
118116 if (file .exists ()) {
119117 Reader reader = new FileReader (file );
120118 House house = gson .fromJson (reader , House .class );
121- HOUSES .put (uuid , house );
119+ HOUSES .put (name , house );
122120 }
123121 }
124122
125123 /**
126124 *
127- * @param uuid
125+ * @param name Name of house
128126 */
129- public static void unLoadHouse (UUID uuid ) {
127+ public static void unLoadHouse (String name ) {
130128 try {
131- saveHouse (uuid );
129+ saveHouse (name );
132130 } catch (IOException e ) {
133131 e .printStackTrace ();
134132 }
135- HOUSES .remove (uuid );
133+ HOUSES .remove (name );
136134 }
137135}
138136
0 commit comments