当前位置: 首页>>代码示例>>Java>>正文


Java Material.SPONGE属性代码示例

本文整理汇总了Java中org.bukkit.Material.SPONGE属性的典型用法代码示例。如果您正苦于以下问题:Java Material.SPONGE属性的具体用法?Java Material.SPONGE怎么用?Java Material.SPONGE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.SPONGE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMove

@EventHandler
public void onMove(PlayerMoveEvent e){
    Player p = e.getPlayer();
    WCUser user = WCSurvival.getPlayer(p);
    Block launch = p.getWorld().getBlockAt(p.getLocation()).getRelative(BlockFace.DOWN);
    Block base = launch.getRelative(BlockFace.DOWN);

    if (!e.getFrom().equals(e.getTo())){
        if (WCServer.afkMode.contains(user)) user.toggleAFK();
    }

    if(launch.getType() == Material.SPONGE && base.getType() == Material.DIAMOND_BLOCK){
        p.setVelocity(p.getLocation().getDirection().multiply(3));
        p.setVelocity(new Vector(p.getVelocity().getX(), 1.0D, p.getVelocity().getZ()));
        WCServer.getUser(p).sendSound(Sound.ENTITY_IRONGOLEM_ATTACK);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:17,代码来源:PlayerEvent.java

示例2: onPlayerLeaverInteract

@EventHandler
public void onPlayerLeaverInteract(PlayerInteractEvent e) {
	Player p = e.getPlayer();
	Block clicked = e.getClickedBlock();

	if (clicked == null)
		return;

	Block underneath = clicked.getRelative(BlockFace.DOWN);
	Location underneathLoc = underneath.getLocation();

	if (e.getAction() != Action.RIGHT_CLICK_BLOCK || e.getHand() == EquipmentSlot.OFF_HAND)
		return;

	if (clicked.getType() != Material.LEVER || underneath == null)
		return;

	String chunk = clicked.getLocation().getChunk().getX() + ";" + clicked.getLocation().getChunk().getZ();

	if (underneath.getType() == Material.SPONGE && !underneath.isBlockPowered()) {
		if (!main.getGeckManager().isGeckBuildCorrect(underneath)) {
			p.sendMessage(ChatColor.RED + "You must build the GECK correctly!");

			// Check if the geck is inside the powerables list
		} else if (main.getGenListener().getPowerable().get(clicked.getWorld().getName()).getList(chunk)
				.contains(underneathLoc)) {
			main.getGeckObjectManager().addGeckLocation(underneathLoc);
			main.getGeckObjectManager().getGeckObject(underneathLoc).setCorrect(true);
			main.getGeckObjectManager().getGeckObject(underneathLoc).setPowered(true);
			p.sendMessage(ChatColor.GREEN + "GECK Enabled!");
			return;
		}

	} else if (main.getGeckObjectManager().getGeckObject(underneathLoc) != null && underneath.isBlockPowered()) {
		main.getGeckObjectManager().getGeckObject(underneathLoc).setPowered(false);
		main.getGeckObjectManager().removeGeckLocation(underneathLoc);
		p.sendMessage(ChatColor.RED + "GECK Disabled!");
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:39,代码来源:GeckPowerListener.java

示例3: onBreakBlock

@EventHandler
public void onBreakBlock(BlockBreakEvent event) {
	Player player = event.getPlayer();
	Block broken = event.getBlock();
	Location geckLocation = broken.getRelative(0, -1, 0).getLocation();

	if (broken.getType() == Material.LEVER) {
		if (main.getGeckObjectManager().getGeckObject(geckLocation) != null) {
			main.getGeckObjectManager().removeGeckLocation(geckLocation);
			player.sendMessage(ChatColor.RED + "GECK disabled.");
		}

	} else if (broken.getType() == Material.SPONGE
			&& main.getGeckObjectManager().getGeckObject(broken.getLocation()) != null) {
		main.getGeckObjectManager().removeGeckLocation(broken.getLocation());
		player.sendMessage(ChatColor.RED + "GECK disabled.");

	} else if (broken.getType() == Material.PISTON_BASE) {
		List<BlockFace> sides = Arrays.asList(BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH);
		sides.forEach(side -> {
			Location bloc = broken.getRelative(side).getLocation();

			if (main.getGeckObjectManager().getGeckObject(bloc) != null) {
				main.getGeckObjectManager().removeGeckLocation(bloc);
				player.sendMessage(ChatColor.RED + "GECK disabled.");
			}
		});
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:29,代码来源:GeckPowerListener.java


注:本文中的org.bukkit.Material.SPONGE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。