1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Implement new sound system (#3880)

Co-authored-by: TheBusyBiscuit <mrCookieSlime@gmail.com>
Co-authored-by: TheBusyBiscuit <TheBusyBiscuit@users.noreply.github.com>
This commit is contained in:
J3fftw 2023-06-29 22:43:43 +02:00 committed by GitHub
parent 811933b1eb
commit f0ac184c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 316 additions and 283 deletions

View File

@ -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

View File

@ -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);
}
});

View File

@ -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 {
/*

View File

@ -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"))));

View File

@ -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()) {

View File

@ -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);

View File

@ -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<String> {
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) {

View File

@ -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);

View File

@ -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

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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<ItemUseHandler>
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 {

View File

@ -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<BlockDispenseHandler> {
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);
}
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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)),

View File

@ -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);

View File

@ -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<Script> scripts = Script.getUploadedScripts(getAndroidType());
int pages = (scripts.size() / 45) + 1;

View File

@ -6,10 +6,10 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
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;
/**
* {@link LongFallBoots} are a pair of boots which negate fall damage.
@ -33,7 +33,7 @@ public class LongFallBoots extends SlimefunArmorPiece {
/**
* This returns the {@link SoundEffect} that is played upon landing with these boots.
*
*
* @return The {@link SoundEffect} played when landing
*/
@Nonnull

View File

@ -6,7 +6,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
@ -23,6 +22,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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;
/**
@ -47,7 +47,7 @@ public class StomperBoots extends SlimefunItem {
*/
public void stomp(@Nonnull EntityDamageEvent fallDamageEvent) {
Player player = (Player) fallDamageEvent.getEntity();
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
SoundEffect.STOMPER_BOOTS_STOMP_SOUND.playFor(player);
player.setVelocity(new Vector(0, 0.7, 0));
for (Entity entity : player.getNearbyEntities(4, 4, 4)) {

View File

@ -15,7 +15,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -36,6 +35,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutoCrafterListener;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask;
@ -314,7 +314,7 @@ public abstract class AbstractAutoCrafter extends SlimefunItem implements Energy
recipe.show(menu, task);
menu.open(p);
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_GUI_CLICK_SOUND.playFor(p);
// Only schedule the task if necessary
if (!task.isEmpty()) {
@ -325,7 +325,7 @@ public abstract class AbstractAutoCrafter extends SlimefunItem implements Energy
@ParametersAreNonnullByDefault
private void setRecipeEnabled(Player p, Block b, boolean enabled) {
p.closeInventory();
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_GUI_CLICK_SOUND.playFor(p);
BlockState state = PaperLib.getBlockState(b, false).getState();
// Make sure the block is still a Skull
@ -344,7 +344,7 @@ public abstract class AbstractAutoCrafter extends SlimefunItem implements Energy
private void deleteRecipe(Player p, Block b) {
setSelectedRecipe(b, null);
p.closeInventory();
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_GUI_CLICK_SOUND.playFor(p);
Slimefun.getLocalization().sendMessage(p, "messages.auto-crafting.recipe-removed");
}

View File

@ -7,7 +7,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.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Skull;
@ -21,6 +20,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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.implementation.tasks.AsyncRecipeChoiceTask;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
@ -98,7 +98,7 @@ public class SlimefunAutoCrafter extends AbstractAutoCrafter {
menu.addItem(49, new CustomItemStack(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select")));
menu.addMenuClickHandler(49, (pl, stack, slot, action) -> {
setSelectedRecipe(b, recipe);
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_UPDATE_RECIPE.playAt(b);
Slimefun.getLocalization().sendMessage(p, "messages.auto-crafting.recipe-set");
showRecipe(p, b, recipe);
return false;
@ -108,7 +108,7 @@ public class SlimefunAutoCrafter extends AbstractAutoCrafter {
recipe.show(menu, task);
menu.open(p);
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_UPDATE_RECIPE.playAt(b);;
if (!task.isEmpty()) {
task.start(menu.toInventory());

View File

@ -12,7 +12,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Skull;
@ -31,6 +31,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService;
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.ChestMenuUtils;
@ -123,7 +124,7 @@ public class VanillaAutoCrafter extends AbstractAutoCrafter {
menu.open(p);
task.start(menu.toInventory());
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.VANILLA_AUTO_CRAFTER_UPDATE_RECIPE_SOUND.playAt(p.getLocation(), SoundCategory.PLAYERS);
}
}
@ -134,7 +135,7 @@ public class VanillaAutoCrafter extends AbstractAutoCrafter {
menu.replaceExistingItem(46, ChestMenuUtils.getPreviousButton(p, index + 1, recipes.size()));
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
if (index > 0) {
pl.playSound(pl.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_GUI_CLICK_SOUND.playFor(pl);
offerRecipe(p, b, recipes, index - 1, menu, task);
}
@ -144,7 +145,7 @@ public class VanillaAutoCrafter extends AbstractAutoCrafter {
menu.replaceExistingItem(52, ChestMenuUtils.getNextButton(p, index + 1, recipes.size()));
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
if (index < (recipes.size() - 1)) {
pl.playSound(pl.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_GUI_CLICK_SOUND.playFor(pl);
offerRecipe(p, b, recipes, index + 1, menu, task);
}
@ -158,7 +159,7 @@ public class VanillaAutoCrafter extends AbstractAutoCrafter {
setSelectedRecipe(b, recipe);
pl.closeInventory();
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
SoundEffect.AUTO_CRAFTER_GUI_CLICK_SOUND.playFor(pl);
Slimefun.getLocalization().sendMessage(p, "messages.auto-crafting.recipe-set");
showRecipe(p, b, recipe);

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.EnderChest;
@ -30,7 +31,7 @@ public class EnderBackpack extends SimpleSlimefunItem<ItemUseHandler> implements
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
Player p = e.getPlayer();
p.openInventory(p.getEnderChest());

View File

@ -10,7 +10,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
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;
@ -25,6 +24,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -94,7 +94,7 @@ public class Composter extends SimpleSlimefunItem<BlockUseHandler> implements Re
});
tasks.thenRun(20, () -> {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
SoundEffect.COMPOSTER_COMPOST_SOUND.playFor(p);
pushItem(b, output.clone());
});

View File

@ -9,7 +9,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.Tag;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
@ -27,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -166,7 +166,7 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
if (isWater && block.getWorld().getEnvironment() == Environment.NETHER && !allowWaterInNether.getValue()) {
// We will still consume the items but won't generate water in the Nether.
block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getLocation().add(0.5, 0.5, 0.5), 4);
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
SoundEffect.CRUCIBLE_GENERATE_LIQUID_SOUND.playAt(block);
return;
}
@ -175,7 +175,7 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
} else if (block.getType() == (isWater ? Material.LAVA : Material.WATER)) {
int level = ((Levelled) block.getBlockData()).getLevel();
block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE);
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
SoundEffect.CRUCIBLE_GENERATE_LIQUID_SOUND.playAt(block);
} else {
Slimefun.runSync(() -> placeLiquid(block, isWater), 50L);
}
@ -189,10 +189,10 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
}
if (level == 0) {
block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F);
Slimefun.runSync(() -> runPostTask(block, water ? SoundEffect.CRUCIBLE_ADD_WATER_SOUND : SoundEffect.CRUCIBLE_ADD_LAVA_SOUND, 1));
} else {
int finalLevel = 7 - level;
Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L);
Slimefun.runSync(() -> runPostTask(block, water ? SoundEffect.CRUCIBLE_ADD_WATER_SOUND : SoundEffect.CRUCIBLE_ADD_LAVA_SOUND, finalLevel), 50L);
}
}
@ -204,7 +204,7 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
if (water && block.getBlockData() instanceof Waterlogged waterlogged) {
waterlogged.setWaterlogged(true);
block.setBlockData(waterlogged, false);
block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
SoundEffect.CRUCIBLE_PLACE_WATER_SOUND.playAt(block);
return;
}
@ -212,18 +212,17 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
BlockStorage.clearBlockInfo(block);
}
}
runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1);
runPostTask(block, water ? SoundEffect.CRUCIBLE_PLACE_WATER_SOUND : SoundEffect.CRUCIBLE_PLACE_LAVA_SOUND, 1);
}
@ParametersAreNonnullByDefault
private void runPostTask(Block block, Sound sound, int times) {
private void runPostTask(Block block, SoundEffect sound, int times) {
if (!(block.getBlockData() instanceof Levelled le)) {
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
SoundEffect.CRUCIBLE_BLOCK_BREAK_SOUND.playAt(block);
return;
}
block.getWorld().playSound(block.getLocation(), sound, 1F, 1F);
sound.playAt(block);
int level = 8 - times;
le.setLevel(level);
block.setBlockData(le, false);
@ -231,7 +230,7 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
if (times < 8) {
Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L);
} else {
block.getWorld().playSound(block.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
SoundEffect.CRUCIBLE_INTERACT_SOUND.playAt(block);
}
}

View File

@ -6,7 +6,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -22,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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.implementation.handlers.VanillaInventoryDropHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery;
@ -94,13 +94,13 @@ public class IgnitionChamber extends SlimefunItem {
if (((Damageable) meta).getDamage() >= item.getType().getMaxDurability()) {
// The Flint and Steel broke
item.setAmount(0);
smelteryBlock.getWorld().playSound(smelteryBlock.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
SoundEffect.IGNITION_CHAMBER_USE_FLINT_AND_STEEL_SOUND.playAt(smelteryBlock);
} else {
item.setItemMeta(meta);
}
}
smelteryBlock.getWorld().playSound(smelteryBlock.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 1, 1);
SoundEffect.IGNITION_CHAMBER_USE_FLINT_AND_STEEL_SOUND.playAt(smelteryBlock);
return true;
} else {
// Notify the Player there is a chamber but without any Flint and Steel

View File

@ -8,11 +8,11 @@ import org.bukkit.SoundCategory;
import org.bukkit.entity.IronGolem;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.bakedlibs.dough.items.CustomItemStack;
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 io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.food;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
@ -32,7 +33,7 @@ public class DietCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
}
@Override
public ItemConsumptionHandler getItemHandler() {
public @Nonnull ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> {
Slimefun.getLocalization().sendMessage(p, "messages.diet-cookie");
SoundEffect.DIET_COOKIE_CONSUME_SOUND.playFor(p);

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.food;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.GameMode;
@ -32,7 +33,7 @@ public class MagicSugar extends SimpleSlimefunItem<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
// Check if it is being placed into an ancient altar.
if (e.getClickedBlock().isPresent()) {

View File

@ -17,8 +17,8 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -54,7 +54,7 @@ public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
}
@Override
public BlockTicker getItemHandler() {
public @Nonnull BlockTicker getItemHandler() {
return new BlockTicker() {
@Override
@ -93,7 +93,7 @@ public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
* Play a sound if at least one item was teleported and
* the "silent" setting is set to false.
*/
if (playSound && !silent.getValue().booleanValue()) {
if (playSound && !silent.getValue()) {
SoundEffect.INFUSED_HOPPER_TELEPORT_SOUND.playAt(b);
}
}

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player;
@ -30,12 +31,12 @@ public class KnowledgeFlask extends SimpleSlimefunItem<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
e.cancel();
Player p = e.getPlayer();
if (p.getLevel() >= 1 && (!e.getClickedBlock().isPresent() || !(e.getClickedBlock().get().getType().isInteractable()))) {
if (p.getLevel() >= 1 && (e.getClickedBlock().isEmpty() || !(e.getClickedBlock().get().getType().isInteractable()))) {
p.setLevel(p.getLevel() - 1);
ItemStack item = SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.clone();

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.ChatColor;
@ -27,7 +28,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunIte
/**
* The {@link KnowledgeTome} allows you to copy every unlocked {@link Research}
* from one {@link Player} to another.
*
*
* @author TheBusyBiscuit
*
*/
@ -39,7 +40,7 @@ public class KnowledgeTome extends SimpleSlimefunItem<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
Player p = e.getPlayer();
ItemStack item = e.getItem();

View File

@ -3,7 +3,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.SoundCategory;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -33,7 +32,7 @@ public class MagicEyeOfEnder extends SimpleSlimefunItem<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
e.cancel();
@ -41,7 +40,7 @@ public class MagicEyeOfEnder extends SimpleSlimefunItem<ItemUseHandler> {
if (hasArmor(p.getInventory())) {
p.launchProjectile(EnderPearl.class);
SoundEffect.MAGICAL_EYE_OF_ENDER_USE_SOUND.playAt(p.getLocation(), SoundCategory.PLAYERS);
SoundEffect.MAGICAL_EYE_OF_ENDER_USE_SOUND.playFor(p);
}
};
}

View File

@ -46,7 +46,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem<EntityInteractHandler
}
@Override
public EntityInteractHandler getItemHandler() {
public @Nonnull EntityInteractHandler getItemHandler() {
return (e, item, offhand) -> {
Entity entity = e.getRightClicked();

View File

@ -15,7 +15,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
@ -27,6 +27,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemDropHandler;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
@ -140,7 +141,7 @@ public class EnchantmentRune extends SimpleSlimefunItem<ItemDropHandler> {
if (rune.isValid() && item.isValid() && itemStack.getAmount() == 1) {
l.getWorld().spawnParticle(Particle.CRIT_MAGIC, l, 1);
l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F);
SoundEffect.ENCHANTMENT_RUNE_ADD_ENCHANT_SOUND.playAt(l, SoundCategory.PLAYERS);
item.remove();
rune.remove();

View File

@ -47,7 +47,7 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
}
@Override
public ItemDropHandler getItemHandler() {
public @Nonnull ItemDropHandler getItemHandler() {
return (e, p, item) -> {
if (isItem(item.getItemStack())) {
@ -116,9 +116,7 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
* @return Whether this {@link Entity} is compatible
*/
private boolean findCompatibleItem(@Nonnull Entity entity) {
if (entity instanceof Item) {
Item item = (Item) entity;
if (entity instanceof Item item) {
return item.getPickupDelay() == 0 && !SlimefunUtils.isSoulbound(item.getItemStack()) && !isItem(item.getItemStack());
}

View File

@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.GameMode;
@ -37,7 +38,7 @@ public class VillagerRune extends SimpleSlimefunItem<EntityInteractHandler> {
}
@Override
public EntityInteractHandler getItemHandler() {
public @Nonnull EntityInteractHandler getItemHandler() {
return (e, item, offhand) -> {
if (e.isCancelled() || !Slimefun.getProtectionManager().hasPermission(e.getPlayer(), e.getRightClicked().getLocation(), Interaction.INTERACT_ENTITY)) {
// They don't have permission to use it in this area

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
@ -37,7 +38,7 @@ public class WindStaff extends SimpleSlimefunItem<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
Player p = e.getPlayer();

View File

@ -1,9 +1,9 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.medical;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.GameMode;
import org.bukkit.SoundCategory;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -26,7 +26,7 @@ public class Splint extends SimpleSlimefunItem<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
Player p = e.getPlayer();
@ -39,11 +39,10 @@ public class Splint extends SimpleSlimefunItem<ItemUseHandler> {
ItemUtils.consumeItem(e.getItem(), false);
}
SoundEffect.SPLINT_CONSUME_SOUND.playAt(p.getLocation(), SoundCategory.PLAYERS);
SoundEffect.SPLINT_CONSUME_SOUND.playFor(p);
p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
e.cancel();
};
}
}

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.medical;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.GameMode;
@ -21,7 +22,7 @@ public class Vitamins extends MedicalSupply<ItemUseHandler> {
}
@Override
public ItemUseHandler getItemHandler() {
public @Nonnull ItemUseHandler getItemHandler() {
return e -> {
Player p = e.getPlayer();
SoundEffect.VITAMINS_CONSUME_SOUND.playFor(p);

View File

@ -19,6 +19,7 @@ import io.github.bakedlibs.dough.items.ItemUtils;
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 io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.papermc.lib.PaperLib;
@ -39,9 +40,9 @@ public class ArmorForge extends AbstractCraftingTable {
Inventory inv = dispenser.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) {
if (isCraftable(inv, inputs.get(i))) {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
for (ItemStack[] input : inputs) {
if (isCraftable(inv, input)) {
ItemStack output = RecipeType.getRecipeOutputList(this, input).clone();
if (SlimefunUtils.canPlayerUseItem(p, output, true)) {
craft(p, output, inv, possibleDispenser);

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
@ -49,7 +50,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine {
}
@Override
public List<ItemStack> getDisplayRecipes() {
public @Nonnull List<ItemStack> getDisplayRecipes() {
List<ItemStack> recipes = new ArrayList<>();
recipes.addAll(goldPan.getDisplayRecipes());

View File

@ -3,10 +3,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -20,6 +20,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.multiblocks.MultiBlockMachine;
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.SlimefunUtils;
@ -48,7 +49,7 @@ public class Compressor extends MultiBlockMachine {
}
@Override
public List<ItemStack> getDisplayRecipes() {
public @Nonnull List<ItemStack> getDisplayRecipes() {
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
}
@ -93,11 +94,13 @@ public class Compressor extends MultiBlockMachine {
Slimefun.runSync(() -> {
// TODO: Convert this mess into Sound Effects
if (j < 3) {
p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F);
} else {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
handleCraftedItem(output, dispenser, dispInv);
}
if (j == 1) {
SoundEffect.COMPRESSOR_CRAFT_CONTRACT_SOUND.playFor(p);
} else {
SoundEffect.COMPRESSOR_CRAFT_EXTEND_SOUND.playFor(p);
handleCraftedItem(output, dispenser, dispInv);
}
}
}, i * 20L);
}
}

View File

@ -19,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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.implementation.items.backpacks.SlimefunBackpack;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -40,9 +41,9 @@ public class EnhancedCraftingTable extends AbstractCraftingTable {
Inventory inv = dispenser.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) {
if (isCraftable(inv, inputs.get(i))) {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
for (ItemStack[] input : inputs) {
if (isCraftable(inv, input)) {
ItemStack output = RecipeType.getRecipeOutputList(this, input).clone();
if (SlimefunUtils.canPlayerUseItem(p, output, true)) {
craft(inv, possibleDispenser, p, b, output);
@ -99,7 +100,6 @@ public class EnhancedCraftingTable extends AbstractCraftingTable {
}
}
}
return true;
}
}

View File

@ -7,7 +7,6 @@ import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -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.multiblocks.MultiBlockMachine;
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.SlimefunUtils;
@ -106,7 +106,7 @@ public class GrindStone extends MultiBlockMachine {
}
@Override
public List<ItemStack> getDisplayRecipes() {
public @Nonnull List<ItemStack> getDisplayRecipes() {
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
}
@ -129,11 +129,10 @@ public class GrindStone extends MultiBlockMachine {
removing.setAmount(1);
inv.removeItem(removing);
outputInv.addItem(output);
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);
SoundEffect.GRIND_STONE_INTERACT_SOUND.playAt(b);
} else {
Slimefun.getLocalization().sendMessage(p, "machines.full-inventory", true);
}
return;
}
}
@ -142,5 +141,4 @@ public class GrindStone extends MultiBlockMachine {
Slimefun.getLocalization().sendMessage(p, "machines.unknown-material", true);
}
}
}

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
@ -44,7 +45,7 @@ public class Juicer extends MultiBlockMachine {
}
@Override
public List<ItemStack> getDisplayRecipes() {
public @Nonnull List<ItemStack> getDisplayRecipes() {
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
}
@ -69,6 +70,7 @@ public class Juicer extends MultiBlockMachine {
outputInv.addItem(adding);
SoundEffect.JUICER_USE_SOUND.playAt(b);
// Not changed since this is supposed to be a natural sound.
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK);
} else {
Slimefun.getLocalization().sendMessage(p, "machines.full-inventory", true);

View File

@ -6,7 +6,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -20,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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.implementation.items.backpacks.SlimefunBackpack;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -47,9 +47,9 @@ public class MagicWorkbench extends AbstractCraftingTable {
Inventory inv = dispenser.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) {
if (isCraftable(inv, inputs.get(i))) {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
for (ItemStack[] input : inputs) {
if (isCraftable(inv, input)) {
ItemStack output = RecipeType.getRecipeOutputList(this, input).clone();
if (SlimefunUtils.canPlayerUseItem(p, output, true)) {
craft(inv, possibleDispener, p, b, output);
@ -103,9 +103,9 @@ public class MagicWorkbench extends AbstractCraftingTable {
p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1);
if (current < 3) {
p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F);
SoundEffect.MAGIC_WORKBENCH_START_ANIMATION_SOUND.playAt(b);
} else {
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
SoundEffect.MAGIC_WORKBENCH_FINISH_SOUND.playAt(b);
handleCraftedItem(output, dispenser, dispInv);
}
}, j * 20L);

View File

@ -10,7 +10,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -22,6 +21,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
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.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -156,7 +156,7 @@ public class OreWasher extends MultiBlockMachine {
outputInv.addItem(output.clone());
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
SoundEffect.ORE_WASHER_WASH_SOUND.playAt(b);
} else {
Slimefun.getLocalization().sendMessage(p, "machines.full-inventory", true);
}

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Effect;
@ -33,7 +34,7 @@ public class PressureChamber extends MultiBlockMachine {
}
@Override
public List<ItemStack> getDisplayRecipes() {
public @Nonnull List<ItemStack> getDisplayRecipes() {
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
}

View File

@ -28,6 +28,7 @@ import io.github.bakedlibs.dough.inventory.InvUtils;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.bakedlibs.dough.protection.Interaction;
import io.github.bakedlibs.dough.scheduling.TaskQueue;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.papermc.lib.PaperLib;
@ -198,8 +199,10 @@ class MiningTask implements Runnable {
}
if (miner.canMine(b) && push(miner.getOutcome(b.getType()))) {
// Not changed since this is supposed to be a natural sound.
furnace.getWorld().playEffect(furnace.getLocation(), Effect.STEP_SOUND, b.getType());
furnace.getWorld().playSound(furnace.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.2F, 1F);
SoundEffect.MINING_TASK_SOUND.playAt(furnace);
b.setType(Material.AIR);
fuelLevel--;

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
@ -31,7 +32,7 @@ public class ExplosiveShovel extends ExplosiveTool {
}
@Override
protected boolean canBreak(Player p, Block b) {
protected boolean canBreak(@Nonnull Player p, Block b) {
return SlimefunTag.EXPLOSIVE_SHOVEL_BLOCKS.isTagged(b.getType()) && Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.BREAK_BLOCK);
}

View File

@ -9,7 +9,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
@ -27,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
@ -64,7 +64,7 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
Block b = e.getBlock();
b.getWorld().createExplosion(b.getLocation(), 0);
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F);
SoundEffect.EXPLOSIVE_TOOL_EXPLODE_SOUND.playAt(b);
List<Block> blocks = findBlocks(b);
breakBlocks(e, p, tool, b, blocks, drops);
@ -76,7 +76,7 @@ public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements
private void breakBlocks(BlockBreakEvent e, Player p, ItemStack item, Block b, List<Block> blocks, List<ItemStack> drops) {
List<Block> blocksToDestroy = new ArrayList<>();
if (callExplosionEvent.getValue().booleanValue()) {
if (callExplosionEvent.getValue()) {
BlockExplodeEvent blockExplodeEvent = new BlockExplodeEvent(b, blocks, 0);
Bukkit.getServer().getPluginManager().callEvent(blockExplodeEvent);

View File

@ -72,9 +72,7 @@ public class LumberAxe extends SlimefunItem implements NotPlaceable {
if (isUnstrippedLog(block)) {
List<Block> logs = Vein.find(block, MAX_STRIPPED, this::isUnstrippedLog);
if (logs.contains(block)) {
logs.remove(block);
}
logs.remove(block);
for (Block b : logs) {
if (!BlockStorage.hasBlockInfo(b) && Slimefun.getProtectionManager().hasPermission(e.getPlayer(), b, Interaction.BREAK_BLOCK)) {

View File

@ -25,9 +25,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan;
* will be voided.
*
* @author TheBusyBiscuit
*
* @see TrashCan
*
*/
public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable {
@ -43,7 +40,7 @@ public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> implemen
Player p = e.getPlayer();
p.openInventory(Bukkit.createInventory(null, 9 * 3, ChatColor.DARK_RED + "Delete Items"));
SoundEffect.TRASH_CAN_OPEN_SOUND.playFor(p);
SoundEffect.PORTABLE_DUSTBIN_OPEN_SOUND.playFor(p);
};
}
}

View File

@ -10,7 +10,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -24,6 +23,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
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.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.JsonUtils;
@ -84,7 +84,7 @@ public class TapeMeasure extends SimpleSlimefunItem<ItemUseHandler> implements N
OptionalDouble distance = getDistance(p, item, block);
if (distance.isPresent()) {
p.playSound(block.getLocation(), Sound.ITEM_BOOK_PUT, 1, 0.7F);
SoundEffect.TAPE_MEASURE_MEASURE_SOUND.playAt(block);
String label = format.format(distance.getAsDouble());
Slimefun.getLocalization().sendMessage(p, "messages.tape-measure.distance", msg -> msg.replace("%distance%", label));
}

View File

@ -53,8 +53,8 @@ public class ExplosiveBow extends SlimefunBow {
SoundEffect.EXPLOSIVE_BOW_HIT_SOUND.playAt(target.getLocation(), SoundCategory.PLAYERS);
int radius = range.getValue();
Collection<Entity> entites = target.getWorld().getNearbyEntities(target.getLocation(), radius, radius, radius, this::canDamage);
for (Entity nearby : entites) {
Collection<Entity> entities = target.getWorld().getNearbyEntities(target.getLocation(), radius, radius, radius, this::canDamage);
for (Entity nearby : entities) {
LivingEntity entity = (LivingEntity) nearby;
Vector distanceVector = entity.getLocation().toVector().subtract(target.getLocation().toVector()).add(new Vector(0, 0.75, 0));
@ -77,7 +77,7 @@ public class ExplosiveBow extends SlimefunBow {
};
}
private boolean canDamage(@Nonnull Entity n) {
return n instanceof LivingEntity && !(n instanceof ArmorStand) && n.isValid();
private boolean canDamage(@Nonnull Entity entity) {
return entity instanceof LivingEntity && !(entity instanceof ArmorStand) && entity.isValid();
}
}

View File

@ -14,9 +14,9 @@ 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.items.settings.IntRangeSetting;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.handlers.WeaponUseHandler;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
/**

View File

@ -14,7 +14,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
@ -32,6 +31,7 @@ import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.bakedlibs.dough.protection.Interaction;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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.altar.AltarRecipe;
@ -157,7 +157,7 @@ public class AncientAltarListener implements Listener {
Slimefun.runSync(() -> removedItems.remove(uuid), 30L);
entity.remove();
p.playSound(pedestal.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 1F);
SoundEffect.ANCIENT_ALTAR_ITEM_PICK_UP_SOUND.playFor(p);
/*
* Fixes #3476
@ -217,9 +217,7 @@ public class AncientAltarListener implements Listener {
for (Block pedestal : pedestals) {
Optional<Item> stack = pedestalItem.getPlacedItem(pedestal);
if (stack.isPresent()) {
input.add(pedestalItem.getOriginalItemStack(stack.get()));
}
stack.ifPresent(item -> input.add(pedestalItem.getOriginalItemStack(item)));
}
Optional<ItemStack> result = getRecipeOutput(catalyst, input);
@ -233,7 +231,7 @@ public class AncientAltarListener implements Listener {
ItemUtils.consumeItem(p.getInventory().getItemInMainHand(), false);
}
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ILLUSIONER_PREPARE_MIRROR, 1, 1);
SoundEffect.ANCIENT_ALTAR_START_SOUND.playAt(b);
AncientAltarTask task = new AncientAltarTask(this, b, altarItem.getStepDelay(), result.get(), pedestals, consumed, p);
Slimefun.runSync(task, 10L);

View File

@ -13,7 +13,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -28,6 +28,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
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.backpacks.Cooler;
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
@ -60,7 +61,7 @@ public class BackpackListener implements Listener {
Player p = (Player) e.getPlayer();
if (markBackpackDirty(p)) {
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
SoundEffect.BACKPACK_CLOSE_SOUND.playFor(p);
}
}
@ -165,7 +166,7 @@ public class BackpackListener implements Listener {
// Check if someone else is currently viewing this backpack
if (!backpacks.containsValue(item)) {
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
SoundEffect.BACKPACK_OPEN_SOUND.playAt(p.getLocation(), SoundCategory.PLAYERS);
backpacks.put(p.getUniqueId(), item);
PlayerProfile.getBackpack(item, backpack -> {

View File

@ -4,7 +4,6 @@ import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -19,6 +18,7 @@ import org.bukkit.potion.PotionEffect;
import io.github.thebusybiscuit.slimefun4.api.events.CoolerFeedPlayerEvent;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
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.backpacks.Cooler;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice;
@ -123,7 +123,7 @@ public class CoolerListener implements Listener {
}
p.setSaturation(6F);
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_DRINK, 1F, 1F);
SoundEffect.COOLER_CONSUME_SOUND.playFor(p);
inv.setItem(slot, null);
backpack.markDirty();

View File

@ -8,7 +8,6 @@ import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
@ -26,6 +25,7 @@ import io.github.bakedlibs.dough.skins.PlayerHead;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
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.HeadTexture;
@ -96,7 +96,7 @@ public class DebugFishListener implements Listener {
block.setType(Material.PLAYER_HEAD);
PlayerHead.setSkin(block, HeadTexture.MISSING_TEXTURE.getAsSkin(), true);
p.playSound(block.getLocation(), Sound.BLOCK_BAMBOO_PLACE, 1, 1);
SoundEffect.DEBUG_FISH_CLICK_SOUND.playFor(p);
}, 2L);
} else if (BlockStorage.hasBlockInfo(b)) {
try {

View File

@ -34,35 +34,31 @@ public class ElytraImpactListener implements Listener {
@EventHandler
public void onPlayerCrash(EntityDamageEvent e) {
if (!(e.getEntity() instanceof Player)) {
if (!(e.getEntity() instanceof Player p)) {
// We only wanna handle damaged Players
return;
}
if (e.getCause() == DamageCause.FALL || e.getCause() == DamageCause.FLY_INTO_WALL) {
Player p = (Player) e.getEntity();
if (e.getCause() == DamageCause.FALL || e.getCause() == DamageCause.FLY_INTO_WALL && p.isGliding()) {
Optional<PlayerProfile> optional = PlayerProfile.find(p);
if (p.isGliding()) {
Optional<PlayerProfile> optional = PlayerProfile.find(p);
if (optional.isEmpty()) {
PlayerProfile.request(p);
return;
}
if (!optional.isPresent()) {
PlayerProfile.request(p);
return;
}
PlayerProfile profile = optional.get();
Optional<SlimefunArmorPiece> helmet = profile.getArmor()[0].getItem();
PlayerProfile profile = optional.get();
Optional<SlimefunArmorPiece> helmet = profile.getArmor()[0].getItem();
if (helmet.isPresent()) {
SlimefunItem item = helmet.get();
if (helmet.isPresent()) {
SlimefunItem item = helmet.get();
if (item.canUse(p, true) && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) {
SoundEffect.ELYTRA_CAP_IMPACT_SOUND.playFor(p);
e.setCancelled(true);
if (item.canUse(p, true) && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) {
SoundEffect.ELYTRA_CAP_IMPACT_SOUND.playFor(p);
e.setCancelled(true);
if (item instanceof DamageableItem damageableItem) {
damageableItem.damageItem(p, p.getInventory().getHelmet());
}
if (item instanceof DamageableItem damageableItem) {
damageableItem.damageItem(p, p.getInventory().getHelmet());
}
}
}

View File

@ -48,8 +48,7 @@ public class SlimefunBootsListener implements Listener {
@EventHandler
public void onEnderPearlDamage(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof EnderPearl && e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
if (e.getDamager() instanceof EnderPearl && e.getEntity() instanceof Player p) {
SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots());
if (boots instanceof EnderBoots && boots.canUse(p, true)) {
@ -59,21 +58,22 @@ public class SlimefunBootsListener implements Listener {
}
private void onFallDamage(@Nonnull EntityDamageEvent e) {
Player p = (Player) e.getEntity();
SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots());
if (e.getEntity() instanceof Player p) {
SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots());
if (boots != null) {
// Check if the boots were researched
if (!boots.canUse(p, true)) {
return;
}
if (boots != null) {
// Check if the boots were researched
if (!boots.canUse(p, true)) {
return;
}
if (boots instanceof StomperBoots stomperBoots) {
e.setCancelled(true);
stomperBoots.stomp(e);
} else if (boots instanceof LongFallBoots) {
e.setCancelled(true);
((LongFallBoots) boots).getSoundEffect().playAt(p.getLocation(), SoundCategory.PLAYERS);
if (boots instanceof StomperBoots stomperBoots) {
e.setCancelled(true);
stomperBoots.stomp(e);
} else if (boots instanceof LongFallBoots longFallBoots) {
e.setCancelled(true);
longFallBoots.getSoundEffect().playAt(p.getLocation(), SoundCategory.PLAYERS);
}
}
}
}

View File

@ -377,7 +377,7 @@ public final class SlimefunItemSetup {
new LongFallBoots(itemGroups.magicalArmor, SlimefunItems.SLIME_BOOTS, RecipeType.ARMOR_FORGE,
new ItemStack[] {null, null, null, new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.IRON_INGOT)},
new PotionEffect[] {new PotionEffect(PotionEffectType.JUMP, 300, 5)},
SoundEffect.SLIME_BOOTS_FALL_SOUND)
SoundEffect.SLIME_BOOTS_FALL_SOUND)
.register(plugin);
new SwordOfBeheading(itemGroups.weapons, SlimefunItems.SWORD_OF_BEHEADING, RecipeType.ENHANCED_CRAFTING_TABLE,

View File

@ -15,13 +15,14 @@ import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.events.AncientAltarCraftEvent;
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.altar.AncientAltar;
@ -134,7 +135,7 @@ public class AncientAltarTask implements Runnable {
Item entity = item.get();
particleLocations.add(pedestal.getLocation().add(0.5, 1.5, 0.5));
items.add(pedestalItem.getOriginalItemStack(entity));
pedestal.getWorld().playSound(pedestal.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F);
SoundEffect.ANCIENT_ALTAR_ITEM_CHECK_SOUND.playAt(pedestal);
dropLocation.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, pedestal.getLocation().add(0.5, 1.5, 0.5), 16, 0.3F, 0.2F, 0.3F);
dropLocation.getWorld().spawnParticle(Particle.CRIT_MAGIC, pedestal.getLocation().add(0.5, 1.5, 0.5), 8, 0.3F, 0.2F, 0.3F);
@ -154,7 +155,7 @@ public class AncientAltarTask implements Runnable {
// This should re-enable altar blocks on craft failure.
listener.getAltarsInUse().remove(altar.getLocation());
dropLocation.getWorld().playSound(dropLocation, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1F, 1F);
SoundEffect.ANCIENT_ALTAR_ITEM_DROP_SOUND.playAt(dropLocation, SoundCategory.BLOCKS);
positionLock.clear();
listener.getAltars().remove(altar);
}
@ -166,7 +167,7 @@ public class AncientAltarTask implements Runnable {
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
dropLocation.getWorld().playSound(dropLocation, Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F);
SoundEffect.ANCIENT_ALTAR_FINISH_SOUND.playAt(dropLocation, SoundCategory.BLOCKS);
dropLocation.getWorld().playEffect(dropLocation, Effect.STEP_SOUND, Material.EMERALD_BLOCK);
dropLocation.getWorld().dropItemNaturally(dropLocation.add(0, -0.5, 0), event.getItem());
}
@ -179,7 +180,7 @@ public class AncientAltarTask implements Runnable {
listener.getAltarsInUse().remove(altar.getLocation());
listener.getAltars().remove(altar);
} else {
dropLocation.getWorld().playSound(dropLocation, Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 1F);
SoundEffect.ANCIENT_ALTAR_ITEM_DROP_SOUND.playAt(dropLocation, SoundCategory.BLOCKS);
}
}
}

View File

@ -46,12 +46,10 @@ public class InfusedMagnetTask extends AbstractPlayerTask {
protected void executeTask() {
boolean playSound = false;
for (Entity n : p.getNearbyEntities(radius, radius, radius)) {
if (n instanceof Item item) {
if (!SlimefunUtils.hasNoPickupFlag(item) && item.getPickupDelay() <= 0 && p.getLocation().distanceSquared(item.getLocation()) > 0.3) {
item.teleport(p.getLocation());
playSound = true;
}
for (Entity entity : p.getNearbyEntities(radius, radius, radius)) {
if (entity instanceof Item item && !SlimefunUtils.hasNoPickupFlag(item) && item.getPickupDelay() <= 0 && p.getLocation().distanceSquared(item.getLocation()) > 0.3) {
item.teleport(p.getLocation());
playSound = true;
}
}
@ -65,5 +63,4 @@ public class InfusedMagnetTask extends AbstractPlayerTask {
protected boolean isValid() {
return super.isValid() && p.getGameMode() != GameMode.SPECTATOR;
}
}

View File

@ -30,7 +30,6 @@ public class JetpackTask extends AbstractPlayerTask {
if (jetpack.removeItemCharge(p.getInventory().getChestplate(), COST)) {
SoundEffect.JETPACK_THRUST_SOUND.playAt(p.getLocation(), SoundCategory.PLAYERS);
p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
p.setFallDistance(0F);
Vector vector = new Vector(0, 1, 0);

View File

@ -19,7 +19,6 @@ import be.seeseemelk.mockbukkit.ServerMock;
class TestResearchCommand {
private static ServerMock server;
private static Research research;
private static Research research2;

View File

@ -1,7 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.food;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.junit.jupiter.api.AfterAll;
@ -12,6 +11,7 @@ import org.junit.jupiter.api.Test;
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.test.TestUtilities;
import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest;
@ -52,7 +52,7 @@ class TestDietCookie implements SlimefunItemTest<DietCookie> {
simulateConsumption(player, cookie);
player.assertSoundHeard(Sound.ENTITY_GENERIC_EAT);
player.assertSoundHeard(SoundEffect.DIET_COOKIE_CONSUME_SOUND.getDefaultSoundId());
Assertions.assertTrue(player.hasPotionEffect(PotionEffectType.LEVITATION));
}

View File

@ -21,7 +21,6 @@ import be.seeseemelk.mockbukkit.ServerMock;
class TestFireworksListener {
private static ServerMock server;
@BeforeAll
public static void load() {
server = MockBukkit.mock();