Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.material.Lever Class Reference
Inheritance diagram for org.bukkit.material.Lever:
org.bukkit.material.SimpleAttachableMaterialData org.bukkit.material.Redstone org.bukkit.material.MaterialData org.bukkit.material.Attachable org.bukkit.material.Directional

Public Member Functions

 Lever (final int type)
 
 Lever (final Material type)
 
 Lever (final int type, final byte data)
 
 Lever (final Material type, final byte data)
 
boolean isPowered ()
 
void setPowered (boolean isPowered)
 
BlockFace getAttachedFace ()
 
void setFacingDirection (BlockFace face)
 
String toString ()
 
Lever clone ()
 
- Public Member Functions inherited from org.bukkit.material.SimpleAttachableMaterialData
 SimpleAttachableMaterialData (int type)
 
 SimpleAttachableMaterialData (int type, BlockFace direction)
 
 SimpleAttachableMaterialData (Material type, BlockFace direction)
 
 SimpleAttachableMaterialData (Material type)
 
 SimpleAttachableMaterialData (int type, byte data)
 
 SimpleAttachableMaterialData (Material type, byte data)
 
BlockFace getFacing ()
 
String toString ()
 
SimpleAttachableMaterialData clone ()
 
- Public Member Functions inherited from org.bukkit.material.MaterialData
 MaterialData (final int type)
 
 MaterialData (final Material type)
 
 MaterialData (final int type, final byte data)
 
 MaterialData (final Material type, final byte data)
 
byte getData ()
 
void setData (byte data)
 
Material getItemType ()
 
int getItemTypeId ()
 
ItemStack toItemStack ()
 
ItemStack toItemStack (int amount)
 
String toString ()
 
int hashCode ()
 
boolean equals (Object obj)
 
MaterialData clone ()
 

Detailed Description

Represents a lever

Definition at line 9 of file Lever.java.

Constructor & Destructor Documentation

org.bukkit.material.Lever.Lever ( final int  type)
Deprecated:
Magic value

Definition at line 19 of file Lever.java.

19  {
20  super(type);
21  }
org.bukkit.material.Lever.Lever ( final int  type,
final byte  data 
)
Deprecated:
Magic value

Definition at line 32 of file Lever.java.

32  {
33  super(type, data);
34  }
org.bukkit.material.Lever.Lever ( final Material  type,
final byte  data 
)
Deprecated:
Magic value

Definition at line 41 of file Lever.java.

41  {
42  super(type, data);
43  }

Member Function Documentation

BlockFace org.bukkit.material.Lever.getAttachedFace ( )

Gets the face that this block is attached on

Returns
BlockFace attached to

Implements org.bukkit.material.Attachable.

Definition at line 69 of file Lever.java.

References org.bukkit.material.MaterialData.getData().

Referenced by org.bukkit.material.Lever.setFacingDirection().

69  {
70  byte data = (byte) (getData() & 0x7);
71 
72  switch (data) {
73  case 0x1:
74  return BlockFace.WEST;
75 
76  case 0x2:
77  return BlockFace.EAST;
78 
79  case 0x3:
80  return BlockFace.NORTH;
81 
82  case 0x4:
83  return BlockFace.SOUTH;
84 
85  case 0x5:
86  case 0x6:
87  return BlockFace.DOWN;
88 
89  case 0x0:
90  case 0x7:
91  return BlockFace.UP;
92 
93  }
94 
95  return null;
96  }
boolean org.bukkit.material.Lever.isPowered ( )

Gets the current state of this Material, indicating if it's powered or unpowered

Returns
true if powered, otherwise false

Implements org.bukkit.material.Redstone.

Definition at line 51 of file Lever.java.

References org.bukkit.material.MaterialData.getData().

51  {
52  return (getData() & 0x8) == 0x8;
53  }
void org.bukkit.material.Lever.setFacingDirection ( BlockFace  face)

Sets the direction this lever is pointing in

Implements org.bukkit.material.Directional.

Definition at line 101 of file Lever.java.

References org.bukkit.material.Lever.getAttachedFace(), org.bukkit.material.MaterialData.getData(), and org.bukkit.material.MaterialData.setData().

101  {
102  byte data = (byte) (getData() & 0x8);
103  BlockFace attach = getAttachedFace();
104 
105  if (attach == BlockFace.DOWN) {
106  switch (face) {
107  case SOUTH:
108  case NORTH:
109  data |= 0x5;
110  break;
111 
112  case EAST:
113  case WEST:
114  data |= 0x6;
115  break;
116  }
117  } else if (attach == BlockFace.UP) {
118  switch (face) {
119  case SOUTH:
120  case NORTH:
121  data |= 0x7;
122  break;
123 
124  case EAST:
125  case WEST:
126  data |= 0x0;
127  break;
128  }
129  } else {
130  switch (face) {
131  case EAST:
132  data |= 0x1;
133  break;
134 
135  case WEST:
136  data |= 0x2;
137  break;
138 
139  case SOUTH:
140  data |= 0x3;
141  break;
142 
143  case NORTH:
144  data |= 0x4;
145  break;
146  }
147  }
148  setData(data);
149  }
BlockFace getAttachedFace()
Definition: Lever.java:69
void org.bukkit.material.Lever.setPowered ( boolean  isPowered)

Set this lever to be powered or not.

Parameters
isPoweredwhether the lever should be powered or not

Definition at line 60 of file Lever.java.

References org.bukkit.material.MaterialData.getData(), and org.bukkit.material.MaterialData.setData().

60  {
61  setData((byte) (isPowered ? (getData() | 0x8) : (getData() & ~0x8)));
62  }

The documentation for this class was generated from the following file: