我在jython中遇到了这个随机的java问题。我在用python编写bukkit插件。代码如下:
class hween(PythonPlugin):
def CandyChance(self):
chance = self.cfg.getDouble("main.candydropchance", 50) / 100 #in config, it's 10, so I must do this to get it like 0.1...
return chance
@hook.event("block.BlockBreakEvent", "HIGHEST")
def onBlockBreakEvent(event):
chance = pyplugin.CandyChance()
print chance #When I print chance out, it's 0.1 (10 is in config) which is good I believe
if(Random.nextDouble("%s"%chance)):
#do something
下面是一个交互式Jython会话,它会重现您的错误:
^{} 方法不是静态的,它不接受任何参数。您将不得不重新考虑如何使用“这个随机的java东西”(不清楚您在尝试做什么)。在
相关问题 更多 >
编程相关推荐