Spotify integration

This commit is contained in:
refactoring 2024-01-01 18:46:49 -05:00
parent b6faa000aa
commit c6f9344b07
5 changed files with 50 additions and 2 deletions

View File

@ -13,6 +13,7 @@ repositories {
name = "cursed-mappings"
url = "https://raw.githubusercontent.com/BleachDev/cursed-mappings/main/"
}
maven { url 'https://jitpack.io' }
}
loom {
@ -26,6 +27,7 @@ dependencies {
modImplementation "net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${project.fabric_version}"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.github.LabyStudio:java-spotify-api:+:all'
}
processResources {

View File

@ -186,6 +186,7 @@ public class ModInstances {
// }
mods.add(new QuickPlayMod());
mods.add(new SoundsMod());
mods.add(new SpotifyMod());
// mods.add(new ItemSizeMod());
}

View File

@ -16,6 +16,7 @@ import net.silentclient.client.mods.ModCategory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class PackDisplayMod extends HudMod {
@ -52,9 +53,9 @@ public class PackDisplayMod extends HudMod {
List<ResourcePackRepository.Entry> rps = Lists.reverse(this.mc.getResourcePackRepository().getRepositoryEntries());
int count = rps.size();
String name = "";
String name;
if(count != 0) {
ResourcePackRepository.Entry entry = rps.get(order == "First Pack" ? 0 : count - 1);
ResourcePackRepository.Entry entry = rps.get(Objects.equals(order, "First Pack") ? 0 : count - 1);
name = entry.getResourcePackName().replace(".zip", "").trim();
} else {
name = mc.getResourcePackRepository().rprDefaultResourcePack.getPackName();

View File

@ -0,0 +1,44 @@
package net.silentclient.client.mods.hud;
import de.labystudio.spotifyapi.SpotifyAPI;
import de.labystudio.spotifyapi.SpotifyAPIFactory;
import net.silentclient.client.Client;
import net.silentclient.client.gui.hud.ScreenPosition;
import net.silentclient.client.mods.HudMod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.ModDraggable;
/**
* @author refactoring
*/
public class SpotifyMod extends HudMod {
private SpotifyAPI api = SpotifyAPIFactory.createInitialized();
public SpotifyMod() {
super("Spotify HUD", ModCategory.MODS, "silentclient/icons/mods/spotify.png");
}
@Override
public String getText() {
if(!api.isConnected()) return " Not connected ";
if(!api.isPlaying()) return " Nothing playing ";
if(api.hasTrack()) {
return " " + api.getTrack().getArtist() + "" + api.getTrack().getName() + " ";
}
return " No track ";
}
@Override
public String getTextForRender() {
if(!api.isConnected()) return "Not connected";
if(!api.isPlaying()) return "Nothing playing";
if(api.hasTrack()) {
return api.getTrack().getArtist() + "" + api.getTrack().getName();
}
return "No track";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB