001 package org.bukkit.material; 002 003 import org.bukkit.Material; 004 005 /** 006 * Represents the tripwire 007 */ 008 public class Tripwire extends MaterialData { 009 010 public Tripwire() { 011 super(Material.TRIPWIRE); 012 } 013 014 /** 015 * 016 * @deprecated Magic value 017 */ 018 @Deprecated 019 public Tripwire(final int type) { 020 super(type); 021 } 022 023 /** 024 * 025 * @deprecated Magic value 026 */ 027 @Deprecated 028 public Tripwire(final int type, final byte data) { 029 super(type, data); 030 } 031 032 /** 033 * Test if tripwire is currently activated 034 * 035 * @return true if activated, false if not 036 */ 037 public boolean isActivated() { 038 return (getData() & 0x4) != 0; 039 } 040 041 /** 042 * Set tripwire activated state 043 * 044 * @param act - true if activated, false if not 045 */ 046 public void setActivated(boolean act) { 047 int dat = getData() & (0x8 | 0x3); 048 if (act) { 049 dat |= 0x4; 050 } 051 setData((byte) dat); 052 } 053 054 /** 055 * Test if object triggering this tripwire directly 056 * 057 * @return true if object activating tripwire, false if not 058 */ 059 public boolean isObjectTriggering() { 060 return (getData() & 0x1) != 0; 061 } 062 063 /** 064 * Set object triggering state for this tripwire 065 * 066 * @param trig - true if object activating tripwire, false if not 067 */ 068 public void setObjectTriggering(boolean trig) { 069 int dat = getData() & 0xE; 070 if (trig) { 071 dat |= 0x1; 072 } 073 setData((byte) dat); 074 } 075 076 @Override 077 public Tripwire clone() { 078 return (Tripwire) super.clone(); 079 } 080 081 @Override 082 public String toString() { 083 return super.toString() + (isActivated()?" Activated":"") + (isObjectTriggering()?" Triggered":""); 084 } 085 }