BatchHacker

Simple Java - Minecraft Plugin a command

Jul 21st, 2013
3,439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. package you.yourcode.Command;
  2. //REMEMBER YOU NEED A PLUGIN YML TO LOAD THE COMMANDS!
  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.PluginDescriptionFile;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9. import org.bukkit.potion.PotionEffect;
  10. import org.bukkit.potion.PotionEffectType;
  11.  
  12. public class Command extends JavaPlugin {
  13.  
  14.    
  15.     @Override
  16.     public void onDisable() {
  17.         System.out.println("[Command] Plugin deaktiviert!");
  18.        
  19.     }
  20.    
  21.     @Override
  22.     public void onEnable() {
  23.         //laden von Event Dingsta
  24.         registerEvent();
  25.         PluginDescriptionFile descFile = this.getDescription();
  26.         System.out.println("[Command] Code written by _chunk__");
  27.         System.out.println("[Command] Version: " + descFile.getVersion());
  28.         System.out.println("[Command] Write what you want!");
  29.  
  30.        
  31.     }
  32.    
  33.     public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args){
  34.         boolean erfolg = false;
  35.        
  36.        
  37.        
  38.         Player p = (Player)sender;
  39.        
  40.         if(cmd.getName().equalsIgnoreCase("YOURINGAMECOMMAND")){
  41.             if(args.length == 0){
  42.                 float health = p.getHealth();
  43.                 p.sendMessage(ChatColor.RED + "[Command] " + ChatColor.AQUA + "Deine Gesundheit: " + health);
  44.                 p.setHealth(20);
  45.                 p.sendMessage(ChatColor.RED + "[Command] " + ChatColor.AQUA + "Du wurdest geheilt!");
  46.                 p.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 500, 1));
  47.        
  48.                 erfolg = true;
  49.             }
  50.             else
  51.             {
  52.             erfolg = false;
  53.             }
  54.         }
  55.        
  56.        
  57.    
  58.        
  59.         return erfolg;
  60.     }
  61.    
  62.     //Event-Teil
  63.     private void registerEvent(){
  64.        
  65.     }
  66.    
  67. }
Advertisement
Add Comment
Please, Sign In to add comment