what is my issue

Discussion in 'Plugin Development' started by NegativeIQ, Jun 27, 2024.

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

    NegativeIQ

    I`ve created a plugin that make cooldown but the cooldown doesn't work.I really need help
    Code:
    public final class Nothing extends JavaPlugin implements Listener {
    
        @Override
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this,this);
            // Plugin startup logic
    
        }
        //Events
        private ArrayList<String> cooldown = new ArrayList<String>();
        public static Nothing plugin = Nothing.plugin;
        @EventHandler
        public void move(PlayerMoveEvent e){
            Player p = e.getPlayer();
    
            if (p.isSprinting()){
                cooldown.add(p.getName());
                getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    
                    public void run() {
                        cooldown.remove(p.getName());
                if (Math.random() * 100 < 10) {
                    p.sendMessage("1");
    
                } else if (Math.random() * 100 < 20) {
                    p.sendMessage("2");
    
                } else {
                    p.sendMessage("3");
    
                }
            }
        },20L);
    
            }
        }
        @Override
        public void onDisable() {
            // Plugin shutdown logic
        }
    }
     
    Last edited: Jun 27, 2024
  2. Offline

    timtower Administrator Administrator Moderator

    @NegativeIQ
    public static Nothing plugin = Nothing.plugin;
    Please remove this, it will only cause issues as you are assigning it to itself.

    And use new BukkitRunnable instead of that scheduler
     
  3. Offline

    NegativeIQ

    sorry i am new in plugins and my question is what runnable can i use instead of this scheduler?
     
  4. Offline

    timtower Administrator Administrator Moderator

    BukkitRunnable, like I said
     
  5. Offline

    NegativeIQ

    thanks alot
     
Thread Status:
Not open for further replies.

Share This Page