Solved Bukkit runnables not working

Discussion in 'Plugin Development' started by xepisolonxx, Nov 27, 2013.

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

    xepisolonxx

    Everytime my plugin method is called it pops up with error plugin cannot be null can you please help me fix it
    Code:
    public class kitslistener extends JavaPlugin implements Listener{
        Kits plugin;
        public kitslistener(Kits instance) {
    this.plugin = instance;
        }
        public kitslistener() {
            // TODO Auto-generated constructor stub
        }
    

    Code:
    @EventHandler
                public void onAssassin(PlayerInteractEvent event) {
                    final Player e = event.getPlayer();
                    Action a = event.getAction();
                      if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {
                          if (e.getItemInHand().getType() == Material.REDSTONE) {
                      if (Lists.assassinList.contains(e) == true){
                      if (Lists.redstone.contains(e) == false){
                          Lists.redstone.add(e);
                            e.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,30,3));
                            e.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,30,1));
                            e.playSound(e.getLocation(), Sound.ORB_PICKUP, 1, 1);
                       
                                       
                          Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
                                public void run() {
                                    Lists.redstone.remove(e);
                                }
                        }, 200);
                     
                  }else{
                      e.sendMessage(ChatColor.RED + "You cannot use that yet!");
                  }
                      }
                          }
                          }
                      }
    Main class
    Code:
    public void onEnable() {
          PluginManager pm = getServer().getPluginManager();
         
          board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
     
          pm.registerEvents(new Chat(), this);
          pm.registerEvents(new utlities(), this);
          pm.registerEvents(new kitslistener(), this);
          pm.registerEvents(new colorname(), this);
            pm.registerEvents(this,this);
    }
     
  2. Offline

    1Rogue

    Remove the empty constructor in "kitslistener" (and any other class you should be passing a plugin instance to).

    Also don't extend javaplugin in every class.
     
  3. Offline

    xepisolonxx

    So what do i add to my bukkit runnables because it still shows plugin cannot be null

    nvm solved it by myself

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page