Spotify integration
This commit is contained in:
parent
b6faa000aa
commit
c6f9344b07
|
@ -13,6 +13,7 @@ repositories {
|
||||||
name = "cursed-mappings"
|
name = "cursed-mappings"
|
||||||
url = "https://raw.githubusercontent.com/BleachDev/cursed-mappings/main/"
|
url = "https://raw.githubusercontent.com/BleachDev/cursed-mappings/main/"
|
||||||
}
|
}
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
@ -26,6 +27,7 @@ dependencies {
|
||||||
modImplementation "net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${project.fabric_version}"
|
modImplementation "net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
implementation 'com.github.LabyStudio:java-spotify-api:+:all'
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|
|
@ -186,6 +186,7 @@ public class ModInstances {
|
||||||
// }
|
// }
|
||||||
mods.add(new QuickPlayMod());
|
mods.add(new QuickPlayMod());
|
||||||
mods.add(new SoundsMod());
|
mods.add(new SoundsMod());
|
||||||
|
mods.add(new SpotifyMod());
|
||||||
// mods.add(new ItemSizeMod());
|
// mods.add(new ItemSizeMod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.silentclient.client.mods.ModCategory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class PackDisplayMod extends HudMod {
|
public class PackDisplayMod extends HudMod {
|
||||||
|
|
||||||
|
@ -52,9 +53,9 @@ public class PackDisplayMod extends HudMod {
|
||||||
|
|
||||||
List<ResourcePackRepository.Entry> rps = Lists.reverse(this.mc.getResourcePackRepository().getRepositoryEntries());
|
List<ResourcePackRepository.Entry> rps = Lists.reverse(this.mc.getResourcePackRepository().getRepositoryEntries());
|
||||||
int count = rps.size();
|
int count = rps.size();
|
||||||
String name = "";
|
String name;
|
||||||
if(count != 0) {
|
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();
|
name = entry.getResourcePackName().replace(".zip", "").trim();
|
||||||
} else {
|
} else {
|
||||||
name = mc.getResourcePackRepository().rprDefaultResourcePack.getPackName();
|
name = mc.getResourcePackRepository().rprDefaultResourcePack.getPackName();
|
||||||
|
|
|
@ -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 |
Loading…
Reference in New Issue