Solved Need help with getServer() used with a scheduleSyncRepeatingTask.

Discussion in 'Plugin Development' started by KayoticCrafting, Feb 7, 2016.

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

    KayoticCrafting

    Code:
    public void onPlayerMove(PlayerMoveEvent e) {
            Player player = e.getPlayer();
            if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
                getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    
                    @Override
                    public void run() {
                        if (number != -1) {
                            if (number != 0) {
                                number--;
                            } else {
                                int r = (int) (Math.random() * 100);
                                if (r < 33) {
                                    player.sendMessage(ChatColor.RED + "You shoulda seen the look on your face!");
                                } else if (r < 66) {
                                    player.sendMessage(ChatColor.RED + "I'm embarrassed just from watching...");
                                } else {
                                    player.sendMessage(ChatColor.RED + "Wow, that was bad.");
                                }
                            }
                        }
                    }
    
                }, 0L, 300L);
            }
        }
     
    Last edited by a moderator: Feb 7, 2016
  2. Offline

    teej107

  3. Offline

    KayoticCrafting

    I would appreciate it if you could just answer thanks.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @KayoticCrafting Well, you aren't really asking a question.
    Added code tags.
     
  5. Offline

    KayoticCrafting

    Well here's the thing, getServer() isnt working and i was wondering if there was a certain way to make it work.
     
  6. Offline

    Xerox262

    @KayoticCrafting getServer is a JavaPlugin method, either call it from your JavaPlugin class or use Bukkit.getServer() instead.
     
  7. Offline

    KayoticCrafting

    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page