This commit is contained in:
Ajneb97 2023-11-30 17:09:26 -03:00
parent fe88b6ae8f
commit c60b6fa041
2 changed files with 22 additions and 8 deletions

View file

@ -163,7 +163,10 @@ public class ItemUtils {
URL url; URL url;
try { try {
String decoded = new String(Base64.getDecoder().decode(texture)); 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) { } catch (MalformedURLException error) {
error.printStackTrace(); error.printStackTrace();
return; return;
@ -487,12 +490,13 @@ public class ItemUtils {
List<String> attributeList = new ArrayList<String>(); List<String> attributeList = new ArrayList<String>();
for(Attribute a : set) { for(Attribute a : set) {
Collection<AttributeModifier> listaModifiers = attributes.get(a); Collection<AttributeModifier> listModifiers = attributes.get(a);
for(AttributeModifier m : listaModifiers) { for(AttributeModifier m : listModifiers) {
String line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+UUID.randomUUID().toString(); String line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+m.getUniqueId();
if(m.getSlot() != null) { if(m.getSlot() != null) {
line=line+";"+m.getSlot().name(); line=line+";"+m.getSlot().name();
} }
line=line+";custom_name:"+m.getName();
attributeList.add(line); attributeList.add(line);
} }
} }
@ -519,12 +523,22 @@ public class ItemUtils {
AttributeModifier.Operation op = AttributeModifier.Operation.valueOf(sep[1]); AttributeModifier.Operation op = AttributeModifier.Operation.valueOf(sep[1]);
double amount = Double.valueOf(sep[2]); double amount = Double.valueOf(sep[2]);
UUID uuid = UUID.fromString(sep[3]); UUID uuid = UUID.fromString(sep[3]);
String customName = attribute;
for(int i=0;i<sep.length;i++){
if(sep[i].startsWith("custom_name:")){
customName = sep[i].replace("custom_name:","");
}
}
AttributeModifier modifier = null; AttributeModifier modifier = null;
if(sep.length >= 5) { if(sep.length >= 5) {
if(!sep[4].startsWith("custom_name:")){
EquipmentSlot slot = EquipmentSlot.valueOf(sep[4]); EquipmentSlot slot = EquipmentSlot.valueOf(sep[4]);
modifier = new AttributeModifier(uuid,attribute,amount,op,slot); modifier = new AttributeModifier(uuid,customName,amount,op,slot);
}else{
modifier = new AttributeModifier(uuid,customName,amount,op);
}
}else { }else {
modifier = new AttributeModifier(uuid,attribute,amount,op); modifier = new AttributeModifier(uuid,customName,amount,op);
} }
meta.addAttributeModifier(Attribute.valueOf(attribute), modifier); meta.addAttributeModifier(Attribute.valueOf(attribute), modifier);

View file

@ -1,5 +1,5 @@
main: pk.ajneb97.PlayerKits2 main: pk.ajneb97.PlayerKits2
version: 1.7.3 version: 1.7.4
name: PlayerKits2 name: PlayerKits2
api-version: 1.13 api-version: 1.13
softdepend: [Vault,PlaceholderAPI] softdepend: [Vault,PlaceholderAPI]