Godleydemon

tinclCommandExecutor.java

Feb 3rd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.41 KB | None | 0 0
  1. package com.github.thestuntman.TINCL;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Location;
  6. import org.bukkit.World;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.*;
  11. import org.bukkit.potion.PotionEffect;
  12. import org.bukkit.potion.PotionEffectType;
  13.  
  14. import java.util.List;
  15. import java.util.Locale;
  16.  
  17. /**
  18.  * Created by The_Stuntman on 1/31/14.
  19.  */
  20. public class tinclCommandExecutor implements CommandExecutor {
  21.  
  22.  
  23.  
  24.     private Main plugin;
  25.  
  26.     public tinclCommandExecutor(Main plugin) {
  27.         this.plugin = plugin;
  28.     }
  29.  
  30.     @Override
  31.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  32.         Player TargetPlayer = null;
  33.         Player player = (Player) sender;
  34.  
  35.  
  36.         if (args.length == 0)
  37.         {
  38.             sender.sendMessage(ChatColor.RED + "Syntax is /tincl help,info");
  39.             return true;
  40.         }
  41.         switch(args[0].toLowerCase(Locale.ENGLISH))
  42.         {
  43.             case "help":
  44.                 player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.YELLOW + "/tincl - Show the command syntax");
  45.                 player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.YELLOW + "/tincl help - view tincl commands");
  46.                 player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.YELLOW + "/tincl swarm [playername] - spawn angry chicken on targetted player");
  47.                 player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.YELLOW + "/tincl info - helpful info");
  48.                 break;
  49.             case "info":
  50.                 player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.DARK_PURPLE + "There is no Chicken Level");
  51.                 player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.DARK_PURPLE + "Created by:  The_Stuntman");
  52.                 break;
  53.             case "swarm":
  54.                 if(!player.hasPermission("swarm.tincl")){
  55.                     player.sendMessage(ChatColor.RED + "You do not have permission to perform this command");
  56.                 }else{
  57.                     if (args.length > 1){
  58.                         TargetPlayer = Bukkit.getServer().getPlayer(args[1]);
  59.                         World world = TargetPlayer.getWorld();
  60.                         Location TargetLocation = TargetPlayer.getLocation();
  61.                         TargetPlayer.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.YELLOW + "An Evil Chicken has attacked you!");
  62.                         Entity chicken = world.spawnEntity(TargetLocation, EntityType.CHICKEN);
  63.                         Entity zombie = world.spawnEntity(TargetLocation, EntityType.ZOMBIE);
  64.  
  65.                         zombie.setPassenger(chicken);
  66.                         tinclListener.zombieIds.add(zombie.getEntityId()+"");
  67.                         tinclListener.chickenIds.add(chicken.getEntityId()+"");
  68.  
  69.                         double radius = 3D;
  70.                         List<Entity> near = TargetLocation.getWorld().getEntities();
  71.                         for(Entity e : near) {
  72.                             if(e.getLocation().distance(TargetLocation) <= radius && e instanceof Zombie)
  73.                             {
  74.                                 Zombie zombiecart = (Zombie) e;
  75.                                 ((Zombie) e).setBaby(true);
  76.                                 zombiecart.setBaby(true);
  77.                                 zombiecart.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1));
  78.                             }
  79.  
  80.                             if(e.getLocation().distance(TargetLocation) <= radius && e instanceof Chicken)
  81.                             {
  82.                                 Chicken evilchicken = (Chicken) e;
  83.                                 evilchicken.setCustomName(ChatColor.RED + "Evil Chicken");
  84.                                 evilchicken.setCustomNameVisible(true);
  85.                             }
  86.  
  87.                         }
  88.                     }else{
  89.                         player.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.RED + "you need to target a player!");
  90.                         }
  91.                     break;
  92.                     }
  93.             default:
  94.                 sender.sendMessage(ChatColor.DARK_GREEN + "[TINCL]" + ChatColor.RED + "Invalid Syntax");
  95.     }
  96.  
  97.  
  98.         return true;
  99. }
  100.     }
Advertisement
Add Comment
Please, Sign In to add comment