类org.bukkit.block.Jukebox源码实例Demo

下面列出了怎么用org.bukkit.block.Jukebox的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Survival-Games   文件: LoggingManager.java
@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);
}
 
 类所在包
 同包方法