mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 08:17:44 +01:00
Fix unintended change to playSound contract and various other issues
By: md_5 <git@md-5.net>
This commit is contained in:
parent
a678c41574
commit
746a0db582
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user