mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 05:19:43 +05:00
30 lines
1.1 KiB
Java
30 lines
1.1 KiB
Java
package me.Navoei.customdiscsplugin;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.block.Jukebox;
|
|
|
|
import java.util.HashSet;
|
|
|
|
public class JukeboxStateManager {
|
|
|
|
static CustomDiscs plugin = CustomDiscs.getInstance();
|
|
static PlayerManager playerManager = PlayerManager.instance();
|
|
static HashSet<Location> jukeboxLocations = new HashSet<>();
|
|
|
|
public static void start(Jukebox jukebox) {
|
|
if (jukeboxLocations.contains(jukebox.getLocation()) || !playerManager.isAudioPlayerPlaying(jukebox.getLocation())) return;
|
|
jukeboxLocations.add(jukebox.getLocation());
|
|
plugin.getServer().getRegionScheduler().runAtFixedRate(plugin, jukebox.getLocation(), scheduledTask -> {
|
|
if (playerManager.isAudioPlayerPlaying(jukebox.getLocation())) {
|
|
if (!jukebox.isPlaying()) {
|
|
jukebox.startPlaying();
|
|
}
|
|
} else {
|
|
jukebox.stopPlaying();
|
|
jukeboxLocations.remove(jukebox.getLocation());
|
|
scheduledTask.cancel();
|
|
}
|
|
}, 1, 1);
|
|
}
|
|
|
|
} |