Skip to content

Commit

Permalink
Add stop music command, add looping parameter, and prevent track from…
Browse files Browse the repository at this point in the history
… changing if both URLs are identical.
  • Loading branch information
oliverdunk committed Mar 19, 2016
1 parent 7fcd3e1 commit 2dfddad
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static void play(Player player, final Media media){
parameters.put("url", media.getURL());
parameters.put("pan", media.getPan() + "");
parameters.put("volume", media.getVolume() + "");
parameters.put("looping", media.isLooping() + "");
Bukkit.getScheduler().runTaskAsynchronously(Jukebox.getInstance(), new Runnable() {
public void run() {
if(media.getType() == ResourceType.MUSIC) Jukebox.getInstance().getRequestHandler().makeRequest("music", parameters);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/oliverdunk/jukeboxapi/api/models/Media.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class Media {
@Getter @Setter private int volume = 100;
//Pan left to right, -100 to 100
@Getter @Setter private int pan = 0;
//If the music track should loop once complete (not applicable for sounds)
@Getter @Setter private boolean looping;

public Media(ResourceType type, String URL){
setType(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private boolean help(CommandSender sender){
sender.sendMessage("/jukebox sound <username> <url>");
sender.sendMessage("/jukebox region add <id> <url>");
sender.sendMessage("/jukebox region remove <id>");
sender.sendMessage("/jukebox stop <username>");
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public void onMove(PlayerMoveEvent e){
if(playing.containsKey(e.getPlayer().getUniqueId().toString()) &&
playing.get(e.getPlayer().getUniqueId().toString()).equals(highestRegion.getId())) return;

if(playing.containsKey(e.getPlayer().getUniqueId().toString()) &&
utils.getURL(playing.get(e.getPlayer().getUniqueId().toString())).equals(
utils.getURL(highestRegion.getId()))) return;

playing.put(e.getPlayer().getUniqueId().toString(), highestRegion.getId());

Media media = new Media(ResourceType.MUSIC, utils.getURL(highestRegion.getId()));
Expand Down

0 comments on commit 2dfddad

Please sign in to comment.