Solved Plugin cannot be null

Discussion in 'Plugin Development' started by MRANDOM, Oct 22, 2020.

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

    MRANDOM

    been coding for a while like discord bots and have had a little bit of experience coding plugins and sort of learned java at a very basic level, but yeah im retarded and can't get past this. please excuse my weird names of files.

    MAIN:
    Code:
    package Me.MRANDOM.pp;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    import Me.MRANDOM.pp.commands.weiner;
    
    public class Main extends JavaPlugin {
    
        @Override
        public void onEnable() {
            System.out.println("(!) Good job");
                new weiner(this);
        }
    }
    Weiner command:
    Code:
    package Me.MRANDOM.pp.commands;
    
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.scheduler.BukkitScheduler;
    
    import Me.MRANDOM.pp.Main;
    
    public class weiner implements Listener {
    
        private Main plugin;
      
        public weiner(Main plugin) {
            Bukkit.getPluginManager().registerEvents(this, plugin);
        }
      
        @EventHandler
        public boolean onClick(PlayerInteractEvent event) {
            if(event.getAction() == Action.RIGHT_CLICK_AIR) {
                Player player = (Player) event.getPlayer();
                    BukkitScheduler sched = player.getServer().getScheduler();
                    sched.scheduleSyncDelayedTask(plugin, new Runnable() {
                        @Override
                        public void run() {
                                player.sendMessage("PP");
                        }}, 20L);
            }
            return false;
        }
    }
     
    Last edited by a moderator: Oct 22, 2020
  2. Online

    timtower Administrator Administrator Moderator

    @MRANDOM You never set plugin in the weiner class
     
    MRANDOM likes this.
  3. Offline

    MRANDOM

    i know this is completely unrelated but how do you kill entities
     
  4. Offline

    spuddy

    Not sure if this'll work. I'm not anywhere I can test stuff currently. If you want to just get rid of the Entity without the death animation, you can just call the entity's remove() method.
    Code:
    public void killEntity(Entity e, Entity killer) {
        e.damage(e.getMaxHealth(), killer);
    }
     
    MRANDOM likes this.
  5. Offline

    Strahan

    If you just want it to disappear, entityVariable.remove(); If you want it to visibly die, ((Damageable)entityVariable).setHealth(0);

    Obviously ensure the target entity is Damageable first.
     
    MRANDOM likes this.
Thread Status:
Not open for further replies.

Share This Page