Lexepi

Untitled

Nov 27th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. package com.lexepi.armorstand.ArmorStandTnT;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Location;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.EntityType;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.entity.TNTPrimed;
  11. import org.bukkit.craftbukkit.v1_8_R1.entity.CraftArmorStand;
  12. import org.bukkit.entity.ArmorStand;
  13.  
  14. import net.minecraft.server.v1_8_R1.EntityArmorStand;
  15. import net.minecraft.server.v1_8_R1.Item;
  16. import net.minecraft.server.v1_8_R1.ItemStack;
  17. import net.minecraft.server.v1_8_R1.Vector3f;
  18.  
  19. public class MyStandTnT implements CommandExecutor{
  20.  
  21. int countdown = 11;
  22.  
  23. @Override
  24. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  25.  
  26. if(label.equalsIgnoreCase("as")){
  27.  
  28. if(sender instanceof Player){
  29.  
  30. Player player = (Player)sender;
  31. Location l = player.getLocation();
  32. ArmorStand stand = ((ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND));
  33. EntityArmorStand as = ((CraftArmorStand) stand).getHandle();
  34.  
  35.  
  36. as.setGravity(true);
  37. as.setBasePlate(true);
  38.  
  39. as.setArms(true);
  40. as.setEquipment(1, new ItemStack(Item.getById(298)));
  41. as.setEquipment(2, new ItemStack(Item.getById(299)));
  42. as.setEquipment(3, new ItemStack(Item.getById(300)));
  43. as.setEquipment(4, new ItemStack(Item.getById(46)));
  44.  
  45. as.setLeftArmPose(new Vector3f(5f, 0f, -150f));
  46. as.setRightArmPose(new Vector3f(5f, 0f, 150f));
  47.  
  48. as.setHeadPose(new Vector3f(-30f, 0f, 0f));
  49.  
  50. Bukkit.getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("ArmorStand"), new Runnable() {
  51.  
  52. @Override
  53. public void run() {
  54. countdown--;
  55.  
  56. double x = stand.getLocation().getX();
  57. double y = stand.getLocation().getY();
  58. double z = stand.getLocation().getZ();
  59.  
  60. TNTPrimed tnt = (TNTPrimed) stand.getWorld().spawn(new Location(stand.getWorld(), x, y+2, z), TNTPrimed.class);
  61.  
  62. if(countdown == 10){
  63. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(0));
  64. }else if(countdown == 9){
  65. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1));
  66. }else if(countdown == 8){
  67. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.2));
  68. }else if(countdown == 7){
  69. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.3));
  70. }else if(countdown == 6){
  71. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.4));
  72. }else if(countdown == 5){
  73. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.5));
  74. }else if(countdown == 4){
  75. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.6));
  76. }else if(countdown == 3){
  77. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.7));
  78. }else if(countdown == 2){
  79. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.8));
  80. }else if(countdown == 1){
  81. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(1.9));
  82. }else if(countdown == 0){
  83. tnt.setVelocity(stand.getLocation().getDirection().normalize().multiply(2));
  84. stand.remove();
  85. Bukkit.getScheduler().cancelTask(countdown);
  86. }
  87. }
  88. },5, 5);
  89.  
  90.  
  91. }
  92.  
  93. return true;
  94. }
  95.  
  96. return false;
  97. }
  98.  
  99. }
Advertisement
Add Comment
Please, Sign In to add comment