9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-31 12:56:39 +00:00

Add sound action #43

This commit is contained in:
LoJoSho
2023-01-20 16:23:43 -06:00
parent 0905071dd2
commit d9b92d5336
2 changed files with 36 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ public class Actions {
private static ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
private static ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
private static ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
private static ActionSound ACTION_SOUND = new ActionSound();
public static Action getAction(String id) {

View File

@@ -0,0 +1,35 @@
package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.entity.Player;
import java.util.logging.Level;
public class ActionSound extends Action {
// [SOUND] minecraft:test 1 1
public ActionSound() {
super("sound");
}
@Override
public void run(CosmeticUser user, String raw) {
Player player = user.getPlayer();
String[] processedString = raw.split(" ");
String soundName = processedString[0];
float volume = 1;
float pitch = 1;
if (processedString.length > 2) {
volume = Float.valueOf(processedString[1]);
pitch = Float.valueOf(processedString[2]);
}
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.WARNING);
player.playSound(player.getLocation(), soundName, volume, pitch);
}
}