Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. package hustler;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.Sound;
  10. import org.bukkit.World;
  11. import org.bukkit.block.Block;
  12. import org.bukkit.command.Command;
  13. import org.bukkit.command.CommandSender;
  14. import org.bukkit.entity.Entity;
  15. import org.bukkit.entity.EntityType;
  16. import org.bukkit.entity.Explosive;
  17. import org.bukkit.entity.Player;
  18. import org.bukkit.entity.TNTPrimed;
  19. import org.bukkit.event.EventHandler;
  20. import org.bukkit.event.EventPriority;
  21. import org.bukkit.event.Listener;
  22. import org.bukkit.event.block.Action;
  23. import org.bukkit.event.block.BlockExplodeEvent;
  24. import org.bukkit.event.block.BlockFromToEvent;
  25. import org.bukkit.event.block.BlockRedstoneEvent;
  26. import org.bukkit.event.entity.CreatureSpawnEvent;
  27. import org.bukkit.event.entity.EntityExplodeEvent;
  28. import org.bukkit.event.entity.ExplosionPrimeEvent;
  29. import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
  30. import org.bukkit.event.player.PlayerInteractEntityEvent;
  31. import org.bukkit.event.player.PlayerInteractEvent;
  32. import org.bukkit.inventory.ItemStack;
  33. import org.bukkit.inventory.meta.ItemMeta;
  34. import org.bukkit.plugin.PluginManager;
  35. import org.bukkit.plugin.java.JavaPlugin;
  36. import org.bukkit.potion.PotionEffect;
  37. import org.bukkit.potion.PotionEffectType;
  38.  
  39.  
  40. import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
  41. import com.onarandombox.MultiversePortals.event.MVPortalEvent;
  42.  
  43. import net.minecraft.server.v1_10_R1.Explosion;
  44.  
  45. public class nukeMain extends JavaPlugin implements Listener {
  46. public List<Location> explosions = new ArrayList<Location>();
  47. ItemStack shard2;
  48.  
  49. public void onEnable() {
  50. shard2 = new ItemStack(399);
  51. ItemMeta im2 = shard2.getItemMeta();
  52. List<String> lore2 = new ArrayList<String>();
  53. lore2.add("§6§lCAUTION CAUTION");
  54. lore2.add("§7Activating a Nuke is Very Dangerous");
  55. lore2.add("§7Never Use This on TNT!");
  56. im2.setLore(lore2);
  57. im2.setDisplayName("§a§kii§4§lNuke Core§a§kii");
  58. shard2.setItemMeta(im2);
  59.  
  60.  
  61. PluginManager manager = this.getServer().getPluginManager();
  62. manager.registerEvents(this, this);
  63.  
  64.  
  65.  
  66. }
  67.  
  68.  
  69.  
  70. @EventHandler(ignoreCancelled = true)
  71. public void ballFiring(EntityExplodeEvent e) {
  72.  
  73.  
  74. if(e.getEntityType().equals(EntityType.PRIMED_TNT)){
  75.  
  76. Entity ent = e.getEntity();
  77.  
  78. Location loc = ent.getLocation();
  79. Location loc2 =loc.add(12,0,0);
  80. Location loc3 =loc.add(-15,0,0);
  81. Location loc4 =loc.add(0,0,13);
  82. Location loc5 =loc.add(0,0,-14);
  83.  
  84.  
  85.  
  86. if(ent!=null){
  87. if(ent.getCustomName().contains("§4§lNUKE")){
  88.  
  89.  
  90. for (Player op : Bukkit.getOnlinePlayers()) {
  91. if(op.getLocation().distance(loc)<=150){
  92. op.addPotionEffect(new PotionEffect(PotionEffectType.POISON,3000,2));
  93. op.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,3000,3));
  94. }
  95. }
  96.  
  97. World world = ent.getWorld();
  98.  
  99.  
  100. world.createExplosion(loc, 70F);
  101. world.createExplosion(loc2, 70F);
  102. world.createExplosion(loc3, 70F);
  103. world.createExplosion(loc4, 70F);
  104. world.createExplosion(loc5, 70F);
  105.  
  106. }
  107. }
  108.  
  109.  
  110. }
  111. }
  112.  
  113. @EventHandler
  114. public static void getExplosion(ExplosionPrimeEvent event) {
  115. Bukkit.broadcastMessage("" + event.getRadius());
  116.  
  117.  
  118. }
  119.  
  120.  
  121.  
  122. public void startNuke(Location loc){
  123. TNTPrimed tnt = loc.getWorld().spawn(loc.add(0.5,0,0.5), TNTPrimed.class);
  124. tnt.setFuseTicks(600);
  125. int timer = 30;
  126. tnt.setCustomName("§4§lNUKE : §6"+timer);
  127. loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 10.0F, -5.0F);
  128. tnt.setCustomNameVisible(true);
  129. ticktimer(tnt,timer);
  130. }
  131. public void ticktimer(final TNTPrimed tnt, final int timer){
  132.  
  133. if(timer >= 1){
  134.  
  135. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  136.  
  137. @Override
  138. public void run() {
  139. int timer2 = timer -1;
  140. ticktimer(tnt,timer2);
  141. tnt.setCustomName("§4§lNUKE : §6"+timer2);
  142. tnt.getWorld().playSound(tnt.getLocation(), Sound.BLOCK_ANVIL_LAND, 10.0F, -5.0F);
  143. if(timer2<=10&&timer2>3){
  144. half(tnt.getLocation(),20);
  145. }
  146. if(timer2<=3){
  147. quarter(tnt.getLocation(),4);
  148. }
  149. if(timer2 == 1){
  150. after(tnt.getLocation(),10);
  151. }
  152. }
  153. }, 20L);
  154. }
  155. else{
  156. return;
  157. }
  158.  
  159. }
  160.  
  161.  
  162.  
  163. public void half(final Location loc, final int count){
  164. if(count >=1){
  165.  
  166. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  167.  
  168. @Override
  169. public void run() {
  170. int count2 = count -1;
  171. loc.getWorld().playSound(loc, Sound.BLOCK_ANVIL_LAND, 10.0F, -5.0F);
  172.  
  173. }
  174. }, 10L);
  175.  
  176. }
  177. else{return;}
  178.  
  179. }
  180. public void quarter(final Location loc, final int count){
  181. if(count >=1){
  182.  
  183. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  184.  
  185. @Override
  186. public void run() {
  187. int count2 = count -1;
  188. loc.getWorld().playSound(loc, Sound.BLOCK_ANVIL_LAND, 10.0F, -5.0F);
  189. quarter(loc,count2);
  190. }
  191. }, 5L);
  192.  
  193. }
  194. else{return;}
  195.  
  196. }
  197.  
  198.  
  199. public void after(final Location loc, final int count){
  200. if(count >=1){
  201.  
  202. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  203.  
  204. @Override
  205. public void run() {
  206. int count2 = count -1;
  207. loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 10.0F, -5.0F);
  208. after(loc,count2);
  209. }
  210. }, 1L);
  211.  
  212. }
  213. else{return;}
  214.  
  215. }
  216.  
  217.  
  218.  
  219. @EventHandler
  220. public void ballFiring(PlayerInteractEvent e) {
  221. Player p = e.getPlayer();
  222.  
  223. if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
  224.  
  225. ItemStack item = shard2;
  226. item.setAmount(p.getItemInHand().getAmount());
  227. if(p.getItemInHand().equals(item)){
  228.  
  229.  
  230. if(e.getClickedBlock().getTypeId()== 46){
  231. int amount = p.getItemInHand().getAmount();
  232. item.setAmount(amount-1);
  233. p.setItemInHand(item);
  234. p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 10.0F, -5.0F);
  235. Block b =e.getClickedBlock();
  236. b.setType(Material.AIR);
  237. Location loc = e.getClickedBlock().getLocation();
  238. startNuke(loc);
  239.  
  240. // p.getWorld().createExplosion(loc, 70F);
  241. // p.getWorld().createExplosion(loc.add(15,0,0), 50F);
  242. // p.getWorld().createExplosion(loc.add(-15,0,0), 50F);
  243. // p.getWorld().createExplosion(loc.add(0,0,15), 50F);
  244. // p.getWorld().createExplosion(loc.add(0,0,-15), 50F);
  245.  
  246.  
  247.  
  248. }
  249. }
  250. }
  251.  
  252. }
  253.  
  254. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  255.  
  256. if ((cmd.getName().equalsIgnoreCase("nukekey"))) {
  257. Player p = (Player) sender;
  258. if (args.length == 1) {
  259.  
  260. for (Player op : Bukkit.getOnlinePlayers()) {
  261. if(op.getName().equalsIgnoreCase(args[0])){
  262. op.getInventory().addItem(shard2);
  263.  
  264.  
  265. }
  266. }
  267.  
  268. }
  269. else{
  270. p.getInventory().addItem(shard2);
  271. }
  272. }
  273. return true;
  274. }
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement