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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 39 additions and 39 deletions

View file

@ -55,7 +55,7 @@ public class BlockDestroyEvent extends BlockExpEvent implements Cancellable {
* @param effectBlock block effect * @param effectBlock block effect
*/ */
public void setEffectBlock(final BlockData effectBlock) { public void setEffectBlock(final BlockData effectBlock) {
this.effectBlock = effectBlock; this.effectBlock = effectBlock.clone();
} }
/** /**

View file

@ -79,7 +79,7 @@ public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
public void setFrom(final Location from) { public void setFrom(final Location from) {
Preconditions.checkArgument(from != null, "Cannot use null from location!"); Preconditions.checkArgument(from != null, "Cannot use null from location!");
Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!"); Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!");
this.from = from; this.from = from.clone();
} }
/** /**

View file

@ -66,7 +66,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
* @param location the spawn location, or {@code null} to remove the spawn location * @param location the spawn location, or {@code null} to remove the spawn location
*/ */
public void setLocation(final @Nullable Location location) { public void setLocation(final @Nullable Location location) {
this.location = location; this.location = location != null ? location.clone() : null;
} }
/** /**

View file

@ -53,7 +53,7 @@ public class EntityMoveEvent extends EntityEvent implements Cancellable {
*/ */
public void setFrom(final Location from) { public void setFrom(final Location from) {
this.validateLocation(from); this.validateLocation(from);
this.from = from; this.from = from.clone();
} }
/** /**
@ -72,7 +72,7 @@ public class EntityMoveEvent extends EntityEvent implements Cancellable {
*/ */
public void setTo(final Location to) { public void setTo(final Location to) {
this.validateLocation(to); this.validateLocation(to);
this.to = to; this.to = to.clone();
} }
/** /**

View file

@ -52,7 +52,7 @@ public class WorldBorderCenterChangeEvent extends WorldBorderEvent implements Ca
* @param newCenter the new center * @param newCenter the new center
*/ */
public void setNewCenter(final Location newCenter) { public void setNewCenter(final Location newCenter) {
this.newCenter = newCenter; this.newCenter = newCenter.clone();
} }
@Override @Override

View file

@ -30,9 +30,9 @@ public final class PotionMix implements Keyed {
*/ */
public PotionMix(final NamespacedKey key, final ItemStack result, final RecipeChoice input, final RecipeChoice ingredient) { public PotionMix(final NamespacedKey key, final ItemStack result, final RecipeChoice input, final RecipeChoice ingredient) {
this.key = key; this.key = key;
this.result = result; this.result = result.clone();
this.input = input; this.input = input.clone();
this.ingredient = ingredient; this.ingredient = ingredient.clone();
} }
/** /**
@ -58,7 +58,7 @@ public final class PotionMix implements Keyed {
* @return the result itemstack * @return the result itemstack
*/ */
public ItemStack getResult() { public ItemStack getResult() {
return this.result; return this.result.clone();
} }
/** /**
@ -67,7 +67,7 @@ public final class PotionMix implements Keyed {
* @return the bottom 3 slot ingredients * @return the bottom 3 slot ingredients
*/ */
public RecipeChoice getInput() { public RecipeChoice getInput() {
return this.input; return this.input.clone();
} }
/** /**
@ -76,7 +76,7 @@ public final class PotionMix implements Keyed {
* @return the top slot input * @return the top slot input
*/ */
public RecipeChoice getIngredient() { public RecipeChoice getIngredient() {
return this.ingredient; return this.ingredient.clone();
} }
@Override @Override

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -70,7 +70,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
*/ */
public void setFrom(@NotNull Location from) { public void setFrom(@NotNull Location from) {
validateLocation(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) { public void setTo(@NotNull Location to) {
validateLocation(to); validateLocation(to);
this.to = to; this.to = to.clone();
} }
// Paper start - PlayerMoveEvent improvements // 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 != null, "Respawn location can not be null");
Preconditions.checkArgument(respawnLocation.getWorld() != null, "Respawn world 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 * @param velocity The velocity vector that will be sent to the player
*/ */
public void setVelocity(@NotNull Vector velocity) { public void setVelocity(@NotNull Vector velocity) {
this.velocity = velocity; this.velocity = velocity.clone();
} }
@NotNull @NotNull

View file

@ -45,7 +45,7 @@ public class AsyncStructureSpawnEvent extends WorldEvent implements Cancellable
*/ */
@NotNull @NotNull
public BoundingBox getBoundingBox() { 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) { 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 != null, "LootContext location cannot be null");
Preconditions.checkArgument(location.getWorld() != null, "LootContext World cannot be null"); Preconditions.checkArgument(location.getWorld() != null, "LootContext World cannot be null");
this.location = location; this.location = location.clone();
this.luck = luck; this.luck = luck;
this.lootingModifier = lootingModifier; this.lootingModifier = lootingModifier;
this.lootedEntity = lootedEntity; this.lootedEntity = lootedEntity;
@ -38,7 +38,7 @@ public final class LootContext {
*/ */
@NotNull @NotNull
public Location getLocation() { public Location getLocation() {
return location; return location.clone();
} }
/** /**
@ -110,7 +110,7 @@ public final class LootContext {
* @param location the location the LootContext should use * @param location the location the LootContext should use
*/ */
public Builder(@NotNull Location location) { 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(scale != null, "scale cannot be null");
Preconditions.checkArgument(rightRotation != null, "rightRotation 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.leftRotation = new Quaternionf(leftRotation);
this.scale = scale; this.scale = new Vector3f(scale);
this.rightRotation = new Quaternionf(rightRotation); this.rightRotation = new Quaternionf(rightRotation);
} }
@ -39,10 +39,10 @@ public class Transformation {
Preconditions.checkArgument(scale != null, "scale cannot be null"); Preconditions.checkArgument(scale != null, "scale cannot be null");
Preconditions.checkArgument(rightRotation != null, "rightRotation cannot be null"); Preconditions.checkArgument(rightRotation != null, "rightRotation cannot be null");
this.translation = translation; this.translation = new Vector3f(translation);
this.leftRotation = leftRotation; this.leftRotation = new Quaternionf(leftRotation);
this.scale = scale; this.scale = new Vector3f(scale);
this.rightRotation = rightRotation; this.rightRotation = new Quaternionf(rightRotation);
} }
/** /**
@ -52,7 +52,7 @@ public class Transformation {
*/ */
@NotNull @NotNull
public Vector3f getTranslation() { public Vector3f getTranslation() {
return this.translation; return new Vector3f(this.translation);
} }
/** /**
@ -62,7 +62,7 @@ public class Transformation {
*/ */
@NotNull @NotNull
public Quaternionf getLeftRotation() { public Quaternionf getLeftRotation() {
return this.leftRotation; return new Quaternionf(this.leftRotation);
} }
/** /**
@ -72,7 +72,7 @@ public class Transformation {
*/ */
@NotNull @NotNull
public Vector3f getScale() { public Vector3f getScale() {
return this.scale; return new Vector3f(this.scale);
} }
/** /**
@ -82,7 +82,7 @@ public class Transformation {
*/ */
@NotNull @NotNull
public Quaternionf getRightRotation() { public Quaternionf getRightRotation() {
return this.rightRotation; return new Quaternionf(this.rightRotation);
} }
@Override @Override

View file

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