View difference between Paste ID: 9FWW4isU and JkfEk5Ki
SHOW: | | - or go back to the newest paste.
1
package ;
2
3
import org.bukkit.Bukkit;
4
import org.bukkit.event.EventHandler;
5
import org.bukkit.event.Listener;
6
import org.bukkit.event.server.PluginEnableEvent;
7
 
8
/*
9
 *
10
 * @author KeybordPiano459
11
 */
12
public class TPS implements Listener {
13-
    public TPS(Plugin plugin) {
13+
    <mainclass> plugin;
14
    public TPS(<mainclass> plugin) {
15
        this.plugin = plugin;
16
    }
17
   
18-
    public long sec = 0;
18+
19
    public long second = 0;
20
   
21
    public float getServerTPS() {
22
        return tps;
23
    }
24
   
25
    @EventHandler
26
    public void onPluginEnable(PluginEnableEvent event) {
27
        if (event.getPlugin() == plugin) {
28-
                long seconds;
28+
29
                long sec;
30
                int ticks;
31
               
32
                @Override
33-
                    seconds = System.currentTimeMillis() / 1000;
33+
34-
                    if (sec == seconds) ticks++;
34+
                    sec = System.currentTimeMillis() / 1000;
35-
                    else {
35+
                    if (second == sec) {
36-
                        sec = seconds;
36+
                        ticks++;
37
                    } else {
38-
                        else tps = tps + ticks / 2;
38+
                        second = sec;
39
                        if (tps == 0) tps = ticks;
40
                        else tps = (tps + ticks) / 2;
41
                        ticks = 0;
42
                    }
43
                }
44
            }, 20, 1);
45
        }
46
    }
47
}