62 lines
3.3 KiB
Java
62 lines
3.3 KiB
Java
package net.t2code.commandguiv2.Spigot.sound;
|
|
|
|
import net.t2code.commandguiv2.Spigot.config.config.Config;
|
|
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) {
|
|
play(player, soundEnum, null, null, null);
|
|
}
|
|
|
|
public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) {
|
|
if (!(Boolean) Config.soundEnable.value) return;
|
|
switch (soundEnum) {
|
|
case OpenInventory:
|
|
if (!(Boolean) Config.soundOpenInventoryEnable.value) return;
|
|
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundOpenInventoryInput.value)), 3, 1);
|
|
break;
|
|
case Click:
|
|
if (!(Boolean) Config.soundClickEnable.value) return;
|
|
if (!function.customSound_Enable) {
|
|
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundClickInput.value)), 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(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundClickInput.value)), 3, 1);
|
|
}
|
|
break;
|
|
case NoMoney:
|
|
if (!(Boolean) Config.soundNoMoneyEnable.value) return;
|
|
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundNoMoneyInput.value)), 3, 1);
|
|
break;
|
|
case NoInventorySpace:
|
|
if (!(Boolean) Config.soundNoInventorySpaceEnable.value) return;
|
|
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundNoInventorySpaceInput.value)), 3, 1);
|
|
break;
|
|
case Give:
|
|
if (!(Boolean) Config.soundGiveEnable.value) return;
|
|
player.playSound(player.getLocation(),org.bukkit.Sound.valueOf(String.valueOf( Config.soundGiveInput.value)), 3, 1);
|
|
break;
|
|
case PlayerNotFound:
|
|
if (!(Boolean) Config.soundPlayerNotFoundEnable.value) return;
|
|
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundPlayerNotFoundInput.value)), 3, 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|