Advertisement
Cool_boy21

Untitled

May 11th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.84 KB | None | 0 0
  1. package ua.Coolboy.QuartzDefenders.Turrets;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collection;
  5. import java.util.List;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.ArmorStand;
  9. import org.bukkit.entity.Arrow;
  10. import org.bukkit.entity.Entity;
  11. import org.bukkit.entity.EntityType;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.entity.TippedArrow;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.metadata.FixedMetadataValue;
  16. import org.bukkit.potion.PotionEffect;
  17. import org.bukkit.util.Vector;
  18. import ua.Endertainment.QuartzDefenders.Game;
  19. import ua.Endertainment.QuartzDefenders.GameTeam;
  20. import ua.Endertainment.QuartzDefenders.QuartzDefenders;
  21.  
  22. public class Turret {
  23.     private QuartzDefenders plugin;
  24.     private List<Entity> stands = new ArrayList<>();
  25.     private final Game game;
  26.     private final Player owner;
  27.     private final GameTeam team;
  28.     ArmorStand stand;
  29.    
  30.     public Turret(Player owner, Location loc) {
  31.         this.owner = owner;
  32.         this.game = plugin.getGame(owner);
  33.        
  34.         this.team = team;
  35.         ArmorStand turret = (ArmorStand) loc.getWorld().spawnEntity(loc.add(0.5, 1, 0.5), EntityType.ARMOR_STAND);
  36.                 turret.getEquipment().setHelmet(new ItemStack(Material.DISPENSER, 1));
  37.                 turret.setSmall(true);
  38.                 turret.setInvulnerable(true);
  39.                 turret.setCustomName("Турель");
  40.                 turret.setGravity(false);
  41.                 turret.setCustomNameVisible(true);
  42.                 turret.setMetadata("turret", new FixedMetadataValue(plugin, true));
  43.                 turret.setMetadata("lived", new FixedMetadataValue(plugin, 0));
  44.                 turret.setMetadata("type", new FixedMetadataValue(plugin, "normal"));
  45.                 //team.addTurret(turret);
  46.                 stands.add(turret);
  47.                 this.stand = turret;
  48.     }
  49.    
  50.     public List<Entity> getStands() {
  51.         return stands;
  52.     }
  53.    
  54.     public ArmorStand getStand() {
  55.         return stand;
  56.     }
  57.    
  58.     public void remove() {
  59.         stands.remove(stand);
  60.     }
  61.    
  62.     public Arrow launchArrow(Vector vector) {
  63.         Arrow arrow = stand.launchProjectile(Arrow.class);
  64.         arrow.setVelocity(vector.multiply(0.4));
  65.         arrow.setCritical(false);
  66.         arrow.spigot().setDamage(2);
  67.         return arrow;
  68.     }
  69.    
  70.     public TippedArrow launchTippedArrow(Vector vector, PotionEffect effect) {
  71.         TippedArrow arrow = stand.launchProjectile(TippedArrow.class);
  72.         arrow.setVelocity(vector.multiply(0.4));
  73.         arrow.setCritical(false);
  74.         arrow.spigot().setDamage(2);
  75.         arrow.addCustomEffect(effect, true);
  76.         return arrow;
  77.     }
  78.    
  79.     public Game getGame() {
  80.         return game;
  81.     }
  82.  
  83.     public GameTeam getTeam() {
  84.         return team;
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement