我正在使用PyPluginLoader为jython中的Minecraft服务器编写bukkit插件。我有事件和所有其他工作,但我想制作切换命令,它将打开blockspawn模式,但如果你再次输入它,它会关闭它。这是代码,错误如下:
from java.io import File
import org.bukkit as bukkit
server = bukkit.Bukkit.getServer()
log = server.getLogger()
Material = bukkit.Material
from org.bukkit.event import player
from org.bukkit.entity import EntityType
import org.bukkit.permissions
from org.bukkit.plugin.java import JavaPlugin
from org.bukkit import Server
from org.bukkit import plugin
from java.util import Date, HashSet, HashMap
z = HashMap
@hook.command("blockspawn", usage="/<command>",
desc="Toggles blockspawning mode on/off")
def onbrix(sender, command, label):
if z.containsKey(player):
z.remove(player.getName())
sender.sendMessage("Blockspawning OFF")
else:
z.put(player.getName())
sender.sendMessage("Blockspawning ON")
ERROR:
Caused by: Traceback (most recent call last):
File "<iostream>", line 23, in onbrix
TypeError: containsKey(): expected 2 args; got 1
答案 0 :(得分:0)
我认为您的代码应为:
z = HashMap()
请注意括号。否则,您不会创建HashMap的实例。