Java 断开自定义块
我试图在键入命令“/customblock”时中断收到的自定义块 忽略其他变量,如世界和玩家档案Java 断开自定义块,java,eclipse,plugins,minecraft,bukkit,Java,Eclipse,Plugins,Minecraft,Bukkit,我试图在键入命令“/customblock”时中断收到的自定义块 忽略其他变量,如世界和玩家档案 所以。。。我收到了正确的阻止,但当我打破它。。。只是不要做任何事什么是CustomBlock?它是一个变量还是一个类? 2件事: 块只是一个位置,不能序列化它,也不能检查它是否等于另一个块 block.equals()。它将简单地检查一个对象是否等于另一个对象 检查块的最佳方法是“自定义块”,只需记录每个自定义块的位置,并检查块是否位于其中一个位置。例如: public List<Locati
所以。。。我收到了正确的阻止,但当我打破它。。。只是不要做任何事什么是
CustomBlock
?它是一个变量还是一个类?
2件事:
块
只是一个位置,不能序列化它,也不能检查它是否等于另一个块block.equals()。它将简单地检查一个对象是否等于另一个对象
public List<Location> customBlocks = new ArrayList<Location>();
//... in the block place event add the block's location to the list
@EventHandler
public void onBlockBreak(BlockBreakEvent broke){
Player player = broke.getPlayer();
PlayerInventory inventory = broke.getPlayer().getInventory();
World world = player.getWorld();
Material block = broke.getBlock().getType();
if(customBlocks.contains(block.getLocation())){
//custom block
block.setType(Material.AIR); //destroy the block
}
}
public List customBlocks=new ArrayList();
//... 在“块放置”事件中,将块的位置添加到列表中
@事件处理程序
BlockBreak上的公共无效(BlockBreakEvent Break){
Player=broke.getPlayer();
PlayerInventory inventory=break.getPlayer().getInventory();
World=player.getWorld();
物料块=断开。getBlock().getType();
if(customBlocks.contains(block.getLocation())){
//自定义块
block.setType(Material.AIR);//销毁块
}
}
什么是CustomBlock
?它是一个变量还是一个类?
2件事:
块
只是一个位置,不能序列化它,也不能检查它是否等于另一个块block.equals()。它将简单地检查一个对象是否等于另一个对象
public List<Location> customBlocks = new ArrayList<Location>();
//... in the block place event add the block's location to the list
@EventHandler
public void onBlockBreak(BlockBreakEvent broke){
Player player = broke.getPlayer();
PlayerInventory inventory = broke.getPlayer().getInventory();
World world = player.getWorld();
Material block = broke.getBlock().getType();
if(customBlocks.contains(block.getLocation())){
//custom block
block.setType(Material.AIR); //destroy the block
}
}
public List customBlocks=new ArrayList();
//... 在“块放置”事件中,将块的位置添加到列表中
@事件处理程序
BlockBreak上的公共无效(BlockBreakEvent Break){
Player=broke.getPlayer();
PlayerInventory inventory=break.getPlayer().getInventory();
World=player.getWorld();
物料块=断开。getBlock().getType();
if(customBlocks.contains(block.getLocation())){
//自定义块
block.setType(Material.AIR);//销毁块
}
}
“CustomBlock”不是一个可以比较相等性的对象。“CustomBlock”不是一个可以比较相等性的对象。