T2C-CommandGUI/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/sound/Sound.java

63 lines
3.1 KiB
Java

package net.t2code.commandguiv2.Spigot.sound;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.objects.functions.Function;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot;
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.entity.Player;
public class Sound {
private static String prefix = Util.getPrefix();
public static void play(Player player, SoundEnum soundEnum) {
if (!SelectConfig.getSound_Enable()) return;
play(player, soundEnum, null, null, null);
}
public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) {
if (!SelectConfig.getSound_Enable()) return;
switch (soundEnum) {
case OpenInventory:
if (!SelectConfig.getSound_OpenInventory_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_OpenInventory(), 3, 1);
break;
case Click:
if (!SelectConfig.getSound_Click_Enable()) return;
if (!function.customSound_Enable) {
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
return;
}
if (function.customSound_NoSound) return;
try {
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + gui.key + " §6Function: §e" + function.key + "§r §6Slot: §e" + (slot.slot + 1) + " §6CustomSound: §9" + function.customSound_Sound));
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
}
break;
case NoMoney:
if (!SelectConfig.getSound_NoMoney_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoMoney(), 3, 1);
break;
case NoInventorySpace:
if (!SelectConfig.getSound_NoInventorySpace_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoInventorySpace(), 3, 1);
break;
case Give:
if (!SelectConfig.getSound_Give_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_Give(), 3, 1);
break;
case PlayerNotFound:
if (!SelectConfig.getSound_PlayerNotFound_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_PlayerNotFound(), 3, 1);
break;
}
}
}