我使用PyPluginLoader爲jython中的Minecraft服務器編寫bukkit插件。我有事件和其他一切正常的工作,但是我想做一個切換命令,它會切換blockspawn模式,但是如果再次輸入它,它會關閉它。下面的代碼,如下錯誤:Jython HashMap參數
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
請不要添加異地鏈接,而是在此發佈錯誤消息和代碼的相關部分。 – hexafraction
回溯也是文本;從控制檯複製它(使用窗口菜單標記,然後複製文本)並將其粘貼到此處。 –