From c60b6fa041a90afbacdc7dcb79a96de0c79b926e Mon Sep 17 00:00:00 2001 From: Ajneb97 Date: Thu, 30 Nov 2023 17:09:26 -0300 Subject: [PATCH] 1.7.4 --- src/main/java/pk/ajneb97/utils/ItemUtils.java | 28 ++++++++++++++----- src/main/resources/plugin.yml | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/pk/ajneb97/utils/ItemUtils.java b/src/main/java/pk/ajneb97/utils/ItemUtils.java index f1f4081..551efe1 100644 --- a/src/main/java/pk/ajneb97/utils/ItemUtils.java +++ b/src/main/java/pk/ajneb97/utils/ItemUtils.java @@ -163,7 +163,10 @@ public class ItemUtils { URL url; try { String decoded = new String(Base64.getDecoder().decode(texture)); - url = new URL(decoded.substring("{\"textures\":{\"SKIN\":{\"url\":\"".length(), decoded.length() - "\"}}}".length())); + String decodedFormatted = decoded.replaceAll("\\s", ""); + int firstIndex = decodedFormatted.indexOf("\"SKIN\":{\"url\":")+15; + int lastIndex = decodedFormatted.indexOf("}",firstIndex+1); + url = new URL(decodedFormatted.substring(firstIndex,lastIndex-1)); } catch (MalformedURLException error) { error.printStackTrace(); return; @@ -487,12 +490,13 @@ public class ItemUtils { List attributeList = new ArrayList(); for(Attribute a : set) { - Collection listaModifiers = attributes.get(a); - for(AttributeModifier m : listaModifiers) { - String line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+UUID.randomUUID().toString(); + Collection listModifiers = attributes.get(a); + for(AttributeModifier m : listModifiers) { + String line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+m.getUniqueId(); if(m.getSlot() != null) { line=line+";"+m.getSlot().name(); } + line=line+";custom_name:"+m.getName(); attributeList.add(line); } } @@ -519,12 +523,22 @@ public class ItemUtils { AttributeModifier.Operation op = AttributeModifier.Operation.valueOf(sep[1]); double amount = Double.valueOf(sep[2]); UUID uuid = UUID.fromString(sep[3]); + String customName = attribute; + for(int i=0;i= 5) { - EquipmentSlot slot = EquipmentSlot.valueOf(sep[4]); - modifier = new AttributeModifier(uuid,attribute,amount,op,slot); + if(!sep[4].startsWith("custom_name:")){ + EquipmentSlot slot = EquipmentSlot.valueOf(sep[4]); + modifier = new AttributeModifier(uuid,customName,amount,op,slot); + }else{ + modifier = new AttributeModifier(uuid,customName,amount,op); + } }else { - modifier = new AttributeModifier(uuid,attribute,amount,op); + modifier = new AttributeModifier(uuid,customName,amount,op); } meta.addAttributeModifier(Attribute.valueOf(attribute), modifier); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3fc4f04..727d4c0 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ main: pk.ajneb97.PlayerKits2 -version: 1.7.3 +version: 1.7.4 name: PlayerKits2 api-version: 1.13 softdepend: [Vault,PlaceholderAPI]