Java 类org.bukkit.material.Button 实例源码

项目:Transport-Pipes    文件:HitboxUtils.java   
/**
 * 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;
}
项目:CraftoPlugin    文件:Craftomat.java   
/** 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();
}
项目:Breakpoint    文件:CTFListener.java   
@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());
        }
    }
}
项目:Breakpoint    文件:CTFListener.java   
@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());
        }
    }
}
项目:BedrockAPI    文件:Button.java   
public Button() {
}
项目:BedrockAPI    文件:Button.java   
@Deprecated public Button(int type) {
}
项目:BedrockAPI    文件:Button.java   
public Button(Material type) {
}
项目:BedrockAPI    文件:Button.java   
@Deprecated public Button(int type, byte data) {
}
项目:BedrockAPI    文件:Button.java   
@Deprecated public Button(Material type, byte data) {
}
项目:BedrockAPI    文件:Button.java   
public Button clone() {
    return null;
}