6
6
/**
7
7
* Disclaimer - Bukkit {@link org.bukkit.Location} storage may cause a memory leak, because it is a wrapper for
8
8
* coordinates and {@link org.bukkit.World} reference. If you need to store location use {@link Position} and
9
- * {@link PositionAdapter}.
9
+ * {@link PositionAdapter} to convert it to {@link org.bukkit.Location} when needed .
10
10
*/
11
11
public record Position (double x , double y , double z , float yaw , float pitch , String world ) {
12
12
@@ -15,40 +15,12 @@ public record Position(double x, double y, double z, float yaw, float pitch, Str
15
15
private static final Pattern PARSE_FORMAT = Pattern .compile (
16
16
"Position\\ {x=(?<x>-?[\\ d.]+), y=(?<y>-?[\\ d.]+), z=(?<z>-?[\\ d.]+), yaw=(?<yaw>-?[\\ d.]+), pitch=(?<pitch>-?[\\ d.]+), world='(?<world>.+)'}" );
17
17
18
- public boolean isNoneWorld () {
19
- return this .world .equals (NONE_WORLD );
20
- }
21
-
22
- @ Override
23
- public boolean equals (Object o ) {
24
- if (this == o ) {
25
- return true ;
26
- }
27
-
28
- if (o == null || getClass () != o .getClass ()) {
29
- return false ;
30
- }
31
-
32
- Position position = (Position ) o ;
33
-
34
- return Double .compare (position .x , this .x ) == 0
35
- && Double .compare (position .y , this .y ) == 0
36
- && Double .compare (position .z , this .z ) == 0
37
- && Float .compare (position .yaw , this .yaw ) == 0
38
- && Float .compare (position .pitch , this .pitch ) == 0
39
- && this .world .equals (position .world );
18
+ public Position (double x , double y , double z , String world ) {
19
+ this (x , y , z , 0F , 0F , world );
40
20
}
41
21
42
- @ Override
43
- public String toString () {
44
- return "Position{" +
45
- "x=" + this .x +
46
- ", y=" + this .y +
47
- ", z=" + this .z +
48
- ", yaw=" + this .yaw +
49
- ", pitch=" + this .pitch +
50
- ", world='" + this .world + '\'' +
51
- '}' ;
22
+ public Position (double x , double z , String world ) {
23
+ this (x , 0.0 , z , 0F , 0F , world );
52
24
}
53
25
54
26
public static Position parse (String parse ) {
@@ -67,4 +39,20 @@ public static Position parse(String parse) {
67
39
matcher .group ("world" )
68
40
);
69
41
}
42
+
43
+ @ Override
44
+ public String toString () {
45
+ return "Position{" +
46
+ "x=" + this .x +
47
+ ", y=" + this .y +
48
+ ", z=" + this .z +
49
+ ", yaw=" + this .yaw +
50
+ ", pitch=" + this .pitch +
51
+ ", world='" + this .world + '\'' +
52
+ '}' ;
53
+ }
54
+
55
+ public boolean isNoneWorld () {
56
+ return this .world .equals (NONE_WORLD );
57
+ }
70
58
}
0 commit comments