我试图在我拿起物品时打开我的库存。这是在Bukkit。如何通过活动打开我自己的库存?
这是迄今为止的事件,player.openInventory
的参数为空。
@EventHandler
public void blank(PlayerDropItemEvent e){
Player player = e.getPlayer();
player.openInventory();
}
我试图在我拿起物品时打开我的库存。这是在Bukkit。如何通过活动打开我自己的库存?
这是迄今为止的事件,player.openInventory
的参数为空。
@EventHandler
public void blank(PlayerDropItemEvent e){
Player player = e.getPlayer();
player.openInventory();
}
尝试使用player.getInventory()
来检索他们的库存,然后使用player.openInventory(inventory)
将其打开。
@EventHandler
public void blank(PlayerDropItemEvent e) {
Player player = e.getPlayer();
Inventory inventory = player.getInventory();
player.openInventory(inventory);
}
要获得玩家的库存,你可以使用:
player.getInventory();
如果你想打开播放器的库存,你可以使用:
player.openInventory(player.getInventory());
所以,你的代码可能看起来像这样:
@EventHandler
public void dropItem(PlayerDropItemEvent e){
Player player = e.getPlayer(); //get the player that dropped the item
player.openInventory(player.getInventory()); //open the player's inventory
}
你是否注册了听众? – CoderMusgrove
插件工作,player.openInventory()需要一个参数 –