我正在使用 PyPluginLoader 在 jython 中为 Minecraft 服务器编写 bukkit 插件。我有事件和其他一切有效的东西,但我想制作切换命令,这将打开方块生成模式,但如果你再次输入它,它会关闭它。这是代码,错误如下:
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")
错误:
Caused by: Traceback (most recent call last):
File "<iostream>", line 23, in onbrix
TypeError: containsKey(): expected 2 args; got 1