下面列出了怎么用org.bukkit.block.Jukebox的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler(priority = EventPriority.MONITOR)
public void blockChanged(PlayerInteractEvent e) {
if(e.isCancelled())return;
if(e.getClickedBlock() == null) return;
Block b = e.getClickedBlock();
String[] type = b.getType().toString().split("_");
if(type.length >= 2) {
if(type[type.length-1].equalsIgnoreCase("button") || (type.length >= 3 && (type[type.length-1]+"_"+type[type.length-2]).equalsIgnoreCase("pressure_plate"))) return;
if(type[type.length-1].equalsIgnoreCase("door")) {
Block down = b.getRelative(0, -1, 0);
String[] downType = down.getType().toString().split("_");
if(downType[downType.length-1].equalsIgnoreCase("door")) {
logBlockChanged(down);
i.put("BCHANGE", i.get("BCHANGE")+1);
}
}
}
if(b.getState() instanceof Jukebox) {
if(GameManager.getInstance().getBlockGameId(b.getLocation()) == -1) return;
if(GameManager.getInstance().getGameMode(GameManager.getInstance().getBlockGameId(b.getLocation())) == Game.GameMode.DISABLED) return;
e.setCancelled(true);
return;
}
logBlockChanged(e.getClickedBlock());
i.put("BCHANGE", i.get("BCHANGE")+1);
}