Skip to content

Commit ac86b9a

Browse files
committed
Fix issues with startup.
1 parent 09771da commit ac86b9a

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

src/main/java/world/bentobox/bentobox/api/addons/Addon.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,7 @@ public File saveResource(String jarResource, File destinationFolder, boolean rep
312312
outFile = new File(destinationFolder, outFile.getName());
313313
}
314314
// Make any dirs that need to be made
315-
if (!outFile.getParentFile().mkdirs()) {
316-
throw new IOException();
317-
}
315+
outFile.getParentFile().mkdirs();
318316
if (!outFile.exists() || replace) {
319317
java.nio.file.Files.copy(in, outFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
320318
}
@@ -326,6 +324,7 @@ public File saveResource(String jarResource, File destinationFolder, boolean rep
326324
"The embedded resource '" + jarResource + "' cannot be found in " + jar.getName());
327325
}
328326
} catch (IOException e) {
327+
e.printStackTrace();
329328
BentoBox.getInstance().logError(
330329
"Could not save from jar file. From " + jarResource + " to " + destinationFolder.getAbsolutePath());
331330
}
Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package world.bentobox.bentobox.util;
22

33

4-
import org.eclipse.jdt.annotation.NonNull;
5-
64
/**
7-
* Class to store pairs of objects, e.g. coordinates
5+
* Class to store pairs of objects, e.g. coordinates.
6+
* This could be done now as a record, but due to legacy code referencing it, it stays as a class.
7+
* @author tastybento
88
*
99
* @param <X> the x part of the pair
1010
* @param <Z> the z part of the pair
11-
* @author tastybento
1211
*/
13-
public record Pair<X, Z>(X x, Z z) {
12+
public class Pair<X, Z> {
13+
public final X x;
14+
public final Z z;
15+
1416
/**
1517
* Static factory method to create a Pair.
16-
*
1718
* @param x the x part
1819
* @param z the z part
1920
* @return a new Pair containing x and z
@@ -22,10 +23,14 @@ public static <X, Z> Pair<X, Z> of(X x, Z z) {
2223
return new Pair<>(x, z);
2324
}
2425

26+
public Pair(X x, Z z) {
27+
this.x = x;
28+
this.z = z;
29+
}
30+
2531

2632
/**
2733
* Returns X element as key.
28-
*
2934
* @return X element
3035
*/
3136
public X getKey() {
@@ -35,7 +40,6 @@ public X getKey() {
3540

3641
/**
3742
* Returns Z element as value.
38-
*
3943
* @return Z element
4044
*/
4145
public Z getValue() {
@@ -47,10 +51,22 @@ public Z getValue() {
4751
* @see java.lang.Object#toString()
4852
*/
4953
@Override
50-
public @NonNull String toString() {
54+
public String toString() {
5155
return "Pair [x=" + x + ", z=" + z + "]";
5256
}
5357

58+
/* (non-Javadoc)
59+
* @see java.lang.Object#hashCode()
60+
*/
61+
@Override
62+
public int hashCode() {
63+
final int prime = 31;
64+
int result = 1;
65+
result = prime * result + ((x == null) ? 0 : x.hashCode());
66+
result = prime * result + ((z == null) ? 0 : z.hashCode());
67+
return result;
68+
}
69+
5470
/* (non-Javadoc)
5571
* @see java.lang.Object#equals(java.lang.Object)
5672
*/
@@ -62,17 +78,27 @@ public boolean equals(Object obj) {
6278
if (obj == null) {
6379
return false;
6480
}
65-
if (!(obj instanceof Pair<?, ?>(Object x1, Object z1))) {
81+
if (!(obj instanceof Pair<?, ?> other)) {
6682
return false;
6783
}
6884
if (x == null) {
69-
return false;
70-
} else if (!x.equals(x1)) {
85+
if (other.x != null) {
86+
return false;
87+
}
88+
} else if (!x.equals(other.x)) {
7189
return false;
7290
}
7391
if (z == null) {
74-
return false;
75-
} else return z.equals(z1);
92+
return other.z == null;
93+
} else return z.equals(other.z);
94+
}
95+
96+
public X x() {
97+
return x;
7698
}
7799

100+
public Z z() {
101+
return z;
102+
}
103+
78104
}

0 commit comments

Comments
 (0)