geforkt von Mirrors/Paper
Clone mutables to prevent unexpected issues
There are lots of locations in the API where mutable types are not cloned, either on return or when passed as a parameter and assigned to a field, which can cause unexpected behaviors. Let this be a lesson to use immutable types for simple things Location, Vector, and others.
Dieser Commit ist enthalten in:
Ursprung
d19f69b3eb
Commit
96f6033450
@ -102,7 +102,7 @@ public class BlockCanBuildEvent extends BlockEvent {
|
||||
*/
|
||||
@NotNull
|
||||
public BlockData getBlockData() {
|
||||
return blockData;
|
||||
return blockData.clone(); // Paper - clone because mutation isn't used
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
|
||||
*/
|
||||
@NotNull
|
||||
public BlockData getBlockData() {
|
||||
return to;
|
||||
return to.clone(); // Paper - clone because mutation isn't used
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -72,7 +72,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return location.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ public class EntityPortalEnterEvent extends EntityEvent implements org.bukkit.ev
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return location.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
// Paper start
|
||||
|
@ -46,7 +46,7 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return location.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -31,7 +31,7 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent {
|
||||
*/
|
||||
@NotNull
|
||||
public org.bukkit.util.Vector getVelocity() {
|
||||
return velocity;
|
||||
return velocity.clone();
|
||||
}
|
||||
// Paper end
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class VehicleMoveEvent extends VehicleEvent {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
return from.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ public class VehicleMoveEvent extends VehicleEvent {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getTo() {
|
||||
return to;
|
||||
return to.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class GenericGameEvent extends WorldEvent implements Cancellable {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return location.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ public class SpawnChangeEvent extends WorldEvent {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getPreviousLocation() {
|
||||
return previousLocation;
|
||||
return previousLocation.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -39,7 +39,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable {
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return location.clone(); // Paper - clone to avoid changes
|
||||
}
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren