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: 1.88 KB  |  views: 61  |  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.BlockState;
  7. import org.bukkit.block.Sign;
  8. import org.bukkit.material.Door;
  9.  
  10. public class Signs {
  11.        
  12.         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};
  13.                
  14.         private static boolean isTollSign (Sign sign) {
  15.                 String[] contents = Signs.getSignContents(sign);
  16.                
  17.                 if (contents[0].equalsIgnoreCase("[Toll]")) return true;
  18.                 return false;
  19.         }
  20.        
  21.         private static String[] getSignContents (Sign sign) {
  22.                 return sign.getLines();
  23.         }
  24.        
  25.         public static void use (Sign sign) {
  26.                
  27.                 // Check to see if the right-clicked sign is a toll sign
  28.                 if (Signs.isTollSign(sign)) {
  29.                        
  30.                         // Locate the door
  31.                         Door door = Signs.findDoor(sign);
  32.                         System.out.println(door);
  33.                         ChargeFest.log.info("Back in to main thread...");
  34.                         // Economy stuff here
  35.                         door.setOpen(door.isOpen());
  36.                        
  37.                 } else return;
  38.                
  39.         }
  40.        
  41.         private static Block find (Sign sign, Material material) {
  42.                 Block block = sign.getBlock();
  43.                
  44.                 for (BlockFace bf : tollFaces) {
  45.             Block faceBlock = block.getRelative(bf);          
  46.             if (faceBlock.getType() == material) {
  47.                 ChargeFest.log.info("Door found!");
  48.                 return faceBlock;
  49.             }
  50.         }
  51.                 return null;
  52.         }
  53.        
  54.         private static Door findDoor (Sign sign)
  55.         {
  56.             Block block = sign.getBlock();
  57.                
  58.             for (BlockFace bf : tollFaces)
  59.             {
  60.                 Block faceBlock = block.getRelative(bf);          
  61.                 if (faceBlock.getState() instanceof Door)
  62.                 {
  63.                         return (Door) faceBlock.getState();
  64.                 }
  65.             }
  66.             return null;
  67.         }
  68.        
  69. }
clone this paste RAW Paste Data