Advertisement
Guest User

Untitled

a guest
Feb 15th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.79 KB | None | 0 0
  1. package me.NathanTheDragon.sethealth;
  2.  
  3. import java.util.logging.Logger;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.plugin.PluginDescriptionFile;
  10. import org.bukkit.plugin.PluginManager;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12. import org.bukkit.potion.PotionEffect;
  13. import org.bukkit.potion.PotionEffectType;
  14.  
  15. public class SetHealth extends JavaPlugin{
  16.         public final Logger logger = Logger.getLogger("Minecraft");
  17.         public static SetHealth plugin;
  18.        
  19.         @Override
  20.         public void onDisable() {
  21.                 PluginDescriptionFile pdfFile = this.getDescription();
  22.                 this.logger.info("[" + pdfFile.getName() + "]" + " has been Disabled! Why u leave me D:!");  
  23.         }
  24.        
  25.         @Override
  26.         public void onEnable() {
  27.                 PluginDescriptionFile pdfFile = this.getDescription();
  28.                 this.logger.info("[" + pdfFile.getName() + "]" + " Version " + pdfFile.getVersion() + " has successfully been Enabled! Awesome!");
  29.         }
  30.         public final PluginManager pm =  Bukkit.getServer().getPluginManager();
  31.         public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
  32.         Player player = (Player) sender;
  33.                 if (cmd.getName().equalsIgnoreCase("heal") || cmd.getName().equalsIgnoreCase("h")){
  34.                     if (player.hasPermission("sethealth.heal"))if (player.hasPermission("sethealth.*")) {
  35.                         if (args.length == 0) {
  36.                                 player.setHealth(20);
  37.                                 player.setFireTicks(0);
  38.                                 player.setFoodLevel(20);
  39.                                 for (PotionEffect effect : player.getActivePotionEffects())
  40.                                     player.removePotionEffect(effect.getType());
  41.                                 player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + ChatColor.BOLD + "You have been healed!");;
  42.                                 return true;
  43.                         }
  44.                         Player target = Bukkit.getServer().getPlayer(args[0]);
  45.                         if (target == null) {
  46.                                 player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.RED + " " + ChatColor.BOLD + "The Player isn't on the server!");
  47.                                 return true;
  48.                         }
  49.                         target.setHealth(20);
  50.                         target.setFireTicks(0);
  51.                         target.setFoodLevel(20);
  52.                         for (PotionEffect effect : target.getActivePotionEffects())
  53.                             target.removePotionEffect(effect.getType());
  54.                         target.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + ChatColor.BOLD + "You have been healed by: " + ChatColor.RED + player.getName() + "!");
  55.                         player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + ChatColor.BOLD + "You have healed: " + ChatColor.RED + target.getName() + "!");
  56.                         return true;}
  57.                  if(cmd.getName().equalsIgnoreCase("feed")){
  58.                     if (player.hasPermission("sethealth.feed"))if (player.hasPermission("sethealth.*")) {
  59.                         if (args.length == 0) {
  60.                                 player.setFoodLevel(20);
  61.                                 player.removePotionEffect(PotionEffectType.HUNGER);
  62.                                 player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + ChatColor.BOLD + "You have been fed!");;
  63.                                 return true;
  64.                         }
  65.                         Player target = Bukkit.getServer().getPlayer(args[0]);
  66.                         if (target == null) {
  67.                                 player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.RED + " " + ChatColor.BOLD + "The Player isn't on the server!");
  68.                                 return true;
  69.                         }
  70.                         target.setFoodLevel(20);
  71.                         target.removePotionEffect(PotionEffectType.HUNGER);
  72.                         target.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + ChatColor.BOLD + "You have been fed by: " + ChatColor.RED + player.getName() + "!");
  73.                         player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Health" + ChatColor.WHITE + "]" + ChatColor.GOLD + " " + ChatColor.BOLD + "You have fed: " + ChatColor.RED + target.getName() + "!");
  74.                         return true;}
  75.         }
  76. }
  77.                 return false;
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement