Files
common/src/main/java/org/saturnclient/cosmetics/Cloaks.java
T

72 lines
2.0 KiB
Java

package org.saturnclient.cosmetics;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import org.saturnclient.client.ServiceClient;
import org.saturnclient.client.player.SaturnPlayer;
import org.saturnclient.common.ref.asset.IdentifierRef;
public class Cloaks {
public static final String[] ALL_CLOAKS = {
"glitch",
"crimson_mark",
"redbull_plus",
"black_hole_amethyst",
"black_hole_flame",
"black_hole_white",
"albania_mark",
"end",
"spanish_empire",
"spain_flag",
};
private static final String[] ANIMATED_CLOAKS = {
"glitch",
"black_hole_amethyst",
"black_hole_flame",
"black_hole_white",
};
// Written by network callbacks, read by the UI thread.
public static final List<String> availableCloaks =
new CopyOnWriteArrayList<>();
public static void initialize() {
availableCloaks.add(0, "");
}
/**
* The cloak's texture, or null for no cloak ("", the "None" choice) and for a cloak this version
* has no texture for, which would otherwise draw as the missing texture.
*/
public static IdentifierRef getCurrentCloakTexture(String cloakName) {
if (
cloakName == null || !Arrays.asList(ALL_CLOAKS).contains(cloakName)
) {
return null;
}
if (Arrays.asList(ANIMATED_CLOAKS).contains(cloakName)) {
return IdentifierRef.ofSaturn(
"textures/cloaks/" + cloakName + ".gif"
);
} else {
return IdentifierRef.ofSaturn(
"textures/cloaks/" + cloakName + ".png"
);
}
}
public static void setCloak(String cloakName) {
if (availableCloaks.contains(cloakName)) {
SaturnPlayer player = SaturnPlayer.get();
if (player != null) {
player.cloak = cloakName;
}
ServiceClient.setCloak(cloakName);
}
}
}