本文整理汇总了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);
}
}
示例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!");
}
}
示例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.");
}
});
}
}