Added open/close sounds to our Barrels

This commit is contained in:
Sn0wStorm 2019-08-17 21:00:15 +02:00
parent 67ab8e7de3
commit dbe4d4fd93
3 changed files with 33 additions and 1 deletions

View File

@ -192,7 +192,7 @@ public class Barrel implements InventoryHolder {
}
}
}
if (event != null && P.p.useCitadel) {
Plugin plugin = P.p.getServer().getPluginManager().getPlugin("Citadel");
if (plugin != null) {
@ -311,6 +311,10 @@ public class Barrel implements InventoryHolder {
return inventory;
}
public Block getSpigot() {
return spigot;
}
// Returns true if this Block is part of this Barrel
public boolean hasBlock(Block block) {
if (block != null) {

View File

@ -9,6 +9,8 @@ import com.dre.brewery.P;
import com.dre.brewery.integration.LogBlockBarrel;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
@ -390,6 +392,18 @@ public class InventoryListener implements Listener {
if (!P.use1_14) return;
// Barrel Closing Sound
if (event.getInventory().getHolder() instanceof Barrel) {
Barrel barrel = ((Barrel) event.getInventory().getHolder());
float randPitch = (float) (Math.random() * 0.1);
if (barrel.isLarge()) {
barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.BLOCK_BARREL_CLOSE, SoundCategory.BLOCKS, 0.5f, 0.5f + randPitch);
barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 0.2f, 0.6f + randPitch);
} else {
barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.BLOCK_BARREL_CLOSE, SoundCategory.BLOCKS, 0.5f, 0.8f + randPitch);
}
}
// Check for MC Barrel
if (event.getInventory().getType() == InventoryType.BARREL) {
Inventory inv = event.getInventory();

View File

@ -4,6 +4,8 @@ import com.dre.brewery.*;
import com.dre.brewery.filedata.UpdateChecker;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
@ -172,6 +174,18 @@ public class PlayerListener implements Listener {
}
barrel.open(player);
if (P.use1_14) {
// Barrel opening Sound
float randPitch = (float) (Math.random() * 0.1);
if (barrel.isLarge()) {
barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.4f, 0.55f + randPitch);
//barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 0.5f, 0.6f + randPitch);
barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.BLOCK_BREWING_STAND_BREW, SoundCategory.BLOCKS, 0.4f, 0.45f + randPitch);
} else {
barrel.getSpigot().getWorld().playSound(barrel.getSpigot().getLocation(), Sound.BLOCK_BARREL_OPEN, SoundCategory.BLOCKS, 0.5f, 0.8f + randPitch);
}
}
}
}
}