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 {
- public TPS(Plugin plugin) {
- this.plugin = plugin;
- }
- public int tps = 0;
- public long sec = 0;
- public float getServerTPS() {
- return tps;
- }
- @EventHandler
- public void onPluginEnable(PluginEnableEvent event) {
- if (event.getPlugin() == plugin) {
- Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- long seconds;
- int ticks;
- @Override
- public void run() {
- seconds = System.currentTimeMillis() / 1000;
- if (sec == seconds) ticks++;
- else {
- sec = seconds;
- tps = tps == 0 ? ticks : (tps + ticks) / 2;
- ticks = 0;
- }
- }
- }, 20, 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment