Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ;
- import org.bukkit.Bukkit;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.server.PluginEnableEvent;
- /*
- *
- * @author KeybordPiano459
- */
- public class TPS implements Listener {
- <mainclass> plugin;
- public TPS(<mainclass> plugin) {
- this.plugin = plugin;
- }
- public int tps = 0;
- public long second = 0;
- public float getServerTPS() {
- return tps;
- }
- @EventHandler
- public void onPluginEnable(PluginEnableEvent event) {
- if (event.getPlugin() == plugin) {
- Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- long sec;
- int ticks;
- @Override
- public void run() {
- sec = System.currentTimeMillis() / 1000;
- if (second == sec) ticks++;
- else {
- second = sec;
- if (tps == 0) tps = ticks;
- else tps = (tps + ticks) / 2;
- ticks = 0;
- }
- }
- }, 20, 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement