nrubin29

Disguiser.java

Jul 28th, 2013
2,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. package me.pogostick29.disguiser;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8. import pgDev.bukkit.DisguiseCraft.DisguiseCraft;
  9. import pgDev.bukkit.DisguiseCraft.api.DisguiseCraftAPI;
  10. import pgDev.bukkit.DisguiseCraft.disguise.Disguise;
  11. import pgDev.bukkit.DisguiseCraft.disguise.DisguiseType;
  12.  
  13. public class Disguiser extends JavaPlugin {
  14.  
  15.     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  16.         if (!(sender instanceof Player)) {
  17.             sender.sendMessage(ChatColor.RED + "You cannot disguise yourself!");
  18.             return true;
  19.         }
  20.  
  21.         Player p = (Player) sender;
  22.  
  23.         if (command.getName().equalsIgnoreCase("disguiser")) {
  24.             if (args.length == 0) {
  25.                 p.sendMessage(ChatColor.RED + "Please specify an entity type!");
  26.                 return true;
  27.             }
  28.  
  29.             DisguiseType type = getDisguiseType(args[0]);
  30.  
  31.             if (type == null) {
  32.                 p.sendMessage(ChatColor.RED + "You specified an invalid disguise type.");
  33.                 return true;
  34.             }
  35.  
  36.             DisguiseCraftAPI api = DisguiseCraft.getAPI();
  37.  
  38.             api.disguisePlayer(p, new Disguise(api.newEntityID(), type));
  39.             p.sendMessage(ChatColor.GREEN + "You have been disguised as a(n) " + type.toString().toLowerCase() + "!");
  40.         }
  41.         return true;
  42.     }
  43.  
  44.     private DisguiseType getDisguiseType(String arg) {
  45.         for (DisguiseType type : DisguiseType.values()) {
  46.             String t = type.toString().toUpperCase();
  47.             if (arg.toUpperCase().equalsIgnoreCase(t)) return type;
  48.         }
  49.         return null;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment