我在 jython 中遇到了这个 Random 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