Fix unintended change to playSound contract and various other issues

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2023-06-12 21:29:41 +10:00
parent a678c41574
commit 746a0db582
6 changed files with 11 additions and 19 deletions

View File

@ -1550,9 +1550,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
Preconditions.checkArgument(loc != null, "Location cannot be null");
Preconditions.checkArgument(sound != null, "Sound cannot be null");
Preconditions.checkArgument(category != null, "Category cannot be null");
if (loc == null || sound == null || category == null) return;
double x = loc.getX();
double y = loc.getY();
@ -1563,9 +1561,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
Preconditions.checkArgument(loc != null, "Location cannot be null");
Preconditions.checkArgument(sound != null, "Sound cannot be null");
Preconditions.checkArgument(category != null, "Category cannot be null");
if (loc == null || sound == null || category == null) return;
double x = loc.getX();
double y = loc.getY();

View File

@ -747,7 +747,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public void setTicksLived(int value) {
Preconditions.checkArgument(value > 0, "Age value (%s) must be positive", value);
Preconditions.checkArgument(value > 0, "Age value (%s) must be greater than 0", value);
getHandle().tickCount = value;
}

View File

@ -457,16 +457,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
Preconditions.checkArgument(sound != null, "Sound cannot be null");
Preconditions.checkArgument(category != null, "Category cannot be null");
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
playSound0(loc, BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch);
}
@Override
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
Preconditions.checkArgument(sound != null, "sound cannot be null");
Preconditions.checkArgument(category != null, "Category cannot be null");
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
playSound0(loc, Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch);
}
@ -492,16 +490,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
Preconditions.checkArgument(category != null, "Category cannot be null");
Preconditions.checkArgument(sound != null, "Sound cannot be null");
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
playSound0(entity, BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch);
}
@Override
public void playSound(org.bukkit.entity.Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
Preconditions.checkArgument(category != null, "Category cannot be null");
Preconditions.checkArgument(sound != null, "sound cannot be null");
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
playSound0(entity, Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), volume, pitch);
}

View File

@ -84,7 +84,7 @@ public class CraftInventory implements Inventory {
@Override
public void setContents(ItemStack[] items) {
Preconditions.checkArgument(getSize() < items.length, "Invalid inventory size (%s); expected %s or less", items.length, getSize());
Preconditions.checkArgument(items.length <= getSize(), "Invalid inventory size (%s); expected %s or less", items.length, getSize());
for (int i = 0; i < getSize(); i++) {
if (i >= items.length) {

View File

@ -32,7 +32,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
@Override
public void setContents(ItemStack[] items) {
Preconditions.checkArgument(getSize() <= items.length, "Invalid inventory size (%s); expected %s or less", items.length, getSize());
Preconditions.checkArgument(items.length <= getSize(), "Invalid inventory size (%s); expected %s or less", items.length, getSize());
setContents(items[0], Arrays.copyOfRange(items, 1, items.length));
}
@ -96,7 +96,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
@Override
public void setMatrix(ItemStack[] contents) {
Preconditions.checkArgument(getMatrixInventory().getContainerSize() <= contents.length, "Invalid inventory size (%s); expected %s or less", contents.length, getMatrixInventory().getContainerSize());
Preconditions.checkArgument(contents.length <= getMatrixInventory().getContainerSize(), "Invalid inventory size (%s); expected %s or less", contents.length, getMatrixInventory().getContainerSize());
for (int i = 0; i < getMatrixInventory().getContainerSize(); i++) {
if (i < contents.length) {

View File

@ -48,7 +48,7 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC
@Override
public void setContents(ItemStack[] items) {
Preconditions.checkArgument(getInventory().getContainerSize() >= items.length, "Invalid inventory size (%s); expected %s or less", items.length, getInventory().getContainerSize());
Preconditions.checkArgument(items.length <= getInventory().getContainerSize(), "Invalid inventory size (%s); expected %s or less", items.length, getInventory().getContainerSize());
ItemStack[] leftItems = new ItemStack[left.getSize()], rightItems = new ItemStack[right.getSize()];
System.arraycopy(items, 0, leftItems, 0, Math.min(left.getSize(), items.length));
left.setContents(leftItems);