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.03 KB  |  views: 34  |  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.                         ChargeFest.log.info("Back in to main thread...");
  33.                         // Economy stuff here
  34.                         if (door != null) {
  35.                                 ChargeFest.log.info("A door");
  36.                                 door.setOpen(door.isOpen());
  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 Door findDoor (Sign sign)
  58.         {
  59.             Block block = sign.getBlock();
  60.                
  61.             for (BlockFace bf : tollFaces)
  62.             {
  63.                 Block faceBlock = block.getRelative(bf);
  64.                 ChargeFest.log.info(""+faceBlock.getType());
  65.                 if (faceBlock.getType() == Material.WOODEN_DOOR)
  66.                 {
  67.                         return (Door) faceBlock.getState().getData();
  68.                 }
  69.             }
  70.             return null;
  71.         }
  72.        
  73. }
clone this paste RAW Paste Data