create commands bukkit code example

Example 1: bukkit register commands

public class main {
  @Override
  public void onEnable() {
      this.getCommand("heal").setExecuter(new health(this));
      //E.g a heal command in class health
      // this.getCommand("heal").setExecture(new health(this))

      //If command in main class replace new <class>() with this.
      // this.getCommand("heal").setExecuter(this)
  }
}

//If in external class a constructor has to be made.
public class health {
  private main plugin;
  //Have to create constructor in external class
  public health(main plugin) { this.plugin = plugin; }  
  
  public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) { 
  	//Do stuff
  }
  
}

Example 2: Java Bukkit

Basics 1:
- Java Plugin implementieren:
	
	public void Main extends JavaPlugin{
    }

- Wenn Aktiviert (onEnbale) Methode erstellen:

	public void Main extends JavaPlugin{
      
     	public void onEnable(){
      	}
    }

- Konsolen anzeige in onEnable Methode:

	public void Main extends JavaPlugin{
      
     	public void onEnable(){
          System.out.println("Das Plugin wurde aktiviert.");
      	}
    }

Tags:

Java Example