Fix a bunch more issues arising from mutable types (#11769)

This commit is contained in:
Jake Potrebic
2024-12-22 13:50:00 -08:00
committed by GitHub
parent 8ad15d64f0
commit 083c083188
19 changed files with 39 additions and 39 deletions

View File

@@ -79,7 +79,7 @@ public class Vibration {
private final Location block;
public BlockDestination(@NotNull Location block) {
this.block = block;
this.block = block.clone();
}
public BlockDestination(@NotNull Block block) {
@@ -88,7 +88,7 @@ public class Vibration {
@NotNull
public Location getLocation() {
return block;
return block.clone();
}
@NotNull

View File

@@ -65,7 +65,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
* @param vel the velocity of the item being dispensed
*/
public void setVelocity(@NotNull Vector vel) {
velocity = vel;
velocity = vel.clone();
}
@Override

View File

@@ -43,7 +43,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable {
Preconditions.checkArgument(newData != null, "newData null");
Preconditions.checkArgument(this.newData.getMaterial().equals(newData.getMaterial()), "Cannot change fluid type");
this.newData = newData;
this.newData = newData.clone();
}
@Override

View File

@@ -99,7 +99,7 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable {
public void setFinalKnockback(@NotNull Vector knockback) {
Preconditions.checkArgument(knockback != null, "Knockback cannot be null");
this.knockback = knockback;
this.knockback = knockback.clone();
}
@Override

View File

@@ -52,7 +52,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
* @param from New location this entity moved from
*/
public void setFrom(@NotNull Location from) {
this.from = from;
this.from = from.clone();
}
/**
@@ -71,7 +71,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
* @param to New Location this entity moved to
*/
public void setTo(@Nullable Location to) {
this.to = to;
this.to = to != null ? to.clone() : null;
}
@NotNull

View File

@@ -241,7 +241,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
@Nullable
@Deprecated // Paper
public Vector getClickedPosition() {
return clickedPosistion;
return clickedPosistion.clone();
}
// Paper start

View File

@@ -70,7 +70,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*/
public void setFrom(@NotNull Location from) {
validateLocation(from);
this.from = from;
this.from = from.clone();
}
/**
@@ -90,7 +90,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*/
public void setTo(@NotNull Location to) {
validateLocation(to);
this.to = to;
this.to = to.clone();
}
// Paper start - PlayerMoveEvent improvements

View File

@@ -69,7 +69,7 @@ public class PlayerRespawnEvent extends PlayerEvent {
Preconditions.checkArgument(respawnLocation != null, "Respawn location can not be null");
Preconditions.checkArgument(respawnLocation.getWorld() != null, "Respawn world can not be null");
this.respawnLocation = respawnLocation;
this.respawnLocation = respawnLocation.clone();
}
/**

View File

@@ -45,7 +45,7 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable {
* @param velocity The velocity vector that will be sent to the player
*/
public void setVelocity(@NotNull Vector velocity) {
this.velocity = velocity;
this.velocity = velocity.clone();
}
@NotNull

View File

@@ -45,7 +45,7 @@ public class AsyncStructureSpawnEvent extends WorldEvent implements Cancellable
*/
@NotNull
public BoundingBox getBoundingBox() {
return boundingBox;
return boundingBox.clone();
}
/**

View File

@@ -24,7 +24,7 @@ public final class LootContext {
private LootContext(@NotNull Location location, float luck, int lootingModifier, @Nullable Entity lootedEntity, @Nullable HumanEntity killer) {
Preconditions.checkArgument(location != null, "LootContext location cannot be null");
Preconditions.checkArgument(location.getWorld() != null, "LootContext World cannot be null");
this.location = location;
this.location = location.clone();
this.luck = luck;
this.lootingModifier = lootingModifier;
this.lootedEntity = lootedEntity;
@@ -38,7 +38,7 @@ public final class LootContext {
*/
@NotNull
public Location getLocation() {
return location;
return location.clone();
}
/**
@@ -110,7 +110,7 @@ public final class LootContext {
* @param location the location the LootContext should use
*/
public Builder(@NotNull Location location) {
this.location = location;
this.location = location.clone();
}
/**

View File

@@ -27,9 +27,9 @@ public class Transformation {
Preconditions.checkArgument(scale != null, "scale cannot be null");
Preconditions.checkArgument(rightRotation != null, "rightRotation cannot be null");
this.translation = translation;
this.translation = new Vector3f(translation);
this.leftRotation = new Quaternionf(leftRotation);
this.scale = scale;
this.scale = new Vector3f(scale);
this.rightRotation = new Quaternionf(rightRotation);
}
@@ -39,10 +39,10 @@ public class Transformation {
Preconditions.checkArgument(scale != null, "scale cannot be null");
Preconditions.checkArgument(rightRotation != null, "rightRotation cannot be null");
this.translation = translation;
this.leftRotation = leftRotation;
this.scale = scale;
this.rightRotation = rightRotation;
this.translation = new Vector3f(translation);
this.leftRotation = new Quaternionf(leftRotation);
this.scale = new Vector3f(scale);
this.rightRotation = new Quaternionf(rightRotation);
}
/**
@@ -52,7 +52,7 @@ public class Transformation {
*/
@NotNull
public Vector3f getTranslation() {
return this.translation;
return new Vector3f(this.translation);
}
/**
@@ -62,7 +62,7 @@ public class Transformation {
*/
@NotNull
public Quaternionf getLeftRotation() {
return this.leftRotation;
return new Quaternionf(this.leftRotation);
}
/**
@@ -72,7 +72,7 @@ public class Transformation {
*/
@NotNull
public Vector3f getScale() {
return this.scale;
return new Vector3f(this.scale);
}
/**
@@ -82,7 +82,7 @@ public class Transformation {
*/
@NotNull
public Quaternionf getRightRotation() {
return this.rightRotation;
return new Quaternionf(this.rightRotation);
}
@Override

View File

@@ -37,7 +37,7 @@ public class PlayerSpawnLocationEvent extends PlayerEvent {
* @param location the spawn location
*/
public void setSpawnLocation(@NotNull Location location) {
this.spawnLocation = location;
this.spawnLocation = location.clone();
}
@NotNull