@@ -52,53 +52,20 @@ private boolean isProxyOnlineMode() {
5252 }
5353
5454 @ Override
55- @ SuppressWarnings ("deprecation" )
55+ @ SuppressWarnings ({ "deprecation" , "Convert2MethodRef" } )
5656 protected void appendDefaultData (JsonObject charts ) {
57- System .out .println ("#appendDefaultData pluginVersion:" );
58- printInfo ("#appendDefaultData pluginVersion:" );
59-
6057 var pluginVersion = tryOrEmpty (() -> plugin .getPluginMeta ().getVersion ())
6158 .orElseGet (() -> plugin .getDescription ().getVersion ());
6259
63- System .out .println (pluginVersion );
64- printInfo (pluginVersion );
65-
66- System .out .println ("#appendDefaultData minecraftVersion:" );
67- printInfo ("#appendDefaultData minecraftVersion:" );
68-
69-
70- System .out .println (server .getBukkitVersion ());
71- System .out .println (server .getVersion ());
72- printInfo (server .getBukkitVersion ());
73- printInfo (server .getVersion ());
74-
75- var minecraftVersion = tryOrEmpty (server ::getMinecraftVersion )
76- .orElseGet (() -> {
77- try {
78- System .out .println (server .getBukkitVersion ());
79- printInfo (server .getBukkitVersion ());
80- return server .getBukkitVersion ().split ("-" , 2 )[0 ];
81- } catch (Exception e ) {
82- System .err .println ("Failed to get Minecraft version" );
83- e .printStackTrace (System .err );
84- printError ("Failed to get Minecraft version" , e );
85- return server .getVersion ();
86- }
87- });
88- //.or(() -> tryOrEmpty(() -> server.getBukkitVersion().split("-", 2)[0]))
89- //.orElseGet(() -> server.getVersion());
90-
91- System .out .println (minecraftVersion );
92- printInfo (minecraftVersion );
60+ var minecraftVersion = tryOrEmpty (() -> server .getMinecraftVersion ())
61+ .or (() -> tryOrEmpty (() -> server .getBukkitVersion ().split ("-" , 2 )[0 ]))
62+ .orElseGet (() -> server .getVersion ().split ("\\ (MC: |\\ )" , 3 )[1 ]);
9363
9464 charts .addProperty ("minecraft_version" , minecraftVersion );
9565 charts .addProperty ("online_mode" , checkOnlineMode ());
9666 charts .addProperty ("player_count" , server .getOnlinePlayers ().size ());
9767 charts .addProperty ("plugin_version" , pluginVersion );
9868 charts .addProperty ("server_type" , server .getName ());
99-
100- System .out .println ("#appendDefaultData done" );
101- printInfo ("#appendDefaultData done" );
10269 }
10370
10471 @ Override
@@ -119,10 +86,7 @@ protected void printWarning(String message) {
11986 private <T > Optional <T > tryOrEmpty (Supplier <T > supplier ) {
12087 try {
12188 return Optional .of (supplier .get ());
122- } catch (Throwable e ) {
123- printError ("Failed to get value" , e );
124- System .err .println ("Failed to get value" );
125- e .printStackTrace (System .err );
89+ } catch (NoSuchMethodError | Exception e ) {
12690 return Optional .empty ();
12791 }
12892 }
0 commit comments