Skip to content

Commit b400603

Browse files
authored
Merge pull request #33 from Arctic-Gaming-LLC/pentlock1-patch-1
Pentlock1 patch 1
2 parents b66d90b + 5b44201 commit b400603

File tree

7 files changed

+55
-61
lines changed

7 files changed

+55
-61
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.pentlock</groupId>
88
<artifactId>ThunderDataEngine</artifactId>
9-
<version>0.2.5</version>
9+
<version>0.2.6</version>
1010
<packaging>jar</packaging>
1111

1212
<name>ThunderDataEngine</name>

src/main/java/net/pentlock/thunderdataengine/profiles/House.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.util.UUID;
88

99
public class House {
10-
@Setter @Getter
11-
private UUID UUID; // UUID of house group
1210
@Setter @Getter
1311
private String name; // name of house
1412
@Setter @Getter
@@ -26,16 +24,14 @@ public class House {
2624
* <h3>House Objects</h3>
2725
* This is the constructor for a House type - not an individual house
2826
*
29-
* @param uuid the Unique ID for the housing instance
3027
* @param name the Name of the House
3128
* @param cost How much the house costs to purchase
3229
* @param doorLocation The exact location of the door
3330
* @param arrivalLocation Where players should spawn in the house
3431
* @param instances Stores the locations and UUIDs of all instances of this house type
3532
* @param instanceLocation Stores a map of player UUIDs and House Locations
3633
*/
37-
public House(UUID uuid, String name, double cost, String[] doorLocation, String[] arrivalLocation, Map<UUID, String[]> instances, Map<UUID, String[]> instanceLocation) {
38-
this.UUID = uuid;
34+
public House(String name, double cost, String[] doorLocation, String[] arrivalLocation, Map<UUID, String[]> instances, Map<UUID, String[]> instanceLocation) {
3935
this.name = name;
4036
this.cost = cost;
4137
this.doorLocation = doorLocation;

src/main/java/net/pentlock/thunderdataengine/utilities/ArrayUtil.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,32 @@ public static Double[] addToArray(Double[] oldArray, double value) {
8282
return newArray;
8383
}
8484

85+
/**
86+
* <h3>Array Util</h3>
87+
* A handy tool to update arrays!
88+
* UUID Edition
89+
*
90+
* @param oldArray The current array that is being updated
91+
* @param value The values that an array is adding to
92+
* @return Array of object type
93+
*/
94+
public static UUID[] addToArray(UUID[] oldArray, UUID value) {
95+
96+
UUID[] newArray = new UUID[oldArray.length + 1];
97+
98+
for (int i = 0; i < oldArray.length + 1;) {
99+
100+
if (i < oldArray.length) {
101+
newArray[i] = oldArray[i];
102+
} else {
103+
newArray[i] = value;
104+
}
105+
i++;
106+
}
107+
108+
return newArray;
109+
}
110+
85111
/**
86112
* <h3>Array Util</h3>
87113
* A handy tool to update arrays!
@@ -181,30 +207,4 @@ public static UUID[] removeFromArray(UUID[] oldArray, UUID value) {
181207

182208
return newArray;
183209
}
184-
185-
/**
186-
* <h3>Array Util</h3>
187-
* A handy tool to update arrays!
188-
* UUID Edition
189-
*
190-
* @param oldArray The current array that is being updated
191-
* @param value The values that an array is adding to
192-
* @return Array of object type
193-
*/
194-
public static UUID[] addToArray(UUID[] oldArray, UUID value) {
195-
196-
UUID[] newArray = new UUID[oldArray.length + 1];
197-
198-
for (int i = 0; i < oldArray.length + 1;) {
199-
200-
if (i < oldArray.length) {
201-
newArray[i] = oldArray[i];
202-
} else {
203-
newArray[i] = value;
204-
}
205-
i++;
206-
}
207-
208-
return newArray;
209-
}
210210
}

src/main/java/net/pentlock/thunderdataengine/utilities/HouseUtil.java

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212

1313
public 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

Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)