首先,很抱歉在短时间内提出两个问题,但我解决了最后一个问题,所以我再次需要帮助。我正在用 jython/python 编写 bukkit 插件...我对 python/jython 很陌生,我不明白我在哪里犯错,看看代码:
(everything is under class hween(PythonPlugin))
def CandyChance(self):
chance = self.cfg.getString("main.candydropchance") #this works, I tried to print it and result is 10 (which I entered in config before)
chancetotal = chance / 100
@hook.event("block.BlockBreakEvent", "HIGHEST")
def onBlockBreakEvent(event):
#something
chancetotal = pyplugin.CandyChance()
if("Random.nextDouble() <= %s"%chancetotal):
#do something
谢谢!