From 46ef0b36f481753410723e8d8dbfda467c50f03d Mon Sep 17 00:00:00 2001 From: glowingstone124 Date: Tue, 1 Oct 2024 13:01:02 +0800 Subject: [PATCH] trying to refactor tick list getter --- .../vip/qoriginal/quantumplugin/MSPTCalculator.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/vip/qoriginal/quantumplugin/MSPTCalculator.java b/src/main/java/vip/qoriginal/quantumplugin/MSPTCalculator.java index edc5f9e..7dd51c3 100644 --- a/src/main/java/vip/qoriginal/quantumplugin/MSPTCalculator.java +++ b/src/main/java/vip/qoriginal/quantumplugin/MSPTCalculator.java @@ -22,11 +22,13 @@ import java.util.ArrayList; import java.util.Calendar; +import java.util.List; public class MSPTCalculator implements Listener { /** 最终展现在返回结果的MilliSecond Per Tick值 */ public static float mspt = 0f; public static ArrayList recent_60tick = new ArrayList<>(); + public static ArrayList tick_list = new ArrayList<>(); /** 记录一个游戏刻开始的毫秒时间 */ private static long starttime = 0; /** 记录上一次 mspt > 77 的时间 */ @@ -95,7 +97,7 @@ public static float getR3s() { return result; } public static ArrayList getRecent60t(){ - return recent_60tick; + return tick_list; } private static String f(int i) { if(i>=10) return i+""; @@ -136,4 +138,10 @@ private static void someExtraWorks() { } } } + public static void add_to_tick_list(float f) { + if (tick_list.size() >= 60) { + tick_list.removeFirst(); + } + tick_list.add(f); + } }