當前位置: 首頁>>代碼示例>>Java>>正文


Java Material.STONE_BUTTON屬性代碼示例

本文整理匯總了Java中org.bukkit.Material.STONE_BUTTON屬性的典型用法代碼示例。如果您正苦於以下問題:Java Material.STONE_BUTTON屬性的具體用法?Java Material.STONE_BUTTON怎麽用?Java Material.STONE_BUTTON使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.STONE_BUTTON屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onNextRoomButtonPress

/**Event handler for a player pressing the button of this Passageway. Will callback to DunGen to generate the next DunGen part.
 * Also moves all other players to this Passageway.
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR)
public void onNextRoomButtonPress(PlayerInteractEvent event) {
    //Player p = event.getPlayer();
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Block clicked = event.getClickedBlock();
        if (   clicked.getType() == Material.STONE_BUTTON 
        	&& modVolume.contains(BukkitUtil.toVector(clicked.getLocation())) ) {
        	
        	unregister(); // button cannot be pushed twice
        	// If double button push appears more often, then use flag here
        	// Here we need the activePlayers list. This is not present in the entry, so don't teleport during STARTUP phase.
        	// This might be solvable better somehow...
        	
        	// only teleport if the dungeon runs, not during entry startup state
        	if (parent.state == State.RUNNING) 
	        	for (Player p : parent.activePlayers) {
	        		if (!modVolume.contains(BukkitUtil.toVector(p.getLocation()))) {
	        			p.teleport(BukkitUtil.toLocation(parent.world, toGlobal(respawnLoc).add(0.5, 0, 0.5)));
	        		}
	        	}
        	
        	parent.genNextRoom();
        }
    }
}
 
開發者ID:TheRoot89,項目名稱:DungeonGen,代碼行數:29,代碼來源:Passageway.java

示例2: execute

public boolean execute(CommandSender sender, String[] args) {
  	if (args.length != 1) {
  		Chat.player(sender, "&cPlease include the name.");
  		return true;
  	}
  	
  	Course c = Course.get(args[0]);
  	if (c == null) {
  		Chat.player(sender, "&7[Parkour] Couldn't find the course, " + args[0]);
  		return true;
  	}
  	
  	Player p = (Player) sender;
  	
Block b = p.getTargetBlock(null, 10);
if (b == null || b.getType() != Material.STONE_BUTTON) {
	Chat.player(sender, "&2[SG] &cThat is not a button");
	return true;
}
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.x", b.getX());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.y", b.getY());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.z", b.getZ());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.world", b.getWorld().getName());
Chat.player(sender, "&7[Parkour] &aStart button added to " + c.getName());
  	Parkour.getInstance().saveConfig();
  	Parkour.getInstance().loadCourses();
  	
      return true;
  }
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:29,代碼來源:ParkourStartCmd.java

示例3: execute

public boolean execute(CommandSender sender, String[] args) {
  	if (args.length != 1) {
  		Chat.player(sender, "&cPlease include the name.");
  		return true;
  	}
  	
  	Course c = Course.get(args[0]);
  	if (c == null) {
  		Chat.player(sender, "&7[Parkour] Couldn't find the course, " + args[0]);
  		return true;
  	}
  	
  	Player p = (Player) sender;
  	
Block b = p.getTargetBlock(null, 10);
if (b == null || b.getType() != Material.STONE_BUTTON) {
	Chat.player(sender, "&2[SG] &cThat is not a button");
	return true;
}
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.x", b.getX());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.y", b.getY());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.z", b.getZ());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.world", b.getWorld().getName());
Chat.player(sender, "&7[Parkour] &aEnd button added to " + c.getName());
  	Parkour.getInstance().saveConfig();
  	Parkour.getInstance().loadCourses();
  	
      return true;
  }
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:29,代碼來源:ParkourEndCmd.java

示例4: onLeverOrButton

@EventHandler
public void onLeverOrButton(PlayerInteractEvent event) {
	Block clickedBlock = event.getClickedBlock();
	Player player = event.getPlayer();

	if (clickedBlock == null)
		return;

	String chunk = clickedBlock.getLocation().getChunk().getX() + ";"
			+ clickedBlock.getLocation().getChunk().getZ();
	if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
		return;
	if (!powerable.containsKey(clickedBlock.getWorld().getName()))
		return;
	if (powerable.get(clickedBlock.getWorld().getName()).getList(chunk).contains(clickedBlock.getLocation()))
		return;

	// We cancel; send smoke particles for button, and we just turn off the
	// lever (if it was, for some reason, on).
	if (clickedBlock.getType() == Material.STONE_BUTTON || clickedBlock.getType() == Material.WOOD_BUTTON) {

		clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
				0, 0.2, 0, 0.03);
		player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");

	} else if (clickedBlock.getType() == Material.LEVER) {
		BlockState state = clickedBlock.getState();
		Lever lever = (Lever) state.getData();

		lever.setPowered(false);
		state.setData(lever);
		state.update();
		clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
				0, 0.2, 0, 0.03);
		player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");
	}

}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:38,代碼來源:GeneratorListener.java

示例5: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    final TOAUser u = TOA.getPlayer(e.getPlayer());

    if (e.getItem() != null) {
        Material m = e.getItem().getType();
        if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
        Ability.useAbility(u, e.getItem().getType());
        e.setCancelled(true);
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:29,代碼來源:GameEvents.java

示例6: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    PAUser u = PAServer.getUser(e.getPlayer());

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (e.getItem() == null) return;
        e.setCancelled(true);
        if (Cosmetic.useCosmetic(u, e.getItem().getType())) return;

        switch (e.getItem().getType()) {
            case NETHER_STAR:
                e.setCancelled(true);
                LobbyMenu.openMenu(u, LobbyMenu.MenuType.SERVERS);
                break;
            case REDSTONE:
                e.setCancelled(true);
                u.sendMessage(PAData.LOBBY.getPrefix() + "&cNo estamos listos aún");
                //LobbyMenu.openMenu(u, LobbyMenu.MenuType.COSMETICOS);
                break;
            case WOOD_AXE:
                e.setCancelled(true);
                u.sendToServer("cons");
                break;
        }

        if (e.getClickedBlock() == null) return;
        if (e.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE) {
            e.setCancelled(true);
            u.sendMessage(PAData.LOBBY.getPrefix() + "&cActualmente estamos trabajando en esto, disculpen las molestias");
        }
    }

    if (!u.isOnRank(PACmd.Grupo.Builder)) {
        if (e.getClickedBlock() != null) {
            if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
                    || e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
                    || e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
                    || e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
                    || e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
                    || e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
                    || e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
                    || e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
                    || e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
                    || e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:50,代碼來源:PlayerEvents.java


注:本文中的org.bukkit.Material.STONE_BUTTON屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。