1.14.2
This commit is contained in:
parent
70fccf26fb
commit
dd0b1c173f
2 changed files with 17 additions and 8 deletions
|
|
@ -533,7 +533,7 @@ public class ItemUtils {
|
||||||
Multimap<Attribute,AttributeModifier> attributes = meta.getAttributeModifiers();
|
Multimap<Attribute,AttributeModifier> attributes = meta.getAttributeModifiers();
|
||||||
Set<Attribute> set = attributes.keySet();
|
Set<Attribute> set = attributes.keySet();
|
||||||
|
|
||||||
List<String> attributeList = new ArrayList<String>();
|
List<String> attributeList = new ArrayList<>();
|
||||||
for(Attribute a : set) {
|
for(Attribute a : set) {
|
||||||
Collection<AttributeModifier> listModifiers = attributes.get(a);
|
Collection<AttributeModifier> listModifiers = attributes.get(a);
|
||||||
for(AttributeModifier m : listModifiers) {
|
for(AttributeModifier m : listModifiers) {
|
||||||
|
|
@ -542,7 +542,7 @@ public class ItemUtils {
|
||||||
line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+m.getKey().getNamespace()+":"+m.getKey().getKey();
|
line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+m.getKey().getNamespace()+":"+m.getKey().getKey();
|
||||||
line=line+";"+m.getSlotGroup().toString();
|
line=line+";"+m.getSlotGroup().toString();
|
||||||
}else{
|
}else{
|
||||||
line = a.name()+";"+m.getOperation().name()+";"+m.getAmount()+";"+m.getUniqueId();
|
line = getAttributeName(a)+";"+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();
|
||||||
}
|
}
|
||||||
|
|
@ -605,7 +605,7 @@ public class ItemUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.addAttributeModifier(Attribute.valueOf(attribute), modifier);
|
meta.addAttributeModifier(getAttributeByName(attribute), modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
@ -764,10 +764,19 @@ public class ItemUtils {
|
||||||
|
|
||||||
private static Attribute getAttributeByName(String name){
|
private static Attribute getAttributeByName(String name){
|
||||||
try {
|
try {
|
||||||
Class<?> attributeTypeClass = Class.forName("org.bukkit.attribute");
|
Class<?> attributeTypeClass = Class.forName("org.bukkit.attribute.Attribute");
|
||||||
Method valueOf = attributeTypeClass.getMethod("valueOf", String.class);
|
Field field = attributeTypeClass.getField(name);
|
||||||
return (Attribute) valueOf.invoke(null,name);
|
return (Attribute) field.get(null);
|
||||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassNotFoundException e) {
|
} catch (IllegalAccessException | ClassNotFoundException | NoSuchFieldException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getAttributeName(Object attribute){
|
||||||
|
try {
|
||||||
|
Class<?> attributeTypeClass = Class.forName("org.bukkit.attribute.Attribute");
|
||||||
|
return (String)attributeTypeClass.getMethod("name").invoke(attribute);
|
||||||
|
} catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
main: pk.ajneb97.PlayerKits2
|
main: pk.ajneb97.PlayerKits2
|
||||||
version: 1.14.1
|
version: 1.14.2
|
||||||
name: PlayerKits2
|
name: PlayerKits2
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend: [Vault,PlaceholderAPI]
|
softdepend: [Vault,PlaceholderAPI]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue