001    package org.bukkit.material;
002    
003    import org.bukkit.Material;
004    
005    /**
006     * Represents a command block
007     */
008    public class Command extends MaterialData implements Redstone {
009        public Command() {
010            super(Material.COMMAND);
011        }
012    
013        /**
014         *
015         * @deprecated Magic value
016         */
017        @Deprecated
018        public Command(final int type) {
019            super(type);
020        }
021    
022        public Command(final Material type) {
023            super(type);
024        }
025    
026        /**
027         *
028         * @deprecated Magic value
029         */
030        @Deprecated
031        public Command(final int type, final byte data) {
032            super(type, data);
033        }
034    
035        /**
036         *
037         * @deprecated Magic value
038         */
039        @Deprecated
040        public Command(final Material type, final byte data) {
041            super(type, data);
042        }
043    
044        /**
045         * Gets the current state of this Material, indicating if it's powered or
046         * unpowered
047         *
048         * @return true if powered, otherwise false
049         */
050        public boolean isPowered() {
051            return (getData() & 1) != 0;
052        }
053    
054        /**
055         * Sets the current state of this Material
056         *
057         * @param bool
058         *            whether or not the command block is powered
059         */
060        public void setPowered(boolean bool) {
061            setData((byte) (bool ? (getData() | 1) : (getData() & -2)));
062        }
063    
064        @Override
065        public String toString() {
066            return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED";
067        }
068    
069        @Override
070        public Command clone() {
071            return (Command) super.clone();
072        }
073    }