org.bukkit.material.Bed Java Examples
The following examples show how to use
org.bukkit.material.Bed.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
private void dropTargetBlock(Block targetBlock) { if (targetBlock.getType().equals(Material.BED_BLOCK)) { Block bedHead; Block bedFeet; Bed bedBlock = (Bed) targetBlock.getState().getData(); if (!bedBlock.isHeadOfBed()) { bedFeet = targetBlock; bedHead = Utils.getBedNeighbor(bedFeet); } else { bedHead = targetBlock; bedFeet = Utils.getBedNeighbor(bedHead); } if (!BedwarsRel.getInstance().getCurrentVersion().startsWith("v1_12")) { bedFeet.setType(Material.AIR); } else { bedHead.setType(Material.AIR); } } else { targetBlock.setType(Material.AIR); } }
Example #2
Source File: BlockAdapterMagicValues.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
@Override public boolean isBedHead(Block block) { MaterialData data = block.getState().getData(); if (!(data instanceof Bed)) { throw new IllegalArgumentException("Block is not Bed"); } return ((Bed) data).isHeadOfBed(); }
Example #3
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
public boolean handleDestroyTargetMaterial(Player p, Block block) { Team team = this.getPlayerTeam(p); if (team == null) { return false; } Team bedDestroyTeam = null; Block bedBlock = team.getHeadTarget(); if (block.getType().equals(Material.BED_BLOCK)) { Block breakBlock = block; Block neighbor = null; Bed breakBed = (Bed) breakBlock.getState().getData(); if (!breakBed.isHeadOfBed()) { neighbor = breakBlock; breakBlock = Utils.getBedNeighbor(neighbor); } else { neighbor = Utils.getBedNeighbor(breakBlock); } if (bedBlock.equals(breakBlock)) { p.sendMessage( ChatWriter .pluginMessage(ChatColor.RED + BedwarsRel._l(p, "ingame.blocks.ownbeddestroy"))); return false; } bedDestroyTeam = this.getTeamOfBed(breakBlock); if (bedDestroyTeam == null) { return false; } this.dropTargetBlock(block); } else { if (bedBlock.equals(block)) { p.sendMessage( ChatWriter .pluginMessage(ChatColor.RED + BedwarsRel._l(p, "ingame.blocks.ownbeddestroy"))); return false; } bedDestroyTeam = this.getTeamOfBed(block); if (bedDestroyTeam == null) { return false; } this.dropTargetBlock(block); } // set statistics if (BedwarsRel.getInstance().statisticsEnabled()) { PlayerStatistic statistic = BedwarsRel.getInstance().getPlayerStatisticManager() .getStatistic(p); statistic.setCurrentDestroyedBeds(statistic.getCurrentDestroyedBeds() + 1); statistic.setCurrentScore(statistic.getCurrentScore() + BedwarsRel.getInstance() .getIntConfig("statistics.scores.bed-destroy", 25)); } // reward when destroy bed if (BedwarsRel.getInstance().getBooleanConfig("rewards.enabled", false)) { List<String> commands = BedwarsRel.getInstance().getConfig().getStringList("rewards.player-destroy-bed"); BedwarsRel.getInstance() .dispatchRewardCommands(commands, ImmutableMap.of("{player}", p.getName(), "{score}", String.valueOf( BedwarsRel.getInstance().getIntConfig("statistics.scores.bed-destroy", 25)))); } BedwarsTargetBlockDestroyedEvent targetBlockDestroyedEvent = new BedwarsTargetBlockDestroyedEvent(this, p, bedDestroyTeam); BedwarsRel.getInstance().getServer().getPluginManager().callEvent(targetBlockDestroyedEvent); for (Player aPlayer : this.getPlayers()) { if (aPlayer.isOnline()) { aPlayer.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(aPlayer, "ingame.blocks.beddestroyed", ImmutableMap.of("team", bedDestroyTeam.getChatColor() + bedDestroyTeam.getName() + ChatColor.RED, "player", Game.getPlayerWithTeamString(p, team, ChatColor.RED))))); } } this.broadcastSound( Sound.valueOf( BedwarsRel.getInstance().getStringConfig("bed-sound", "ENDERDRAGON_GROWL") .toUpperCase()), 30.0F, 10.0F); this.updateScoreboard(); return true; }
Example #4
Source File: SetTargetCommand.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, ArrayList<String> args) { if (!super.hasPermission(sender)) { return false; } Player player = (Player) sender; String team = args.get(1); Game game = this.getPlugin().getGameManager().getGame(args.get(0)); if (game == null) { player.sendMessage(ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(player, "errors.gamenotfound", ImmutableMap.of("game", args.get(0).toString())))); return false; } if (game.getState() == GameState.RUNNING) { sender.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel ._l(sender, "errors.notwhilegamerunning"))); return false; } Team gameTeam = game.getTeam(team); if (gameTeam == null) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.teamnotfound"))); return false; } Class<?> hashsetType = Utils.getGenericTypeOfParameter(player.getClass(), "getTargetBlock", 0); Method targetBlockMethod = this.getTargetBlockMethod(player); Block targetBlock = null; if (targetBlockMethod != null) { targetBlock = this.getTargetBlock(targetBlockMethod, hashsetType, player); } Block standingBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN); if (targetBlock == null || standingBlock == null) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.bedtargeting"))); return false; } Material targetMaterial = game.getTargetMaterial(); if (targetBlock.getType() != targetMaterial && standingBlock.getType() != targetMaterial) { player.sendMessage( ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel._l(player, "errors.bedtargeting"))); return false; } Block theBlock = null; if (targetBlock.getType() == targetMaterial) { theBlock = targetBlock; } else { theBlock = standingBlock; } if (targetMaterial.equals(Material.BED_BLOCK)) { Block neighbor = null; Bed theBed = (Bed) theBlock.getState().getData(); if (!theBed.isHeadOfBed()) { neighbor = theBlock; theBlock = Utils.getBedNeighbor(neighbor); } else { neighbor = Utils.getBedNeighbor(theBlock); } gameTeam.setTargets(theBlock, neighbor); } else { gameTeam.setTargets(theBlock, null); } player.sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + BedwarsRel ._l(player, "success.bedset", ImmutableMap .of("team", gameTeam.getChatColor() + gameTeam.getName() + ChatColor.GREEN)))); return true; }