我是bukkit jython/python插件程序员。最近几天,我一直在努力解决这个问题。我必须给用户添加药剂效果,如果我在代码中手动输入效果名称、持续时间和放大器,这不是问题,但是当我想从配置中获取它们时,我得到以下错误:
13:38:20 [SEVERE] Could not pass event PlayerInteractEvent to ItemEffect v1.0
Traceback (most recent call last):
File "<iostream>", line 126, in onPlayerInteractEvent
TypeError: addPotionEffect(): 1st arg can't be coerced to org.bukkit.potion.Poti
onEffect
下面是代码的一部分:
^{pr2}$当我打印getpotioneffect时,我得到:
13:38:20 [INFO] PotionEffect(PotionEffectType.SPEED, 600, 1)
没关系,应该行得通。我测试了它,没有从配置信息,它工作完美。。。综上所述,上述代码无效,但下面的代码有效:
getpotioneffect = PotionEffect(PotionEffectType.SPEED, 600, 1)
if iteminhand == currentKey:
event.getPlayer().addPotionEffect(getpotioneffect)
链接到这个事件的javadocs!在
谢谢!在
在第一个代码段中,^{{cd1>}是一个字符串。您可以在某处检查它添加^{{cd2>}。
您想要的是替换:
使用此选项:
^{pr2}$相关问题 更多 >
编程相关推荐