MZIMU
我想问问各位是怎么增加比如说
物理攻击属性的数值的



我用AttributeApi获取那个属性数据put到map里面没有用。。。难道是我想错了?
  1. AttributeAPI.getAttrData(p).getAttributeValue().put(key,value);
复制代码



RE_OVO
1. 请上你的具体代码啊, 不然咋知道错在哪
2. 如果是1.9+版本Bukkit已自带了Attribute API,1.8/1.7当我没说

MZIMU
本帖最后由 MZIMU 于 2020-6-18 11:51 编辑
jebme 发表于 2020-6-17 22:40
1. 请上你的具体代码啊, 不然咋知道错在哪
2. 如果是1.9+版本Bukkit已自带了Attribute API,1.8/1.7当我没 ...

是1.12
  1. public static ZMAttributeData updataAttributeForWeapons(Player p){
  2.             ItemStack handItem = p.getInventory().getItemInMainHand();
  3.             Equipment.WeaponsType weaponsType = Equipment.WeaponsType.valueOf(handItem);
  4.             if(weaponsType!=null){
  5.                 ZMAttributeData zmAttributeData = new ZMAttributeData();
  6.                 Map<String,Double> aMap = zmAttributeData.updataWeaponsValueLv(handItem,weaponsType);
  7.                 for(Map.Entry<String, Double> entry : weaponsType.getZmWeapons().getAttr().entrySet()){
  8.                     String key = entry.getKey();
  9.                     if(aMap.containsKey(key)){
  10.                         zmAttributeData.updataAttribute(key,entry.getValue() + aMap.get(key));
  11.                     }else{
  12.                         zmAttributeData.updataAttribute(key,entry.getValue());
  13.                     }
  14.                     AttributeAPI.getAttrData(p).getAttributeValue().put(key,AttributeAPI.getAttrData(p).getAttributeValue().get(key) + zmAttributeData.getAttributeMap().get(key));
  15.                 }

  16.                 for(Map.Entry<String,Double> entry : AttributeAPI.getAttrData(p).getAttributeValue().entrySet()){
  17.                     System.out.println(entry.getKey() + "   " + entry.getValue());
  18.                 }
  19.                 ZMWeaponsLevel.attrPlayData.putZMAttributeData(p,zmAttributeData);
  20.                 return zmAttributeData;
  21.             }
  22.             return null;
  23.         }
复制代码