all item drops

Discussion in 'Spigot Plugin Development' started by canadianeggnog, May 2, 2015.

  1. how could i remove all items dropped on the floor in my onDisable method in my main class? thanks
     
  2. gigosaurus

    Supporter

    Depending on if you have multiple worlds or not, the outer for loop might not be needed
    Code (Java):

    for (World world : Bukkit.getWorlds()) {
        for (Entity entity : world.getEntities()) {
            if (entity instanceof Item) {
                entity.remove();
            }
        }
    }
     
     
    #2 gigosaurus, May 2, 2015
    Last edited: May 2, 2015
    • Informative Informative x 1
  3. so simple thanks