Read Only
- Статус
- Оффлайн
- Регистрация
- 26 Авг 2024
- Сообщения
- 638
- Реакции
- 1
SS - просто при включении модуля врубается музыка
Код:
@RegisterModules(
name = "Music",
type = Category.Player
)
public class Music extends Function {
private boolean isActionEnabled;
private Clip clip;
private final String musicFolderPath = "C:\\acid client\\acidclient\\music"; // укаж свой путь к папке с музыкой пжж сука
private final Random random = new Random();
@Override
public boolean onEnable() {
playRandomSong();
this.performActionIfRequired(false);
super.onEnable();
return true;
}
private void performActionIfRequired(boolean DO) {
if (DO) {
mc.gameSettings.keyBindSneak.pressed = mc.player.ticksExisted % 2 == 0;
if (!this.isActionEnabled) {
this.isActionEnabled = true;
}
} else if (this.isActionEnabled) {
mc.gameSettings.keyBindSneak.pressed = false;
this.isActionEnabled = false;
}
}
private void playRandomSong() {
File musicFolder = new File(musicFolderPath);
File[] musicFiles = musicFolder.listFiles((dir, name) -> name.endsWith(".wav"));
if (musicFiles != null && musicFiles.length > 0) {
int randomIndex = random.nextInt(musicFiles.length);
File selectedFile = musicFiles[randomIndex];
try (AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(selectedFile)) {
clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
clip.loop(Clip.LOOP_CONTINUOUSLY);
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("Нет доступных музыкальных файлов в папке: " + musicFolderPath);
}
}
@Override
public void onDisable() {
if (clip != null && clip.isRunning()) {
clip.stop();
clip.close();
}
super.onDisable();
}
}