/** * checks if this block would give a reaction if you click on it without * shifting, e.g. opening a chest or switching a lever */ public static boolean isInteractiveBlock(Block b) { if (b == null || b.getState() == null) { return false; } if (b.getType() == Material.WORKBENCH || b.getType() == Material.ENCHANTMENT_TABLE || b.getType() == Material.ANVIL || b.getType() == Material.BREWING_STAND || b.getState() instanceof InventoryHolder || b.getState() instanceof NoteBlock) { return true; } if (b.getState().getData() instanceof Button || b.getState().getData() instanceof Lever || b.getState().getData() instanceof Door || b.getState().getData() instanceof TrapDoor || b.getState().getData() instanceof Gate || b.getState().getData() instanceof Comparator) { if (b.getType() != Material.IRON_DOOR && b.getType() != Material.IRON_DOOR_BLOCK && b.getType() != Material.IRON_TRAPDOOR) { return true; } } return false; }
/** TODO: Documentation */ public Optional<Button> getButton() { if (this.buttonLoc.getBlock().getType().equals(Material.STONE_BUTTON)) { final Button btn = (Button) this.buttonLoc.getBlock().getState().getData(); return Optional.of(btn); } return Optional.empty(); }
@Override public void onPlayerRightClickBlock(PlayerInteractEvent event, BPPlayer bpPlayer) { Block block = event.getClickedBlock(); Material mat = block.getType(); if(mat == Material.STONE_BUTTON) { Button button = (Button) block.getState().getData(); Block attBlock = block.getRelative(button.getAttachedFace()); if(attBlock.getType() == Material.WOOL) clickedWoolButton(event, attBlock, bpPlayer); } else if(mat == Material.WALL_SIGN || mat == Material.SIGN_POST) { Sign sign = (Sign) block.getState(); String[] lines = sign.getLines(); if(ChatColor.stripColor(lines[0]).equals(MessageType.CHARACTER_SELECT.getTranslation().getValue())) { Player player = bpPlayer.getPlayer(); CTFProperties props = (CTFProperties) bpPlayer.getGameProperties(); Team team = props.getTeam(); if(team != null) { CharacterType selectedCT = props.getCharacterType(); if(selectedCT == null) { String rawCharType = ChatColor.stripColor(lines[1]); CharacterType charType = null; for(CharacterType ct : CharacterType.values()) if(rawCharType.equalsIgnoreCase(ct.getProperName())) { charType = ct; break; } if(charType != null) { String name = charType.getProperName(); if(charType.requiresVIP() && !player.hasPermission("Breakpoint.vip")) { player.sendMessage(ChatColor.DARK_GRAY + "---"); player.sendMessage(MessageType.LOBBY_CHARACTER_VIPSONLY.getTranslation().getValue(name)); player.sendMessage(ChatColor.DARK_GRAY + "---"); return; } props.chooseCharacter(charType, true); player.sendMessage(MessageType.LOBBY_CHARACTER_SELECTED.getTranslation().getValue(name)); } else player.sendMessage(MessageType.LOBBY_CHARACTER_NOTFOUND.getTranslation().getValue(rawCharType)); } else { String charName = selectedCT.getProperName(); player.sendMessage(MessageType.LOBBY_CHARACTER_ALREADYSELECTED.getTranslation().getValue(charName)); } } else player.sendMessage(MessageType.LOBBY_TEAM_WARN.getTranslation().getValue()); } } }
public Button() { }
@Deprecated public Button(int type) { }
public Button(Material type) { }
@Deprecated public Button(int type, byte data) { }
@Deprecated public Button(Material type, byte data) { }
public Button clone() { return null; }