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

    bergerkiller

    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. :)

    Important:

    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

    Description

    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.

    Read more...

    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.

    Read more...

    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. :)

    Read more...

    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.

    Read more...

    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.

    Read more...

    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.

    Read more...

    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)



    Media



    Video by brandcool86


    FAQ

    - 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.

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

    Changelog

    Show your appreciation for my plugins by donating
    [​IMG]
     
  2. Offline

    rtcabooservb

    @bergerkiller
    Yeah, please fix the beta holes on chunk update (teleporting, /home, /spawn) with CB 1303 and spout 435. :( I tried essentials, craftbook, various other plugins, and still get beta holes with the addon plugin.
     
  3. Offline

    Sk8Sanctified

    Newer update works good, nice work.
     
  4. Offline

    Borch

    @bergerkiller Wow, 1.3 works perfectly with unload delay set to 2 mins wrt unloaded chunks. :)
    However, in the 2:40 hours I'm running it now I had 3 false positives on flying when the affected players were just walking around. If it stays at this rate it would be acceptable for me, but still wanted to let you know that it definitely has something to do with the unload delay at least in my case. Could it be that a chunk gets unloaded while a player is standing on it, so the server thinks there is nothing, while the player still sees the chunk?
    As far as I understand the previous issue with the unloaded chunks was caused by something like this, but there it also unloaded the chunk client side, so no idea if it is possible that the chunk gets unloaded on the server while the client still displays it.
    But still, great improvement over the previous build for me!
     
  5. Offline

    kawiz

    gah. just updated and getting this:

    Code:
    23:54:57 [SEVERE] java.net.SocketException: Socket closed
    23:54:57 [SEVERE] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
    23:54:57 [SEVERE] at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    23:54:57 [SEVERE] at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
    23:54:57 [SEVERE] at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
    23:54:57 [SEVERE] at java.io.DataOutputStream.flush(DataOutputStream.java:106)
    23:54:57 [SEVERE] at net.minecraft.server.NetworkWriterThread.run(SourceFile:104)
     
  6. Offline

    Adrenaline

    mhm?

    1.
    PHP:
    2011-10-09 06:49:01 [INFOChunk file at 18,31 is in the wrong locationrelocating. (Expected 1831got 1125)
    2011-10-09 06:49:01 [INFOChunk (1125stored at  (1831)
    2011-10-09 06:49:01 [SEVEREjava.lang.Throwable
    2011
    -10-09 06:49:01 [SEVERE]     at org.bukkit.craftbukkit.util.LongHashtable.put(LongHashtable.java:19)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:77)
    2011-10-09 06:49:01 [SEVERE]     at org.bukkit.craftbukkit.CraftWorld.getChunkAt(CraftWorld.java:98)
    2011-10-09 06:49:01 [SEVERE]     at performancetweaks.bin.org.jbls.mrchasez.ChunkPersistance.onPlayerMove(ChunkPersistance.java:127)
    2011-10-09 06:49:01 [SEVERE]     at performancetweaks.bin.org.jbls.mrchasez.events.MPlayerListener.onPlayerMove(MPlayerListener.java:17)
    2011-10-09 06:49:01 [SEVERE]     at org.bukkit.plugin.java.JavaPluginLoader$7.execute(JavaPluginLoader.java:286)
    2011-10-09 06:49:01 [SEVERE]     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    2011-10-09 06:49:01 [SEVERE]     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:180)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.Packet10Flying.a(SourceFile:126)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:92)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:471)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    2011-10-09 06:49:01 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)

    2.
    PHP:
    2011-10-09 06:22:53 [INFOChunk (1125stored at  (1831)
    2011-10-09 06:22:53 [SEVEREjava.lang.Throwable
    2011
    -10-09 06:22:53 [SEVERE]     at org.bukkit.craftbukkit.util.LongHashtable.get(LongHashtable.java:32)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:62)
    2011-10-09 06:22:53 [SEVERE]     at org.bukkit.craftbukkit.CraftWorld.getChunkAt(CraftWorld.java:98)
    2011-10-09 06:22:53 [SEVERE]     at performancetweaks.bin.org.jbls.mrchasez.ChunkPersistance.onPlayerMove(ChunkPersistance.java:127)
    2011-10-09 06:22:53 [SEVERE]     at performancetweaks.bin.org.jbls.mrchasez.events.MPlayerListener.onPlayerMove(MPlayerListener.java:17)
    2011-10-09 06:22:53 [SEVERE]     at org.bukkit.plugin.java.JavaPluginLoader$7.execute(JavaPluginLoader.java:286)
    2011-10-09 06:22:53 [SEVERE]     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    2011-10-09 06:22:53 [SEVERE]     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:180)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.Packet10Flying.a(SourceFile:126)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:92)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.NetworkListenThread.a(SourceFile:108)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:471)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    2011-10-09 06:22:53 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
     
  7. Does the Chunks-AddOn also require the user to use Spoutcraft?
     
  8. Offline

    bergerkiller

    @Lathanael nope, it only implements the Spout packet listener.

    Also, I'll try to move uncompressed chunk storage to compressed chunk storage, so buffered packets are always sent right after the call. I noticed that, when sending uncompressed chunk data, a delay exists between sending and actual sending, which I need to fix. Other than that, storing the compressed data instead of uncompressed data limits RAM usage a LOT, and will make packets arrive in-sync correctly.

    Once I managed to handle compressed map data chunks through spout I'll update it once more.
     
  9. Offline

    Kainzo

    @bergerkiller

    Latest and RB
    12:43:16 [SEVERE] java.util.ConcurrentModificationException
    12:43:16 [SEVERE] at java.util.WeakHashMap$HashIterator.nextEntry(WeakHashMap.java:785)
    12:43:16 [SEVERE] at java.util.WeakHashMap$ValueIterator.next(WeakHashMap.java:812)
    12:43:16 [SEVERE] at java.util.AbstractCollection.toArray(AbstractCollection.java:188)
    12:43:16 [SEVERE] at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader.getSortedBuffers(PlayerChunkLoader.java:69)
    12:43:16 [SEVERE] at com.bergerkiller.bukkit.nolaggchunks.PlayerChunkLoader$1.run(PlayerChunkLoader.java:89)
    12:43:16 [SEVERE] at org.bukkit.craftbukkit.scheduler.CraftWorker.run(CraftWorker.java:34)
    12:43:16 [SEVERE] at java.lang.Thread.run(Thread.java:722)
     
  10. Offline

    bergerkiller

    @Kainzo Aw yeah didn't make the buffers a-sync proof. Ow well, for now don't use the Chunks add-on, I'm waiting for Spout to fix their chunk packet listening coding so I can listen for compressed chunks. The current way of doing it can cause too many issues.

    Status update: waiting for Spout to fix their packet listeners so I can properly handle them. Then I will continue working on NoLaggChunks, since the base is solid and working. Till then, any requests for the main plugin? Turning physics off after a certain tick duration is already on the TODO list.

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

    mrciku

    Is it just me, or is text on signs not sending to the client after 1.30?
     
  12. Offline

    LEOcab

    Not at all - same here. Jeez, I've gotta stop updating more than one plugin at once. I was driving myself nuts figuring out what was causing this most annoying issue. :(
     
  13. Offline

    bergerkiller

    Can only be the add-on acting up, probably because of chunk packets being received after the sign update packets. (there is no sign to set the text on at the client). Waiting for Spout to fix/improve the packet listeners, then this should be pretty much solved.
     
  14. Offline

    jase240

    For me the server keeps "deleting chunks" not really deleting them but thinking they arent there. ill upload a pic soon

    here are screenshots of what happens to me
    Only with this plugin enabled though, when i disabled it this problem went away. The chunks arent really missing they just WONT load, for anyone.

    [​IMG]
    [​IMG]

    Also before you ask, no not using the Chunk addon and getting this

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

    bergerkiller

    @jase240 Unfortunately don't have time to fix it quickly, just a few questions will do...
    - Do these holes appear at the horizon after stopping for a few seconds, and then moving again?
    - Can you fall through these chunks, or are you pushed back by an invisible force?
    - Does (re)setting the chunkUnloadDelay to 0 fix these chunks?
    - Is everyone on the server seeing the same chunks as missing and does rejoining fail to remove it?
     
  16. Offline

    Makatiel

    I am having the same problem with missing chunks. It is so bad that I had to remove the plug-in for now.

    I don't know if my situation is the same as jase240 but I will answer the same questions.

    - The holes appear randomly, just an enitre chunk missing exactly like you see in that screenshot. They don't appear on the horizon, they are in a random location.

    -You fall through the world and straight into the void

    -Haven't tried

    -Yes and Yes - They remain persistent until everyone leaves the area and returns a while later forcing the chunk to reload.

    Now interesting enough we have one situation of falling through the world where the chunk wasn't visibly missing. They were walking and just fell through the world into the void. Came back to figure out WTF and fell straight through the same spot. Other people came to check it out and they were able to fall through as well. I wish one of them would have taken a Screenshot but nobody did.

    I uninstalled NoLagg a few days ago and the problem has disappeared completely.

    Plugin List:

    CraftBukkit r1240
    Dynmap 0.23
    Minecraft Mobile Admin for Android 3.22
    Spout r403
    Pail v0.7.5
    SuperLog 2.1
    Transporter v7.2


    The following plug-ins were added since NoLagg was removed:
    WorldGuard 5.3
    WorldEdit 4.7
    ChestShop 3.22
    PermissionsBukkit 1.2
    Super Perms Bridge 1.2
    LWC 3.53
    LWC-Economy 1.30
    Odditem 0.8
     
  17. Offline

    ledhead900

    I don't understand mate, These people are on about holes I have not seen a single hole yet at least nothing serious like that that as not loaded when I came a little closer to it. Although the no physics rain is still appearing in random areas again since installing the chunk add-on but re refreshing the view fixes the rain issue.
     
  18. Offline

    jase240

    1- they appear always, nothing not even relogging fixes them, only a server restart does.
    2- yes the server acts like they are air you can fall through them to the void
    3-unsure how to do this, however as I've said restarting the server fixes, and my settings are the default settings.
    4-yes it appears for everyone, and everyone can fall through them like its air.

    I don't know what stats to give you, as I have had this problem in high load and low load situations.
    Sadly that makes it hard even more and no console errors either. BUT I can garrentee 100% that its the plugin, I would give u my plugin list but as I am typing now I must sleep, if you need it tomorrow I will give it to you in case you think its a conflict, however I am not using any other plugin for performance.

    ALSO NOW - Not solid evidence but I just installed spout and I haven't seen this happen YET! Possibly an issue for users without spout???
     
  19. Offline

    Borch

    I'm using Spout + have the view distance set to 11 in the bukkit config. The problem was gone with 1.3, but I had many chunks missing before that. Maybe everyone who still got the problem should post their view distance and also try with Spout.
     
  20. Offline

    jase240

    My only problem with using it with spout is slow chunk loading issues again :(

    @bergerkiller
    If this is any help, my view distance was also set to 10.
    I lowered it when using spout I think to 8, If that means anything. Ill raise it to 10 and try to see if I get this bug again.
     
  21. Offline

    Afforess

    Can you open for an issue for it, so I don't keep forgetting? If I have time, I'll fix it tonight.

    https://github.com/SpoutDev/Spout/issues
     
  22. Offline

    bergerkiller

  23. Offline

    lithium210

    Is it ok to be using performancetweaks along with nolagg?
     
  24. Offline

    bergerkiller

    @lithium210 it should work yes, although all features of Performance Tweaks (except async saving) are taken over in NoLagg. (not to be mistaken with PTweaks, that is simply a 'copy 'n fix' project of Performance Tweaks set-up after NoLagg)
     
  25. Offline

    Greylocke

    CB1323, Spout 1.0.6.449. After running the server for a few minutes with NoLagg, I get this error:
    Error at Console (open)
    2011-10-12 03:32:38 [WARNING] Task of 'NoLagg' generated an exception
    java.lang.NullPointerException
    at org.bukkit.craftbukkit.CraftWorld.preserveChunk(CraftWorld.java:57)
    at org.bukkit.craftbukkit.CraftWorld.unloadChunk(CraftWorld.java:164)
    at org.bukkit.craftbukkit.CraftWorld.unloadChunk(CraftWorld.java:134)
    at org.bukkit.craftbukkit.CraftWorld.unloadChunk(CraftWorld.java:130)
    at org.getspout.spout.block.SpoutCraftChunk.unload(SpoutCraftChunk.java:113)
    at com.bergerkiller.bukkit.nolagg.ChunkHandler.cleanUp(ChunkHandler.java:81)
    at com.bergerkiller.bukkit.nolagg.NoLagg$1.run(NoLagg.java:125)
    at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:137)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:441)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)

    sorry if this is a repeat. I didn't see this error mentioned previously.
     
  26. Offline

    Afforess

    @bergerkiller

    I've switched Spout to use a modified copy of the chunk compression thread, as previously discussed.

    Please test this build of spout and let me know:

    A.) If I've broken anything.
    B.) If your packet listeners now receive compressed packets correctly.
     
  27. Offline

    lithium210

    so is there any benefit in running both? Should i just have nolagg running? I would rather have nolagg if its going to keep my server clean and have less plugins running.
     
  28. Offline

    Mrchasez

  29. Offline

    bergerkiller

    @lithium210 Unlike P(erformance)Tweaks I don't really improve the chunk unload and auto save features, only fix bugs that are occuring. I read that (RAM-decreasing) features will be added to PTweaks, and I won't go and copy the entire plugin (idea) in NoLagg. Until new features (different from performancetweaks/NoLagg) are added, there is no real benefit. But I'm sure there will be a benefit of using both in the near future. :)

    @Afforess Thanks, I'll fully test the packet listeners and perform some simple tests with them too. I'll report any issues on the Spout GitHub page.

    Also, may take a little longer to update it for CB#1323 (or latest RB), but I'll look into it some day. (got other things to do too unfortunately)
     
  30. Offline

    Mrchasez

    @bergerkiller
    I have added a feature to check ram.
    Another thing i want to add is a TPS checker, What methods would i need for that?
    I didn't even think about TPS but it has been requested a few times and i am lost on the subject.
     
  31. Offline

    bergerkiller

    @Mrchasez Keep track of the previous time a tick occured. For example, schedule a sync repeating task (interval is up to you) and store the latest type in MS in that tick. Subtract the new time with the old time of the previous tick, and you got the milliseconds a tick took.
    Code:
    private long prevTime = 0;
    public void run() {
        long newTime = System.currentTimeMillis();
        if (prevTime != 0) {
            long dur = newtime - prevTime;
            //dur is the time in milliseconds a tick took
        }
        prevTime = newTime;
    }
    This can be converted to TPS easily.
    Code:
    int tps = 1000 / dur;
     

Share This Page