This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: Java  |  size: 2.05 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.daveblencowe.chargefest;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.block.Block;
  5. import org.bukkit.block.BlockFace;
  6. import org.bukkit.block.Sign;
  7. import org.bukkit.material.Door;
  8.  
  9. public class Signs {
  10.        
  11.         private static final BlockFace[] tollFaces = {BlockFace.SELF, BlockFace.DOWN, BlockFace.UP, BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST, BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST};
  12.                
  13.         private static boolean isTollSign (Sign sign) {
  14.                 String[] contents = Signs.getSignContents(sign);
  15.                
  16.                 if (contents[0].equalsIgnoreCase("[Toll]")) return true;
  17.                 return false;
  18.         }
  19.        
  20.         private static String[] getSignContents (Sign sign) {
  21.                 return sign.getLines();
  22.         }
  23.        
  24.         public static void use (Sign sign) {
  25.                
  26.                 // Check to see if the right-clicked sign is a toll sign
  27.                 if (Signs.isTollSign(sign)) {
  28.                        
  29.                         // Locate the door
  30.                         Block doorBlock = Signs.findDoor(sign);
  31.                         ChargeFest.log.info("Back in to main thread...");
  32.                         // Economy stuff here
  33.                         if (doorBlock != null) {
  34.                                 ChargeFest.log.info("A door");
  35.                                 Door door = (Door) doorBlock.getState().getData();
  36.                                 doorBlock.setData((byte)(door.getData()^4));
  37.                         }                      
  38.                        
  39.                 } else return;
  40.                
  41.         }
  42.        
  43.         private static Block find (Sign sign, Material material) {
  44.                 Block block = sign.getBlock();
  45.                
  46.                 for (BlockFace bf : tollFaces) {
  47.             Block faceBlock = block.getRelative(bf);
  48.             ChargeFest.log.info(""+faceBlock.getState());
  49.             if (faceBlock.getType() == material) {
  50.                 ChargeFest.log.info("Door found!");
  51.                 return faceBlock;
  52.             }
  53.         }
  54.                 return null;
  55.         }
  56.        
  57.         private static Block findDoor (Sign sign)
  58.         {
  59.             Block block = sign.getBlock();
  60.                
  61.             for (BlockFace bf : tollFaces) {
  62.                 Block faceBlock = block.getRelative(bf);
  63.                 ChargeFest.log.info(""+faceBlock.getType());
  64.                 if (faceBlock.getType() == Material.WOODEN_DOOR) {
  65.                         return (Block) faceBlock.getState();
  66.                 }
  67.             }
  68.             return null;
  69.         }
  70.        
  71. }
clone this paste RAW Paste Data