diff --git a/CHANGELOG.md b/CHANGELOG.md index b126124f3..8034a2a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,8 +38,10 @@ ## Release Candidate 35 (TBD) #### Additions +* Added `sounds.yml` file to configure sound effects for Slimefun #### Changes +* Moved all sound effects to the new sound system #### Fixes diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index fee2b057e..d2d9a3c1e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -15,7 +15,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Server; -import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.entity.Player; @@ -29,6 +28,7 @@ import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter; @@ -257,7 +257,7 @@ public class GPSNetwork { menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete")); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { profile.removeWaypoint(waypoint); - pl.playSound(pl.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F); + SoundEffect.GPS_NETWORK_OPEN_PANEL_SOUND.playFor(p); openWaypointControlPanel(pl); return false; @@ -290,7 +290,7 @@ public class GPSNetwork { } Slimefun.getLocalization().sendMessage(p, "gps.waypoint.new", true); - p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F); + SoundEffect.GPS_NETWORK_CREATE_WAYPOINT.playFor(p); ChatInput.waitForPlayer(Slimefun.instance(), p, message -> addWaypoint(p, message, l)); }); @@ -333,7 +333,7 @@ public class GPSNetwork { profile.addWaypoint(new Waypoint(profile, id, event.getLocation(), event.getName())); - p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 1F); + SoundEffect.GPS_NETWORK_ADD_WAYPOINT.playFor(p); Slimefun.getLocalization().sendMessage(p, "gps.waypoint.added", true); } }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index 38015ddc4..19646ed4c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -13,7 +13,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Particle; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; @@ -22,6 +21,7 @@ import org.bukkit.potion.PotionEffectType; import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -70,8 +70,7 @@ public final class TeleportationManager { @ParametersAreNonnullByDefault public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity) { if (teleporterUsers.add(p.getUniqueId())) { - p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F); - + SoundEffect.TELEPORTATION_MANAGER_OPEN_GUI.playFor(p); PlayerProfile.fromUUID(ownerUUID, profile -> { ChestMenu menu = new ChestMenu("&3Teleporter"); menu.addMenuCloseHandler(pl -> teleporterUsers.remove(pl.getUniqueId())); @@ -203,8 +202,7 @@ public final class TeleportationManager { p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0); source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F); - source.getWorld().playSound(source, Sound.BLOCK_BEACON_AMBIENT, 1F, 0.6F); - + SoundEffect.TELEPORT_UPDATE_SOUND.playFor(p); Slimefun.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); } } else { @@ -229,7 +227,7 @@ public final class TeleportationManager { // Spawn some particles for aesthetic reasons. Location loc = new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()); destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F); - destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F); + SoundEffect.TELEPORT_SOUND.playFor(p); teleporterUsers.remove(p.getUniqueId()); } else { /* diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java index 15a654b53..9a928c8be 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java @@ -17,6 +17,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -86,7 +87,7 @@ public class NestedItemGroup extends FlexItemGroup { SurvivalSlimefunGuide guide = (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode); menu.setEmptySlotsClickable(false); - menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), guide.getSound(), 1, 1)); + menu.addMenuOpeningHandler(SoundEffect.GUIDE_BUTTON_CLICK_SOUND::playFor); guide.createHeader(p, profile, menu); menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java index 31b83df4e..05694f3e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java @@ -59,7 +59,7 @@ public interface DamageableItem extends ItemAttribute { ItemMeta meta = item.getItemMeta(); - if (!meta.isUnbreakable()) { + if (meta != null && !meta.isUnbreakable()) { Damageable damageable = (Damageable) meta; if (damageable.getDamage() >= item.getType().getMaxDurability()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java index 951a9e064..93e8d89a3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java @@ -6,7 +6,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; @@ -15,6 +14,7 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -36,7 +36,7 @@ final class ContributorsMenu { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.credits")); menu.setEmptySlotsClickable(false); - menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F)); + menu.addMenuOpeningHandler(SoundEffect.GUIDE_CONTRIBUTORS_OPEN_SOUND::playFor); ChestMenuUtils.drawBackground(menu, 0, 2, 3, 4, 5, 6, 7, 8, 45, 47, 48, 49, 50, 51, 53); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java index a6fe62458..7a4779ff5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java @@ -6,7 +6,6 @@ import java.util.Optional; import org.bukkit.ChatColor; import org.bukkit.NamespacedKey; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -15,6 +14,7 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.api.events.PlayerLanguageChangeEvent; import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -79,7 +79,7 @@ class PlayerLanguageOption implements SlimefunGuideOption { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.languages")); menu.setEmptySlotsClickable(false); - menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F)); + menu.addMenuOpeningHandler(SoundEffect.GUIDE_LANGUAGE_OPEN_SOUND::playFor); for (int i = 0; i < 9; i++) { if (i == 1) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java index 48b7ac5a5..6761a9c19 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java @@ -10,7 +10,6 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -21,6 +20,7 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService; import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -63,7 +63,7 @@ public final class SlimefunGuideSettings { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.settings")); menu.setEmptySlotsClickable(false); - menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F)); + menu.addMenuOpeningHandler(SoundEffect.GUIDE_OPEN_SETTING_SOUND::playFor); ChestMenuUtils.drawBackground(menu, BACKGROUND_SLOTS); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java index be156fc4d..42de523fe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java @@ -1,6 +1,7 @@ package io.github.thebusybiscuit.slimefun4.core.services; import java.io.File; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,11 +37,12 @@ public class PermissionsService { config = new Config(plugin, "permissions.yml"); // @formatter:off - config.getConfiguration().options().header( - "This file is used to assign permission nodes to items from Slimefun or any of its addons.\n" + - "To assign an item a certain permission node you simply have to set the 'permission' attribute\n" + - "to your desired permission node.\n" + - "You can also customize the text that is displayed when a Player does not have that permission." + config.getConfiguration().options().setHeader(Collections.singletonList(""" + This file is used to assign permission nodes to items from Slimefun or any of its addons. + To assign an item a certain permission node you simply have to set the 'permission' attribute + to your desired permission node. + You can also customize the text that is displayed when a Player does not have that permission. + """) ); // @formatter:on diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java index 171fd85d3..d7cd73b2c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java @@ -6,58 +6,107 @@ import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.apache.commons.lang.Validate; -import org.bukkit.Keyed; + +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; + import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.SoundCategory; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import com.google.common.base.Preconditions; /** * This enum holds references to all our sounds. * * @author TheBusyBiscuit - * + * @author J3fftw1 + * * @see SoundService * @see SoundConfiguration * */ public enum SoundEffect { + ANCIENT_ALTAR_ITEM_CHECK_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F), + ANCIENT_ALTAR_ITEM_DROP_SOUND(Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1F, 1F), + ANCIENT_ALTAR_ITEM_PICK_UP_SOUND(Sound.ENTITY_ITEM_PICKUP, 1F, 1F), + ANCIENT_ALTAR_FINISH_SOUND(Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F), + ANCIENT_ALTAR_START_SOUND(Sound.ENTITY_ILLUSIONER_PREPARE_MIRROR, 1F, 1F), + ANCIENT_PEDESTAL_ITEM_PLACE_SOUND(Sound.ENTITY_ITEM_PICKUP, 0.5F, 0.5F), ARMOR_FORGE_FINISH_SOUND(Sound.BLOCK_ANVIL_USE, 1F, 1F), ARMOR_FORGE_WORKING_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), + AUTO_CRAFTER_GUI_CLICK_SOUND(Sound.UI_BUTTON_CLICK, 1F, 1F), + AUTO_CRAFTER_UPDATE_RECIPE(Sound.UI_BUTTON_CLICK, 1F, 1F), AUTOMATED_PANNING_MACHINE_FAIL_SOUND(Sound.ENTITY_ARMOR_STAND_BREAK, 1F, 1F), AUTOMATED_PANNING_MACHINE_SUCCESS_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - BEE_BOOTS_FALL_SOUND("block.honey_block.fall", 1F, 1F), + BEE_BOOTS_FALL_SOUND(Sound.BLOCK_HONEY_BLOCK_FALL, 1F, 1F), + BACKPACK_CLOSE_SOUND(Sound.ENTITY_HORSE_ARMOR, 1F, 1F), + BACKPACK_OPEN_SOUND(Sound.ENTITY_HORSE_ARMOR, 1F, 1F), + COMPOSTER_COMPOST_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), + COMPRESSOR_CRAFT_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), + COMPRESSOR_CRAFT_CONTRACT_SOUND(Sound.BLOCK_PISTON_CONTRACT, 1F, 1F), + COMPRESSOR_CRAFT_EXTEND_SOUND(Sound.BLOCK_PISTON_EXTEND, 1F, 1F), + COOLER_CONSUME_SOUND(Sound.ENTITY_GENERIC_DRINK, 1F, 1F), + CRUCIBLE_ADD_WATER_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), + CRUCIBLE_ADD_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F , 1F), + CRUCIBLE_BLOCK_BREAK_SOUND(Sound.BLOCK_METAL_BREAK, 1F, 1F), + CRUCIBLE_GENERATE_LIQUID_SOUND(Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F), + CRUCIBLE_INTERACT_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), + CRUCIBLE_PLACE_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F , 1F), + CRUCIBLE_PLACE_WATER_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), + DEBUG_FISH_CLICK_SOUND(Sound.BLOCK_BAMBOO_PLACE, 1F, 1F), DIET_COOKIE_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), + ENCHANTMENT_RUNE_ADD_ENCHANT_SOUND(Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F), ENDER_BACKPACK_OPEN_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 1F), ENHANCED_CRAFTING_TABLE_CRAFT_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), ELYTRA_CAP_IMPACT_SOUND(Sound.BLOCK_STONE_HIT, 1F, 1F), EXPLOSIVE_BOW_HIT_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F), + EXPLOSIVE_TOOL_EXPLODE_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F), FISHERMAN_ANDROID_FISHING_SOUND(Sound.ENTITY_PLAYER_SPLASH, 0.3F, 0.7F), FLASK_OF_KNOWLEDGE_FILLUP_SOUND(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 0.5F), + GUIDE_BUTTON_CLICK_SOUND(Sound.ITEM_BOOK_PAGE_TURN, 1F, 1F), + GUIDE_CONTRIBUTORS_OPEN_SOUND(Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F), + GUIDE_LANGUAGE_OPEN_SOUND(Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F), + GUIDE_OPEN_SETTING_SOUND(Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F), + GRIND_STONE_INTERACT_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), + IGNITION_CHAMBER_USE_FLINT_AND_STEEL_SOUND(Sound.ENTITY_ITEM_BREAK, 1F, 1F), INFUSED_HOPPER_TELEPORT_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 0.5F, 2F), INFUSED_MAGNET_TELEPORT_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 0.25F, 0.9F), - IRON_GOLEM_ASSEMBLER_ASSEMBLE_SOUND("entity.iron_golem.repair", 0.5F, 1F), + IRON_GOLEM_ASSEMBLER_ASSEMBLE_SOUND(Sound.ENTITY_IRON_GOLEM_REPAIR, 0.5F, 1F), JETBOOTS_THRUST_SOUND(Sound.ENTITY_TNT_PRIMED, 0.25F, 1F), JETPACK_THRUST_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 0.25F, 1F), JUICER_USE_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), + LIMITED_USE_ITEM_BREAK_SOUND(Sound.ENTITY_ITEM_BREAK, 1F, 1F), MAGICAL_EYE_OF_ENDER_USE_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 1F), MAGIC_SUGAR_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), + MAGIC_WORKBENCH_FINISH_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), + MAGIC_WORKBENCH_START_ANIMATION_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), + MINER_ANDROID_BLOCK_GENERATION_SOUND(Sound.BLOCK_FIRE_EXTINGUISH, 0.075F, 0.8F), + MINING_TASK_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 0.2F, 1F), + ORE_WASHER_WASH_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), PLAYER_RESEARCHING_SOUND(Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F), + PORTABLE_DUSTBIN_OPEN_SOUND(Sound.BLOCK_ANVIL_LAND, 1F, 1F), PORTABLE_CRAFTER_OPEN_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), PRESSURE_CHAMBER_FINISH_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), PRESSURE_CHAMBER_WORKING_SOUND(Sound.ENTITY_TNT_PRIMED, 1F, 1F), + PROGRAMMABLE_ANDROID_SCRIPT_DOWNLOAD_SOUND(Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F), SLIME_BOOTS_FALL_SOUND(Sound.BLOCK_SLIME_BLOCK_FALL, 1F, 1F), + TELEPORTATION_MANAGER_OPEN_GUI(Sound.UI_BUTTON_CLICK, 1F, 1F), + GPS_NETWORK_ADD_WAYPOINT(Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 1F), + GPS_NETWORK_CREATE_WAYPOINT(Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F), + GPS_NETWORK_OPEN_PANEL_SOUND(Sound.UI_BUTTON_CLICK, 1F, 1F), SMELTERY_CRAFT_SOUND(Sound.BLOCK_LAVA_POP, 1F, 1F), SOULBOUND_RUNE_RITUAL_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F), SPLINT_CONSUME_SOUND(Sound.ENTITY_SKELETON_HURT, 1F, 1F), + STOMPER_BOOTS_STOMP_SOUND(Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F), + TAPE_MEASURE_MEASURE_SOUND(Sound.ITEM_BOOK_PUT, 1, 0.7F), TOME_OF_KNOWLEDGE_USE_SOUND(Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F), - TRASH_CAN_OPEN_SOUND(Sound.BLOCK_ANVIL_LAND, 1F, 1F), + TELEPORT_UPDATE_SOUND(Sound.BLOCK_BEACON_AMBIENT, 1F, 0.6F), + TELEPORT_SOUND(Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F), VAMPIRE_BLADE_HEALING_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F), + VANILLA_AUTO_CRAFTER_UPDATE_RECIPE_SOUND(Sound.UI_BUTTON_CLICK, 1F, 1F), VILLAGER_RUNE_TRANSFORM_SOUND(Sound.ENTITY_VILLAGER_CELEBRATE, 1F, 1.4F), VITAMINS_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), WIND_STAFF_USE_SOUND(Sound.ENTITY_TNT_PRIMED, 1F, 1F); @@ -67,9 +116,9 @@ public enum SoundEffect { private final float defaultPitch; SoundEffect(@Nonnull String sound, float volume, float pitch) { - Validate.notNull(sound, "The Sound id cannot be null!"); - Validate.isTrue(volume >= 0, "The volume cannot be a negative number."); - Validate.isTrue(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); + Preconditions.checkNotNull(sound, "The Sound id cannot be null!"); + Preconditions.checkArgument(volume >= 0, "The volume cannot be a negative number."); + Preconditions.checkArgument(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); this.defaultSound = sound; this.defaultVolume = volume; @@ -77,20 +126,11 @@ public enum SoundEffect { } SoundEffect(@Nonnull Sound sound, float volume, float pitch) { - Validate.notNull(sound, "The Sound id cannot be null!"); - Validate.isTrue(volume >= 0, "The volume cannot be a negative number."); - Validate.isTrue(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); - - /* - * Only Minecraft 1.16+ implements Keyed for Sound. - * So we need to check this first. - */ - if (sound instanceof Keyed) { - this.defaultSound = sound.getKey().getKey(); - } else { - this.defaultSound = sound.name().toLowerCase(Locale.ROOT).replace('_', '.'); - } + Preconditions.checkNotNull(sound, "The Sound id cannot be null!"); + Preconditions.checkArgument(volume >= 0, "The volume cannot be a negative number."); + Preconditions.checkArgument(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); + this.defaultSound = sound.getKey().getKey(); this.defaultVolume = volume; this.defaultPitch = pitch; } @@ -109,12 +149,11 @@ public enum SoundEffect { /** * This method will play this {@link SoundEffect} only to the given {@link Player} using the * eye {@link Location} of the {@link Player} and the {@link SoundCategory} {@code PLAYERS}. - * - * @param player - * The {@link Player} which to play the {@link Sound} to. + * + * @param player The {@link Player} which to play the {@link Sound} to. */ public void playFor(@Nonnull Player player) { - Validate.notNull(player, "Cannot play sounds to a Player that is null!"); + Preconditions.checkNotNull(player, "Cannot play sounds to a Player that is null!"); SoundConfiguration config = getConfiguration(); if (config != null) { @@ -126,17 +165,15 @@ public enum SoundEffect { /** * This method will play this {@link SoundEffect} at the given {@link Location} using the * provided {@link SoundCategory}. - * - * @param loc - * The {@link Location} at which to play the {@link SoundEffect}. - * @param category - * The {@link SoundCategory} that should be used. + * + * @param loc The {@link Location} at which to play the {@link SoundEffect}. + * @param category The {@link SoundCategory} that should be used. */ public void playAt(@Nonnull Location loc, @Nonnull SoundCategory category) { - Validate.notNull(loc, "The location should not be null."); + Preconditions.checkNotNull(loc, "The location should not be null."); SoundConfiguration config = getConfiguration(); - if (config != null) { + if (config != null && loc.getWorld() != null) { loc.getWorld().playSound(loc, config.getSoundId(), category, config.getVolume(), config.getPitch()); } } @@ -144,18 +181,17 @@ public enum SoundEffect { /** * This method will play this {@link SoundEffect} at the {@link Location} of the given {@link Block}, * the used {@link SoundCategory} will be {@code BLOCKS}. - * - * @param block - * The {@link Block} at which to play the {@link SoundEffect} + * + * @param block The {@link Block} at which to play the {@link SoundEffect} */ public void playAt(@Nonnull Block block) { - Validate.notNull(block, "The block cannot be null."); + Preconditions.checkNotNull(block, "The block cannot be null."); playAt(block.getLocation(), SoundCategory.BLOCKS); } /** * This returns the default sound id. - * + * * @return The default sound id. */ public @Nonnull String getDefaultSoundId() { @@ -164,20 +200,19 @@ public enum SoundEffect { /** * This returns the default volume. - * + * * @return The default volume. */ - float getDefaultVolume() { + public float getDefaultVolume() { return defaultVolume; } /** * This returns the default pitch. - * + * * @return The default pitch. */ - float getDefaultPitch() { + public float getDefaultPitch() { return defaultPitch; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java index 7eb54b4fd..55cb63074 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services.sounds; +import java.util.Collections; import java.util.EnumMap; import java.util.Map; import java.util.logging.Level; @@ -7,17 +8,16 @@ import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.apache.commons.lang.Validate; - import io.github.bakedlibs.dough.config.Config; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import com.google.common.base.Preconditions; + /** * The {@link SoundService} is responsible for our sound management. * It allows server owners to fully customize their users' sound experience. - * - * @author TheBusyBiscuit * + * @author TheBusyBiscuit */ public class SoundService { @@ -35,19 +35,20 @@ public class SoundService { config = new Config(plugin, "sounds.yml"); // @formatter:off - config.getConfiguration().options().header( - "This file is used to assign the sounds which Slimefun will play." + - "\nYou can fully customize any sound you want and even change their pitch" + - "\nand volume. To disable a sound, simply set the volume to zero." + config.getConfiguration().options().setHeader(Collections.singletonList(""" + This file is used to assign the sounds which Slimefun will play. + You can fully customize any sound you want and even change their pitch + and volume. To disable a sound, simply set the volume to zero. + """) ); // @formatter:on - config.getConfiguration().options().copyHeader(true); + config.getConfiguration().options().parseComments(true); } /** * This method reloads every {@link SoundConfiguration}. - * + * * @param save * Whether to save the defaults to disk */ @@ -97,14 +98,14 @@ public class SoundService { /** * This returns the currently used (immutable) {@link SoundConfiguration} for the given {@link SoundEffect}. - * + * * @param sound * The {@link SoundEffect} - * + * * @return The corresponding {@link SoundConfiguration}. This may be null if something went wrong */ public @Nullable SoundConfiguration getConfiguration(@Nonnull SoundEffect sound) { - Validate.notNull(sound, "The sound must not be null!"); + Preconditions.checkNotNull(sound, "The sound must not be null!"); return soundMap.get(sound); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index d3f004c41..bd4618ac1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -252,7 +252,7 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon { command.register(); registry.load(this, config); loadTags(); - soundService.reload(false);; + soundService.reload(false); } /** @@ -837,6 +837,11 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon { return instance.hologramsService; } + /** + * This returns our {@link SoundService} which handles the configuration of all sounds used in Slimefun + * + * @return Our instance of {@link SoundService} + */ @Nonnull public static SoundService getSoundService() { validateInstance(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 2e8629600..21cee1d00 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -14,7 +14,6 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.Tag; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -44,6 +43,7 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; @@ -67,7 +67,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHan public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { private static final int MAX_ITEM_GROUPS = 36; - private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN; private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 }; private final ItemStack item; @@ -80,16 +79,6 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)"); } - /** - * This returns the {@link Sound} which is played when someone navigates through - * the {@link SlimefunGuide} - * - * @return The {@link Sound} - */ - public @Nonnull Sound getSound() { - return sound; - } - @Override public @Nonnull SlimefunGuideMode getMode() { return SlimefunGuideMode.SURVIVAL_MODE; @@ -683,7 +672,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { menu.addMenuClickHandler(28, (pl, slot, itemstack, action) -> { if (page > 0) { displayRecipes(pl, profile, menu, sfItem, page - 1); - pl.playSound(pl.getLocation(), sound, 1, 1); + SoundEffect.GUIDE_BUTTON_CLICK_SOUND.playFor(pl); } return false; @@ -693,7 +682,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { menu.addMenuClickHandler(34, (pl, slot, itemstack, action) -> { if (recipes.size() > (18 * (page + 1))) { displayRecipes(pl, profile, menu, sfItem, page + 1); - pl.playSound(pl.getLocation(), sound, 1, 1); + SoundEffect.GUIDE_BUTTON_CLICK_SOUND.playFor(pl); } return false; @@ -753,7 +742,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.main")); menu.setEmptySlotsClickable(false); - menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), sound, 1, 1)); + menu.addMenuOpeningHandler(SoundEffect.GUIDE_BUTTON_CLICK_SOUND::playFor); return menu; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java index ff4b0026c..c4377d458 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java @@ -9,7 +9,6 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -22,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; @@ -116,7 +116,7 @@ public abstract class LimitedUseItem extends SimpleSlimefunItem int usesLeft = pdc.getOrDefault(key, PersistentDataType.INTEGER, getMaxUseCount()); if (usesLeft == 1) { - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); + SoundEffect.LIMITED_USE_ITEM_BREAK_SOUND.playFor(p); item.setAmount(0); item.setType(Material.AIR); } else { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java index 5ec8b3240..a95bbbbbe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java @@ -8,7 +8,6 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; @@ -26,6 +25,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -140,7 +140,7 @@ public class AncientPedestal extends SimpleSlimefunItem { entity.setCustomNameVisible(true); entity.setCustomName(nametag); SlimefunUtils.markAsNoPickup(entity, "altar_item"); - p.playSound(b.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.3F, 0.3F); + SoundEffect.ANCIENT_PEDESTAL_ITEM_PLACE_SOUND.playAt(b); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java index fbbbdb108..c4fa1a030 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java @@ -46,7 +46,7 @@ public enum AndroidType { FIGHTER, /** - * The {@link FisherAndroid} can catch a fish and other materials. + * The {@link FishermanAndroid} can catch a fish and other materials. */ FISHERMAN, diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java index 7a652caab..a6ce80e2f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java @@ -11,10 +11,10 @@ import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.collections.RandomizedSet; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java index 13b55f4c3..03fba08cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java @@ -182,7 +182,7 @@ public enum Instruction { CHOP_TREE(AndroidType.WOODCUTTER, HeadTexture.SCRIPT_CHOP_TREE), /** - * This {@link Instruction} makes a {@link FisherAndroid} try to catch fish from + * This {@link Instruction} makes a {@link FishermanAndroid} try to catch fish from * the water below. */ CATCH_FISH(AndroidType.FISHERMAN, HeadTexture.SCRIPT_FISH, (android, b, inv, face) -> android.fish(b, inv)), diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java index 89c7878bb..be397c505 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java @@ -11,7 +11,6 @@ import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Particle; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; @@ -22,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.InfiniteBlockGenerator; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; @@ -148,7 +148,7 @@ public class MinerAndroid extends ProgrammableAndroid { } // "poof" a "new" block was generated - block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.075F, 0.8F); + SoundEffect.MINER_ANDROID_BLOCK_GENERATION_SOUND.playAt(block); block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015); } else { block.setType(Material.AIR); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 0a3a2f7c7..471551575 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -14,7 +14,6 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -45,6 +44,7 @@ import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -373,7 +373,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, ChestMenu menu = new ChestMenu("Android Scripts"); menu.setEmptySlotsClickable(false); - menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F)); + menu.addMenuOpeningHandler(SoundEffect.PROGRAMMABLE_ANDROID_SCRIPT_DOWNLOAD_SOUND::playFor); List