Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. // /mob mob amount
  2. package me.bribbs.ezmobs;
  3.  
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.EntityType;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. import net.md_5.bungee.api.ChatColor;
  11.  
  12. public class Mob extends JavaPlugin {
  13.  
  14. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  15. if (!(sender instanceof Player)) {
  16. sender.sendMessage(ChatColor.RED + "You must be a player to use this command");
  17. return true;
  18. }
  19.  
  20. int amount = 1;
  21.  
  22. if (args.length == 2) {
  23. try {
  24. amount = Integer.parseInt(args[1]);
  25. }
  26.  
  27. catch (Exception e) {
  28. sender.sendMessage("Invalid Amount");
  29. return true;
  30. }
  31. }
  32.  
  33. Player p = (Player) sender;
  34. try {
  35. for (int i = 0; i < amount; i++)
  36. p.getLocation().getWorld().spawnEntity(p.getLocation(), EntityType.valueOf(args[0].toUpperCase()));
  37. } catch (Exception e) {
  38. sender.sendMessage("Invalid Entity");
  39. }
  40. return true;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement