Solved this Task question..

Discussion in 'Plugin Development' started by Ibas, Aug 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Ibas

    Why does everybody define task if it's in main plugin's class like this:

    Code:java
    1. this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {

    What's the difference between with:
    Code:java
    1. this.
    and without it ?



    Next: If i want to define task in class "drakonasKomanda", but it's not main class. Main class would be funkcijos. So is this defining right:

    Code:java
    1. public class drakonasKomanda implements CommandExecutor {
    2. funkcijos plugin;
    3. public drakonasKomanda(funkcijos plugin) {
    4. this.plugin = plugin;
    5. }
    6. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    7.  
    8. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
     
  2. Offline

    Syd

    1.
    There is no difference, but Eclipse suggests getServer() for you when you use this.

    2.
    This would work, but you could use plugin.getServer().getScheduler()..., too.
    Don't know which one is "better"...

    Btw. Class names should always start with a capital letter.
     
Thread Status:
Not open for further replies.

Share This Page