本文整理匯總了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.");
}
});
}
}