blob: 8dadedaf18449dbe2b9ed9e7cb579d6555fb0324 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package de.hysky.skyblocker.skyblock.profileviewer.utils;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import de.hysky.skyblocker.skyblock.profileviewer.ProfileViewerScreen;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ProfileComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Optional;
import java.util.UUID;
public class ProfileViewerUtils {
public static final NumberFormat COMMA_FORMATTER = NumberFormat.getNumberInstance(Locale.US);
public static ItemStack createSkull(String textureB64) {
ItemStack skull = new ItemStack(Items.PLAYER_HEAD);
try {
PropertyMap map = new PropertyMap();
map.put("textures", new Property("textures", textureB64));
ProfileComponent profile = new ProfileComponent(Optional.of("skull"), Optional.of(UUID.randomUUID()), map);
skull.set(DataComponentTypes.PROFILE, profile);
} catch (Exception e) {
ProfileViewerScreen.LOGGER.error("[Skyblocker Profile Viewer] Failed to create skull", e);
}
return skull;
}
public static String numLetterFormat(double amount) {
if (amount >= 1_000_000_000) {
return String.format("%.4gB", amount / 1_000_000_000);
} else if (amount >= 1_000_000) {
return String.format("%.4gM", amount / 1_000_000);
} else if (amount >= 1_000) {
return String.format("%.4gK", amount / 1_000);
} else {
return String.valueOf((int)(amount));
}
}
}
|