NevLo

SQTNLT

Aug 18th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.31 KB | None | 0 0
  1. package me.NevLo.SQTurrets_M.Types;
  2.  
  3. import org.bukkit.Location;
  4. import org.bukkit.Material;
  5. import org.bukkit.block.Block;
  6. import org.bukkit.block.BlockFace;
  7. import org.bukkit.block.Sign;
  8. import org.bukkit.entity.Player;
  9.  
  10. import me.NevLo.SQTurrets_M.Utils;
  11. import net.md_5.bungee.api.ChatColor;
  12.  
  13. public class Turret {
  14.  
  15.     private String name;
  16.     private String permission;
  17.     private boolean onCooldown;
  18.     public void fire(Player p){
  19.         p.sendMessage("You are firing!");
  20.     }
  21.  
  22.     public static void enter(Player p, Sign s){
  23.         p.sendMessage(ChatColor.RED + "You have entered a turret! Right click while holding a clock to exit, or left click to fire.");
  24.         Location l = Utils.getBlockBehindSign(s.getBlock()).getRelative(BlockFace.UP).getLocation();
  25.         Location target = new Location(l.getWorld(), l.getX() + 0.5D, l.getY(), l.getZ() + 0.5D);
  26.         target.getBlock().setType(Material.GLOWSTONE);
  27.         p.teleport(target);
  28.         s.setLine(1, ChatColor.RED + "OCCUPIED");
  29.     }
  30.     public void exit(Player p){
  31.         Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
  32.         BlockFace s = BlockFace.NORTH;
  33.         BlockFace[] slocs = {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
  34.         for(BlockFace bf : slocs){
  35.             if(b.getRelative(bf).getType() == Material.WALL_SIGN
  36.                     && ((Sign)b.getRelative(bf).getState()).getLine(0).equalsIgnoreCase(ChatColor.BLUE + "Turret")){
  37.                
  38.                 s = bf;
  39.             }
  40.         }
  41.        
  42.         Sign sign = (Sign) b.getRelative(s).getState();
  43.         b.getRelative(BlockFace.UP).setType(Material.REDSTONE_LAMP);
  44.         double[] xy = Utils.playerOffsetOnTeleport(s);
  45.         int ymod = 0;
  46.         p.teleport(new Location(p.getLocation().getWorld(), p.getLocation().getX() + xy[0], b.getY() - ymod, p.getLocation().getZ() + xy[1] ));
  47.         if(sign != null){
  48.             sign.setLine(1, ChatColor.GREEN + "UNOCCUPIED");
  49.             sign.setLine(2, "");
  50.             sign.setLine(3, "");
  51.             sign.update(true);
  52.         }
  53.        
  54.        
  55.        
  56.        
  57.        
  58.        
  59.        
  60.        
  61.     }
  62.    
  63.  
  64.  
  65.     public String getName() {
  66.         return name;
  67.     }
  68.  
  69.  
  70.     public void setName(String name) {
  71.         this.name = name;
  72.     }
  73.  
  74.  
  75.     public String getPermission() {
  76.         return permission;
  77.     }
  78.  
  79.  
  80.     public void setPermission(String permission) {
  81.         this.permission = permission;
  82.     }
  83.  
  84.  
  85.     public boolean isOnCooldown() {
  86.         return onCooldown;
  87.     }
  88.  
  89.  
  90.     public void setOnCooldown(boolean onCooldown) {
  91.         this.onCooldown = onCooldown;
  92.     }
  93. }
Add Comment
Please, Sign In to add comment