Guest User

SpawnZombies Source Code

a guest
Aug 1st, 2017
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.08 KB | None | 0 0
  1. public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args){       
  2.         if(CommandLabel.equalsIgnoreCase("szspawn")){
  3.             if(!(sender instanceof Player)){
  4.                 sender.sendMessage(ChatColor.DARK_RED + "You must be a player to execute this command!");
  5.                 return false;
  6.             }
  7.             Player p = (Player) sender;
  8.             if(args.length == 2){
  9.                 Player target = Bukkit.getPlayer(args[0]);
  10.                 if(target.isOnline()){
  11.                     if(isInt(args[1])){
  12.                         p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.GREEN + "Spawning Zombies around the target!");
  13.                         target.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.GREEN + "Spawning Zombies around You!");
  14.                         Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  15.                             public void run() {
  16.                                 for(int i = 0; i < Integer.valueOf(args[1]); i++){    
  17.                                
  18.                                     World world = target.getWorld();
  19.                                
  20.                                     Location loc = target.getLocation().add(5, 0, 5);
  21.                                     Location loc1 = target.getLocation().add(-5, 0, 5);
  22.                                     Location loc2 = target.getLocation().add(5, 0, -5);
  23.                                     Location loc3 = target.getLocation().add(-5, 0, -5);
  24.                            
  25.                                     Zombie z1 = (Zombie) world.spawnEntity(loc, EntityType.ZOMBIE);
  26.                                     Zombie z2 = (Zombie) world.spawnEntity(loc1, EntityType.ZOMBIE);
  27.                                     Zombie z3 = (Zombie) world.spawnEntity(loc2, EntityType.ZOMBIE);
  28.                                     Zombie z4 = (Zombie) world.spawnEntity(loc3, EntityType.ZOMBIE);
  29.                                
  30.                                     z1.setTarget(target);
  31.                                     z2.setTarget(target);
  32.                                     z3.setTarget(target);
  33.                                     z4.setTarget(target);
  34.                                     }
  35.                                 }
  36.                             }, 0L, 20L);
  37.                         }else if (!isInt(args[1])){
  38.                             p.sendMessage(ChatColor.GREEN + "Variable <zombies per second> must me a number!");
  39.  
  40.                         }
  41.                     }else if(!target.isOnline()){
  42.                         p.sendMessage(ChatColor.RED + "The target is Offline!");
  43.  
  44.                     }
  45.                 }else if(!(args.length == 2)){
  46.                     p.sendMessage(ChatColor.GREEN + "Usage: /szspawn <target> <zombies per second>");
  47.  
  48.                 }
  49.             }
  50.        
  51.         if(CommandLabel.equalsIgnoreCase("szstart")){
  52.             if(!(sender instanceof Player)){
  53.                 sender.sendMessage(ChatColor.DARK_RED + "You must be a player to execute this command!");
  54.                 return false;
  55.             }
  56.                 Player p = (Player) sender;
  57.                 if(args.length == 2){
  58.                     if(isInt(args[0])){
  59.                         int radius = Integer.valueOf(args[0]);
  60.                             if(isInt(args[1])){
  61.                                 p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.GREEN + "Spawning Zombies around You!");
  62.                                 Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
  63.                                     public void run() {
  64.                                         for(int i = 0; i < Integer.valueOf(args[1]); i++){    
  65.                                        
  66.                                             World w = p.getWorld();
  67.                                            
  68.                                             Location loc = new Location(p.getLocation().getWorld(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
  69.                                              
  70.                                             loc.setX(loc.getX() + Math.random() * radius * 2 - radius);
  71.                                             loc.setZ(loc.getZ() + Math.random() * radius * 2 - radius);
  72.                                             loc.setY(w.getHighestBlockAt(loc.getBlockX(), loc.getBlockZ()).getY());
  73.                                            
  74.                                             w.spawnEntity(loc, EntityType.ZOMBIE);
  75.                                             }
  76.                                         }
  77.                                     }, 0L, 20L);
  78.                                 }else if (!isInt(args[1])){
  79.                                     p.sendMessage(ChatColor.GREEN + "Variable <zombies per second> must be a number!");
  80.  
  81.                                 }
  82.                         }else if(!(isInt(args[0]))){
  83.                             p.sendMessage(ChatColor.GREEN + "Variable <radius> must be a number!");
  84.                         }
  85.                     }else if(!(args.length == 2)){
  86.                         p.sendMessage(ChatColor.GREEN + "Usage: /szstart <radius> <zombies per second>");
  87.                     }
  88.             }
  89.        
  90.         if(CommandLabel.equalsIgnoreCase("szstop")){
  91.             if(!(sender instanceof Player)){
  92.                 sender.sendMessage(ChatColor.DARK_RED + "You must be a player to execute this command!");
  93.                 return false;
  94.             }
  95.             Player p = (Player) sender;
  96.             p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.RED + "Stopped Spawning Zombies around You!");
  97.             Bukkit.getServer().getScheduler().cancelAllTasks();
  98.         }
  99.        
  100.         if(CommandLabel.equalsIgnoreCase("szinfo")){
  101.             if(!(sender instanceof Player)){
  102.                 sender.sendMessage(ChatColor.DARK_RED + "You must be a player to execute this command!");
  103.                 return false;
  104.             }
  105.             Player p = (Player) sender;
  106.             p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "Plugin Made by TrolleDz");
  107.             p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "YouTube: TrolleDz");
  108.             p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "Skype: darkmix13");
  109.             p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "Thank for using SpawnZombies");
  110.         }
  111.        
  112.         if(CommandLabel.equalsIgnoreCase("szboss")){
  113.             if(!(sender instanceof Player)){
  114.                 sender.sendMessage(ChatColor.DARK_RED + "You must be a player to execute this command!");
  115.                 return false;
  116.             }
  117.                 Player p = (Player) sender;
  118.                 Bukkit.broadcastMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "Boss Spawned! :O");
  119.            
  120.                 World world = p.getWorld();
  121.                 Location l = p.getLocation();
  122.            
  123.                 Zombie boss = (Zombie) world.spawnEntity(l, EntityType.ZOMBIE);
  124.                 boss.setCustomName(ChatColor.GRAY + "* " + ChatColor.BOLD + ChatColor.DARK_RED + "Boss" + ChatColor.RESET + ChatColor.GRAY + " *");
  125.                 boss.setCustomNameVisible(true);
  126.                 boss.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 5));
  127.                 boss.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 5));
  128.                 boss.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 999999, 2));
  129.                 boss.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 999999, 10));
  130.                 boss.setMaxHealth(500);
  131.                 boss.setHealth(500);
  132.            
  133.                 for(int i = 0; i < 8; i++) {                   
  134.                     Location location = boss.getLocation().add(5, 0, 5);
  135.                     Zombie z1 = (Zombie) world.spawnEntity(location, EntityType.ZOMBIE);
  136.                     z1.setCustomName("Guard");
  137.                     z1.setCustomNameVisible(true);
  138.                     z1.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
  139.                     z1.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
  140.                     z1.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS));
  141.                     z1.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
  142.                    
  143.                     Location location1 = boss.getLocation().add(-5, 0, 5);
  144.                     Zombie z2 = (Zombie) world.spawnEntity(location1, EntityType.ZOMBIE);
  145.                     z2.setCustomName("Paladin");
  146.                     z2.setCustomNameVisible(true);
  147.                     z2.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
  148.                     z2.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
  149.                     z2.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
  150.                     z2.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
  151.                    
  152.                     Location location2 = boss.getLocation().add(5, 0, -5);
  153.                     Zombie z3 = (Zombie) world.spawnEntity(location2, EntityType.ZOMBIE);
  154.                     z3.setCustomName("Non-Dead Warrior");
  155.                     z3.setCustomNameVisible(true);
  156.                     z3.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
  157.                     z3.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
  158.                     z3.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
  159.                     z3.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
  160.                    
  161.                     Location location3 = boss.getLocation().add(-5, 0, -5);
  162.                     Zombie z4 = (Zombie) world.spawnEntity(location3, EntityType.ZOMBIE);
  163.                     z1.setCustomName("Defender");
  164.                     z1.setCustomNameVisible(true);
  165.                     z4.getEquipment().setHelmet(new ItemStack(Material.GOLD_HELMET));
  166.                     z4.getEquipment().setChestplate(new ItemStack(Material.GOLD_CHESTPLATE));
  167.                     z4.getEquipment().setBoots(new ItemStack(Material.GOLD_BOOTS));
  168.                     z4.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
  169.                     }
  170.                 }
  171.        
  172.         if(CommandLabel.equalsIgnoreCase("szkill")){
  173.             if(!(sender instanceof Player)){
  174.                 sender.sendMessage(ChatColor.DARK_RED + "You must be a player to execute this command!");
  175.                 return false;
  176.             }
  177.             Player p = (Player) sender;
  178.             World w = p.getWorld();
  179.             p.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + "SpawnZombies" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "Killing all the Zombies!");
  180.             List<Entity> entities = w.getEntities();
  181.             for (Entity entity : entities){
  182.                 if(entity.getType() == EntityType.ZOMBIE){
  183.                     entity.remove();
  184.                 }
  185.             }
  186.         }
  187.        
  188.        
  189.         return false;
  190.        }
Advertisement
Add Comment
Please, Sign In to add comment