Skip to content

Commit

Permalink
v1.1.9 Update
Browse files Browse the repository at this point in the history
- Fixed inventory creation order
- Added the ability to use the base64 value in addition to the minecraft-url value
  • Loading branch information
FranFrau committed May 7, 2021
1 parent fb332d5 commit 00e9167
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ public Inventory build() {
fillInventory(inventory);
}

setItems(inventory);

if (fillBorder != null)
fillBorder(inventory);

if (!fillChessBorder.isEmpty())
fillChessBorder(inventory);

setItems(inventory);

reset();
return inventory;
}
Expand Down
23 changes: 19 additions & 4 deletions Java/src/main/java/it/mycraft/powerlib/item/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,10 @@ public ItemBuilder clone(ItemStack itemStack) {
* Sets a custom skin to a skull
*
* @param itemBuilder The itemBuilder
* @param base64 The base64
* @param url The minecraft.net url
* @return The skull with a non-player skin
*/
private ItemStack setCustomSkin(ItemBuilder itemBuilder, String base64) {
String url = "http://textures.minecraft.net/texture/" + base64;
private ItemStack setCustomSkin(ItemBuilder itemBuilder, String url) {
int version = ReflectionAPI.getNumericalVersion();
String material = version >= 13 ? "PLAYER_HEAD" : "SKULL_ITEM";
ItemStack skull = itemBuilder.setMaterial(material).setMetaData((byte) 3).setAmount(1).setName(name).setLore(lore).build();
Expand Down Expand Up @@ -411,7 +410,23 @@ public ItemStack build() {
* @return The ItemStack
*/
public ItemStack customHeadBuild(String skinURL) {
return setCustomSkin(this, skinURL);
if(!skinURL.endsWith("="))
return setCustomSkin(this, "http://textures.minecraft.net/texture/" + skinURL);

return setCustomSkin(this, base64Decoder(skinURL));
}

/**
* This method is used for extracting the minecraft.net link from the base64 text
*
* @param base64 The base64 text
* @return The minecraft.net link
* */
private String base64Decoder(String base64){
byte[] decoded = Base64.getDecoder().decode(base64);
String s = new String(decoded);

return s.replace("\"}}}", "").split(":\"")[1];
}

/**
Expand Down

0 comments on commit 00e9167

Please sign in to comment.