Why is this laggin/crashing my server.

Discussion in 'Plugin Development' started by MinecraftMart, Mar 8, 2015.

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


    Is it because when i have 1 location i spawn 2 stacks of bottles at once? Or because of a leak or something.

                List<Player> onlinePlayers = new ArrayList<Player>();
                for(Player p : Bukkit.getOnlinePlayers()){
                int amountXpOrbs = (128 * onlinePlayers.size()) / main.locations.size();
                String world = player.getWorld().getName();
                for(Location l : main.locations){
                    for(int x = 0; x < amountXpOrbs; x =+1){
                        Bukkit.getWorld(world).spawn(l, ExperienceOrb.class);
  2. Offline


    Maybe because you're spawning 128 experience orbs per location, per player. Not to mention adding all the online players to a new collection for no reason. As well as retrieving the world by name for every single orb when you already have a reference available via player.getWorld()
Thread Status:
Not open for further replies.

Share This Page