12
12
13
13
public class ExplosionLogHelper
14
14
{
15
- private static BaseComponent log ;
15
+ private static BaseComponent compactLog ;
16
+ private static BaseComponent totalLog ;
16
17
17
18
public static void onExplosion (Vec3 pos , long tick , boolean affectBlocks )
18
19
{
20
+ if (ExplosionHelper .getCountInTick ()==0 )
21
+ ExplosionHelper .registerFirstTime (System .currentTimeMillis ());
22
+
19
23
if (ExplosionHelper .isEmpty () || ExplosionHelper .isNew (pos , tick ))
20
24
{
21
- long time = System .currentTimeMillis ();
22
- logCompact (time , false );
23
- ExplosionHelper .registerNewPos (pos , tick , time , affectBlocks );
25
+ long newPosTime = System .currentTimeMillis ();
26
+ logCompact (newPosTime , false );
27
+ ExplosionHelper .registerNewPos (pos , tick , newPosTime , affectBlocks );
24
28
}
25
29
else
26
30
{
27
- log = null ;
31
+ compactLog = null ;
28
32
ExplosionHelper .incrementCounts (tick );
29
33
}
30
34
}
@@ -33,8 +37,13 @@ public static List<BaseComponent> onLog(List<BaseComponent> messages, String opt
33
37
{
34
38
if (option .equals ("compact" ))
35
39
{
36
- if (log != null )
37
- messages .add (log );
40
+ if (compactLog != null )
41
+ messages .add (compactLog );
42
+ }
43
+ if (option .equals ("total" ))
44
+ {
45
+ if (totalLog != null )
46
+ messages .add (totalLog );
38
47
}
39
48
return messages ;
40
49
}
@@ -45,7 +54,7 @@ private static void logCompact(long time, boolean endOfTick)
45
54
return ;
46
55
47
56
Vec3 pos = ExplosionHelper .getPos ();
48
- log = Messenger .c (
57
+ compactLog = Messenger .c (
49
58
"d " + ExplosionHelper .getCountInPos () + "x " ,
50
59
Messenger .dblt ("l" , pos .x , pos .y , pos .z ),
51
60
"p [Tp]" , String .format (Locale .ENGLISH , "!/tp %.3f %.3f %.3f" , pos .x , pos .y , pos .z ),
@@ -55,16 +64,27 @@ private static void logCompact(long time, boolean endOfTick)
55
64
);
56
65
}
57
66
67
+ private static void logTotal (long lastTime )
68
+ {
69
+ if (ExplosionHelper .getCountInTick () == 0 )
70
+ return ;
71
+
72
+ totalLog = Messenger .c ("d " + ExplosionHelper .getCountInTick (), "g total" , "g (" , "d " + (lastTime - ExplosionHelper .getFirstTime ()), "g ms)" );
73
+ }
74
+
58
75
public static void afterEntities ()
59
76
{
60
77
if (LoggerRegistry .__explosions )
61
78
{
62
- logCompact (System .currentTimeMillis (), true );
79
+ long time = System .currentTimeMillis ();
80
+ logCompact (time , true );
81
+ logTotal (time );
63
82
LoggerRegistry .getLogger ("explosions" ).log ((option ) ->
64
83
{
65
84
return onLog (new ArrayList <BaseComponent >(), option ).toArray (new BaseComponent [0 ]);
66
85
});
67
- log = null ;
86
+ compactLog = null ;
87
+ totalLog = null ;
68
88
}
69
89
ExplosionHelper .clear ();
70
90
}
0 commit comments