Keep on crashing

Discussion in 'Plugin Development' started by Albkad, May 30, 2019.

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

    Albkad

    So I keep on crashing every time I place down stone after the repeating task has been activated. I get the message "Stone in area" but crash right after, with no logs or anything. With no stone it works fine.

    Code:
        public void generating(int delay, List<Location> l, Player p, List<Material> bl, Location bloc) {
            task = Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
                @Override
                public void run() {
                    if(ine != 0) {
                       
                        if (!getNBlocks(bloc, 2).contains(Material.STONE)) {
                            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    
                                @Override
                                public void run() {
                                    if (getNBlocks(bloc, 2).contains(Material.STONE)) {
                                        p.sendMessage("Stone in area");
                                        int r = new Random().nextInt(123);
                                        if (l.get(r).getBlock().getType() == Material.STONE) {
                                            l.get(r).getBlock().setType(Material.EMERALD_ORE);
                                        } else {
                                            while (l.get(r).getBlock().getType() != Material.STONE) {
                                                r = new Random().nextInt(123);
                                                if (l.get(r).getBlock().getType() == Material.STONE) {
                                                    l.get(r).getBlock().setType(Material.EMERALD_ORE);
                                                }
                                            }
                                        }
                                        ine--;
                                        return;
                                    }
                                    p.sendMessage("No stone in area!");
                                }
                               
                            }, 100, 100);
     
  2. Online

    timtower Moderator Moderator

    @Albkad Get rid of the while loop.
     
  3. Offline

    Albkad

    The while loop isnt the problem. When taken out the same thing happens. Something seems to be starting an infinite loop that keeps on crashing. because the server cant be stopped or reloaded, and no commands are usable.
     
  4. Online

    timtower Moderator Moderator

    Normally that is the work of a while loop.
    If you need one for this then you are doing it wrong
    Post the full class please
     
Thread Status:
Not open for further replies.

Share This Page