/:“unicode”和“int”的操作数类型不受支持

2024-06-25 06:01:17 发布

您现在位置:Python中文网/ 问答频道 /正文

首先,很抱歉在短时间内问了两个问题,但我解决了最后一个,所以我需要帮助。我正在用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

谢谢!


Tags: 代码self插件eventisdef错误jython