Inactive [FIX/ADMN] NoLagg v1.88.1 - Prevent common lag causes on your server [2338]

Discussion in 'Inactive/Unsupported Plugins' started by bergerkiller, Sep 17, 2011.

  1. Offline


    I had already made this plugin before after having a major lag issue. (lots of torches being filled, turned into items, lag for 20 minutes) It also works for 1060.

    Some feature ideas are taken over from PerformanceTweaks by @LexManos so some credit goes to him. Code, however, written from scratch by me. :)


    If you get a warning message [NoLagg TLN] followed up with a stack trace in the log, this has to do with the main thread not having responded within 10 seconds. When a plugin takes more than this time to enable, it will show that. The warning is NOT an error and is no bug, and not a bug related to NoLagg. To disable this feature, disable 'threadlocknotifier' in the config.yml. This feature is mainly intended to notify you what plugin is causing the server to freeze, may it ever happen. It is used to debug plugins in general, as they may get stuck for whatever reason.

    NoLagg's features in a nutshell


    Prevent lag caused by many items

    Every time an item gets spawned, it is buffered per chunk. For example, you spawn 30 items using Q and the maximum allowed items per chunk is 20, then the 10 remaining items are not spawned. They are spawned as soon the item count in this chunk is < 20 again.


    Form item stacks - fully automatically

    Whenever two or more (configurable) items or experience orbs get near each other, they form a single stack of that item type. If someone drops 64 dirt blocks on the ground using Q, it will show a single item of 64 dirt instead.


    Prevent lag caused by TNT

    This plugin takes over tnt ignition caused by explosions. When exploding stacks of tnt, it does not rush all tnts into a single tick, but detonate them nicely in sync. This results in pretty awesome fireworks. :)


    Prevent lag caused by lighting glitches

    Whenever a new chunk is generated, it's lighting information is generated and all nearby players receive the updated chunk data. If the auto-method fails, you can use /nolagg fix to do it manually. This fixing fixes, for example, dark spots in and around caves lagging the client.


    Set entity spawn limits

    You can set a spawn limit on virtually every entity in the game. From mobs to items to TNT. Only thing being excluded is Players, since I can't simply kick someone 'like that'. :)
    Note: It removes already spawned entities too. So, if you want to keep your animals alive, don't set mob or animal limits, or it will possibly clear your farm animals. (or you can disable the spawn limiter all together)

    I recommend finding an alternative plugin for this instead. Removing entities after they are spawned causes more lag than it prevents!

    Global auto-saver

    Since asynchronous chunk saving is now implemented internally, it is no longer a problem to save entire worlds frequently. You can set auto-save intervals in the configuration. If used with an interval higher than 400 ticks (20 seconds) it will use a scheduled task instead of the internal saver to prevent chunks never getting saved. Another benefit is that player information is also auto-saved, preventing your players losing their inventory state.

    New chunk sending mechanics

    Instead of loading chunks all around the player, the player direction is used to load the visible chunks first. This means that players can expect chunks in front of them to load quickly, while chunks on the sides take a bit longer to appear. When the player looks into another direction, the direction changes and thus the new visible chunks get loaded first. Only if all chunks ahead of the player are loaded, chunks around the player are sent. This all can be configured using a simple minimum and maximum sending rate.


    Examining the server tick rate

    If you encounter very low tick rates and you want to find out what plugin is causing it, you can use the examine component to find it out. It comes with a graphic viewer, which makes bug tracking the easiest thing ever.


    Prevent cross-thread access for events

    As it seems, some plugins don't follow the rules and use Bukkit methods in another thread. This plugin will notify you and cancel if possible whenever this happens so other plugins understand their mistake. If you encounter a lot of spam in the console, first check the stack trace for the plugin that caused the error. Report this error to the author or remove the plugin, if you have questions you are free to ask.

    Configuration (on BukkitDev)

    Commands and Permissions (on BukkitDev)

    Synchronized code accessed by another thread? (BukkitDev)


    Video by brandcool86


    - Help I experience missing chunks
    If you are using Spout, don't use Reloads. This is also the reason why Spout added a warning when a player tries to reload the server. Not using Spout, then it's a bug which you can report.

    - Can this plugin be used with PTweaks
    (this message was really old...) Yes, they are compatible, but if certain features overlap, make sure you disable these features in either plugin.

    - I get a warning about the async auto save and interval. Wat do?
    Change the autoSaveInterval value in the configuration to a value higher than 400, like 600. The warning is to prevent endless autosaves to occur, clogging up CPU.

    - I have experienced CPU usage
    CPU usage is not the same as lag. NoLagg uses multiple (2-3) extra threads to prevent tick and network lag. If a lot has to be done, it does this quicker, but this takes more CPU obviously.

    - I have lag when using NoLagg
    See also the FAQ above. Explain what type of lag you have: tick lag, client lag, network lag and/or 'block placement' lag. You can use /nolagg monitor to check the tick rate. If this is normal (>15), then you have network lag. Client lag is when the FPS drops. Block placement lag is lag when the tick rate is normal and other network messages, like chat, are instant.

    - WorldEdit causes lag...
    YES because it is unsafe to take over the main thread while another plugin is having hold over it. I can try fixing this, but it could ultimately lead to some serious concurrency exceptions. Don't expect this to be implemented very soon...

    - Do spawn limits interfere with mob-spawning plugins like MobArena?
    No, it does not. It only limits mobs spawned by 'nature': all custom creature spawns are ignored throughout the run of the plugin. Only after you reload will it lose track of these entities and will it remove custom-spawned mobs. If you use MobArena, be sure nothing is going on when you reload the server.

    - Does item stacking interfere with Showcase or BleedingMobs?
    It supports Showcase and ShowcaseStandalone entirely. (showcased items are completely ignored at all times) The same applies to the 'particles' created by the BleedingMobs plugin. Know of a plugin where it stacks items which should not be stacked? Post the plugin name so I can add support. You are an owner and want to add support? Only having a function in your plugin to check if an item is 'ignored' is enough.

    - Can this plugin be used with Chunk Manager
    If you want to use the Chunk Manager with Nolagg, disable the chunk sending of Nolagg first. If you don't do that, this plugin will do that by itself and send a warning in the log. Of course, compare the results first. :)

    - What are the best settings if I have a lot of RAM memory?
    This plugin does not deal with reduced RAM memory. If I could, I would, but you simply can't reduce the amount of memory Java uses. This data is locked and secured, so I can't simply throw away bits of data or write and read data from/to disk. Any plugin claiming to reduce RAM usage on a server, is probably 'garbage collecting'. This fakes having less RAM usage by removing unused data, but Java does this by itself as well once it hits a certain limit. All these plugins will do is make the Garbage Collector run in overdrive, which will only kill your tick rate and/or CPU speeds. A bad thing.

    - I get a lot of 'Synchronized code accessed from another thread' errors
    Find out what plugin is acting up by inspecting the stack trace. If the plugin that causes this is inactive, all you can do is wait for a refurnished version or someone to fix it for you, or use an alternative plugin. If it's still under development, notify the author of this, it IS an error caused by that plugin. If you can't find out the cause, PM me or post in this thread.

    Before you begin writing a lag issue

    This is very important, just posting a 'it causuz lagz und shitz' won't do, won't help and I won't be able to help you any further either. Question is if I even want to help you, if you post such a message without anything worth looking at. Things to include in your message:
    - Errors in the log if possible
    - What CB version you use and what NoLagg version you use
    - When this lag occurs. Tick rate drop in general?
    - The configuration you used when running this plugin
    - What type of lag if applicable. Options are: tick lag, client lag, network lag (see above)

    Important links

    NoLagg Download page and others at Dev Bukkit
    View the source code of NoLagg at GitHub

    Use an archive extracting program (WinRar, WinZip) to open the archive.

    - Add option to disable physics when the tick delay becomes too high


    Show your appreciation for my plugins by donating
  2. Offline


    Now one question, I run a mob arena. Will this effect my mob arena as it spawns waves of mobs?
  3. Offline


    @Eminam nope, that is why I ignore custom spawned creatures.

    Do note that a reload will probably wipe custom spawned mobs anyway.
  4. Offline


    If it's possible. Can you make it to where it limits just monster spawner spawned mobs, and naturally spawning mobs when its dark and so on. If it ignores mobs spawned inside an arena like mob arena, I'd like to keep it that way.

    The reload I'm not worried about as the Mob arena has to be started before mobs are spawned anyways lol so it's all good. Just a limit on naturally spawning mobs and monster spawner spawned mobs is really all i need.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 19, 2016
  5. Offline


    Hi bergerkiller. Here's a new one for you.
    15:20:11 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-1067-g6301507-b1185jnks (MC: 1.8.1)
    15:20:22 [INFO] [NoLagg] Auto-save field bound to 'u'!
    15:20:22 [INFO] NoLagg version 1.22 is enabled!
    15:20:22 [INFO] [NoLagg] chunk handler add-on version 1.01 is enabled!
    15:20:22 [INFO] [NoLagg] 1 chunk packets will be sent every 1 ticks.
    15:31:40 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?
    15:31:40 [WARNING] Task of 'NoLaggChunks' generated an exception
    java.lang.NoSuchMethodError: com.bergerkiller.bukkit.nolagg.ChunkHandler.send(IILorg/bukkit/entity/Player;)Z
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.sendAll(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader$
        at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(
        at net.minecraft.server.MinecraftServer.h(
    15:31:40 [WARNING] Task of 'NoLaggChunks' generated an exception
    java.lang.NoSuchMethodError: com.bergerkiller.bukkit.nolagg.ChunkHandler.send(IILorg/bukkit/entity/Player;)Z
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.send(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.sendAll(
        at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader$
        at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(
        at net.minecraft.server.MinecraftServer.h(
    15:31:47 [INFO] Player Respawning
    15:31:50 [WARNING] xxxxxxxxx was kicked for floating too long!
  6. Offline


    @Zathras make sure you use the latest NoLagg version, it appears you got an old one. (v1.22 to be precise, you need v1.23)
  7. Offline


    So this is what it will do as of 1.23? and whats the deal with the addon. is it stable enough to use as of now?
  8. Offline


    can i have this paralell to ptweaks?
  9. Offline


    Whats up?
    2011-10-01 22:13:42 [SEVERE] Could not load 'plugins/NoLaggChunks.jar' in folder 'plugins': NoLagg
    org.bukkit.plugin.UnknownDependencyException: NoLagg
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(
    at org.bukkit.craftbukkit.CraftServer.<init>(
    at net.minecraft.server.ServerConfigurationManager.<init>(
    at net.minecraft.server.MinecraftServer.init(
  10. Offline


    I know why it does it now with essentials. When using e in front of commands. IE /eban it FORCES essentials to take control causing issues. Try using a different letter in front of it. Something like /zban or something
  11. Offline


    @Zone to use the Addon you obviously need NoLagg too. :)
    The Addon uses the configuration and some chunk handling code from NoLagg, so it IS required.

    Also, I'll upload 1.24. Got kinda into MyWorlds now...desperately fixing the redstone issues when changing/locking the time...
  12. Offline


    nevermind. Anyone who has this problem its because you need to update to 2.6.2 essentials
  13. Offline


    @bergerkiller OK I've got 1.24 now. Thanks!
  14. Offline


    Can you explain the coding of your plugin in terms of chunk management?
    It's currently having problems with my plugin

    I basically get the packet from spout's packet listener, if it belongs to Packet51MapChunk, cancel it, send it in a separate thread.
    I don't quite understand your technique of managing chunk sending.

    Source code goes here:
  15. Offline


    Note that Spout has an internal issue where it fails to load chunks, not related to NoLagg.
    If you encounter the following error:
    Post it in the Spout thread. This happens when you fly into unloaded chunks way too fast, and for some reason the entity list gets out of sync.


    @lishid What I do is cancel the initial chunk being sent in the packetlistener and mark this chunk 'need to unload' for the Player specified in the PlayerChunkLoader. This marking consists of a HashSet containing my own Chunk pairs, which implement the HashCode. When marking you simply remove it from this 'sent' list. The same happens when the player changes chunks.

    Here the full code (prepare your brainz)
    PlayerChunkLoader - Contains a scheduled task sending chunks to all players. Pretty complicated, since it contains algorithmic formulas. What you need to look for is the send functions, one of them send a single chunk to a player.


    Coding where chunks are actually sent (in NoLagg)

    in short:
    - packet being sent for entire chunk? Schedule it by marking it not sent
    - player changed chunks? Remove chunks from sent if no longer in range
    - send(rate) for all players in scheduled task, which handles the sending
    - allow the chunk to pass through the listener - send - deny again
  16. Offline


  17. Offline


    I updated my prev post to add the chunk sending functions in NoLagg.

    Also, I use this:
                net.minecraft.server.World world = ((CraftWorld) to.getWorld()).getHandle();
                Packet51MapChunk packet = new Packet51MapChunk(cx * 16, 0, cz * 16, 16, 128, 16, world);
                net.minecraft.server.Chunk chunk = world.getChunkAt(cx, cz);
                NetServerHandler handler = ((CraftPlayer) to).getHandle().netServerHandler;
                //Send pre-chunk
                handler.sendPacket(new Packet50PreChunk(cx * 16, cz * 16, true));
                //Send chunk
                //Send entities
                for (Object o : chunk.tileEntities.values()) {
                    TileEntity entity = (TileEntity) o;
    To keep it non-Spout compatible in some way. Since the netserverHandler gets replaced by Spout, Spout should handle it in the end. Do need to know if it worked out correctly. I'll look for some conflicts too.


    Found one possible issue. If your coding gets executed 1 tick after mine, my packetlistener is denying new chunks, generating a new chunk which your plugin handles again, infinite loop there. Unless the handler.sendPacket(mappacket) is calling your coding instantly, there could be an issue.
  18. Offline


    Okay, after reading your source, I don't seem to see any conflict. When you send the packet, you actually return true in your packet listener, which will then go to mine (probably). But I still don't understand why people reports to have no chunks being loaded when our plugins are both installed...

    Weird, when you use spout's packet listener, what happens is that it calls all the listeners and then queue that to network manager. I don't see an issue there because you set allow to false after the sendPacket code gets executed.

    Also, my plugin send directly to NetworkManager, which means it doesn't get touched by spout afterwards.

    Hm... Is it possible that your code on Github isn't newest? :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 19, 2016
  19. Offline


    @lishid yup. I can't seem to merge NoLagg and NoLaggChunks together on one repository, it's a pain. :/

    Any idea how I can push two projects into the same repository?

    Committed the 1/24 of NoLagg now.

    Also, you can open NoLaggChunks in Winrar, the source java files are there next to the class files.
  20. Offline


    I don't know, what are you using to build them?
    I use Eclipse to build, and I just export to a jar file.
  21. Offline


    @lishid the problem is not exporting, it is pushing it to GitHub. It starts complaining about me having to pull the project to properly push to NoLagg...but I obviously don't want the two projects mixed up. Or do I...

    Maybe the solution is easier than I thought. :)
  22. Offline


    Yes, you need to pull before doing anything, just backup, Pull, replace, commit and push.

    EDIT: Any idea for our plugin's conflict?
  23. Offline


    Still getting player_move errors..

    04:35:39 [SEVERE] Could not pass event PLAYER_MOVE to NoLaggChunks
            at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
            at java.util.HashMap$ Source)
            at java.util.AbstractCollection.toArray(Unknown Source)
            at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.updateChunk(
            at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.update(
            at com.bergerkiller.bukkit.nolaggchunks.NLPlayerListener.onPlayerMove(
            at org.bukkit.plugin.RegisteredListener.callEvent(
            at org.bukkit.plugin.SimplePluginManager.callEvent(
            at net.minecraft.server.NetServerHandler.a(
            at org.getspout.spout.SpoutNetServerHandler.a(
            at net.minecraft.server.Packet10Flying.a(SourceFile:126)
            at net.minecraft.server.NetworkManager.b(
            at net.minecraft.server.NetServerHandler.a(
            at org.getspout.spout.SpoutNetServerHandler.a(
            at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
            at net.minecraft.server.MinecraftServer.h(
    Using the RB of Spout, AutoCraft, BlockDispenser, CommandBook, ControllerBlock, PistonsExtended, WeatherRestrictions, and WorldEdit.
  24. Offline


    @lishid not really, and I'm going to bed now. Will see tomorrow. :)

    @QQCucumber Ok I'm confused...there's no possible way this is happening lol...
    Time for iterator extreme? Iterator extreme it is...
    Chunk[] from = sentChunks.toArray(new Chunk[0]);
    And here a concurrentmodification exception? HOW....
  25. Offline


    multiple threads access same field.
  26. Offline


    So is the add on alright for spout servers that dont restrict it?
  27. Offline

    justin shulman

    can you make it so wee can only enable the things we want to. Plus you should add something to prevent redstone clocks
  28. Offline


    Wow I just have to say after reading your source code I could only wish notch was that clean then maybe we would not have fps issue and bug after bug updates. On a side note your advice did the trick with the chunks I set my interval to 8 as I host from home but is has been stable in the past for 20 players ;), But using this plugin and your other wonderful plugins that I am actually planning on doing a playthru about in the near future are a god send for all servers, really man they are truly a step in the right direction to curing this bandwidth usage issue.

    A bit of a side note I am about to see if the Anti Xray works in a min and update your latest versions again., Also I think I may have a solution that will solve the custom mob spawn issues everyone are talking about. My solution would be actually pretty darn simple but in practice I have no idea how to code it. I would simply add a listener event for plugin load then in config the user would define plugins for nolagg to completely pass thru and ignore. This way arena plugins or class skills and the like would bypass this nolagg and nolagg will completely ignore what they spawn and what there doing.

    The way I understand every custom mobtype being created by a plugin would have the plugin tag called in the at the start of the spawn event. So in theory all you would have do was listen for it and add it to a list of ignored for persistence reasons and you have your self a method for people to define what nolagg should not focus on cleaning up.

    Oh and did you say you updated the info on the first page for myworlds to show the config options for the worlds file ?, if so I can't find them and I just want to assign a generator.

    What did you do in that last fix coz you broke it again for me, I have the sendrate:1 and the interval:8 worked fine last versions it was what I would call close to perfect, now the physics failed on me again and the black holes. Now we are getting

    2011-10-02 17:33:43 [INFO] stobess lost connection: disconnect.overflow
    2011-10-02 17:33:43 [INFO] MCBans: stobess has disconnected!
    2011-10-02 17:33:44 [INFO] Connection reset
    2011-10-02 17:33:44 [INFO] ledhead900 lost connection: disconnect.overflow

    I have a request this time :p.

    Could you change how the mob limit is handled so that it physically stops spawning of new mobs past the limit instead of what I currently see it doing, Removing mobs as they spawn causing the trickery I see when mobs are despawned in front of me. Once this chunk mess is sorted out the mob limit is the only beef I have left about the way this works.
  29. Offline


    Would you make plaugin for me?
    I only want function that entity spawn limits.
    Please ... ^^;;;
  30. Offline


    @lishid aah so that explains a lot. :)
    I bet Spout's packet listener runs in a separate thread...time to add some checks against this.

    Also, it is kinda weird that it removes mobs previously spawned when the limit is reached. It shouldn't even allow the new mobs to spawn once the limit is how can it remove already spawned mobs?

    @ledhead900 could you run an offline server so I can see what is going on, in detail? posting your entire config.yml could help too. :)

    I'll make the packet sender async and make the hashset contained multi-threading proof to fix that modification error.


    Ooookkkaay...this explains a lot. :)
    Now I made the chunk sending thread async, and made certain methods synchronized, it works even better! I can run it with an interval of 3 and I haven't encountered much issues.

    Could be it was locking up, causing the black holes issue...
  31. Offline


    Now with this fix i will try this again, can i have ptweaks and this? Wath can i disable so both dont do the same thing?

Share This Page