1818import com .thevoxelbox .voxelsniper .performer .PerformerRegistry ;
1919import com .thevoxelbox .voxelsniper .performer .property .PerformerProperties ;
2020import com .thevoxelbox .voxelsniper .sniper .SniperRegistry ;
21+ import com .thevoxelbox .voxelsniper .update .UpdateCheckerParser ;
2122import com .thevoxelbox .voxelsniper .util .io .VoxelSniperResourceLoader ;
2223import io .papermc .lib .PaperLib ;
2324
3031import org .bukkit .plugin .PluginManager ;
3132import org .bukkit .plugin .java .JavaPlugin ;
3233import org .incendo .serverlib .ServerLib ;
33- import org .json .simple .JSONArray ;
34- import org .json .simple .JSONObject ;
35- import org .json .simple .JSONValue ;
3634
3735import java .io .BufferedReader ;
3836import java .io .File ;
@@ -270,7 +268,8 @@ public CommandRegistry getCommandRegistry() {
270268 return this .commandRegistry ;
271269 }
272270
273- // Borrowed from Vault
271+ // Borrowed from Vault - Updated to workaround JSON removal from paper
272+
274273 private double updateCheck (double currentVersion ) {
275274 try {
276275
@@ -280,18 +279,26 @@ private double updateCheck(double currentVersion) {
280279 conn .addRequestProperty ("User-Agent" , "FastAsyncVoxelSniper Update Checker" );
281280 conn .setDoOutput (true );
282281 final BufferedReader reader = new BufferedReader (new InputStreamReader (conn .getInputStream ()));
283- final String response = reader .readLine ();
284- final JSONArray array = (JSONArray ) JSONValue .parse (response );
282+ StringBuilder sb = new StringBuilder ();
283+ String line ;
284+ while ((line = reader .readLine ()) != null ) {
285+ sb .append (line );
286+ }
287+ final String response = sb .toString ();
288+
289+ // Extract last name using UpdateCheckerParser to avoid JSON dependency
290+ String lastName = UpdateCheckerParser .extractLatestNameFromResponse (response );
285291
286- if (array . isEmpty () ) {
292+ if (lastName == null ) {
287293 LOGGER .warn ("No files found, or Feed URL is bad." );
288294 return currentVersion ;
289295 }
290- newVersionTitle =
291- ((String ) ((JSONObject ) array .getLast ()).get ("name" )).replace ("FastAsyncVoxelSniper" , "" ).trim ();
296+ newVersionTitle = lastName .replace ("FastAsyncVoxelSniper" , "" ).trim ();
292297 return Double .parseDouble (newVersionTitle .replaceFirst ("\\ ." , "" ).trim ());
293298 } catch (IOException ignored ) {
294299 LOGGER .error ("Unable to connect to api.curseforge.com to check for updates. Improper firewall configuration?" );
300+ } catch (NumberFormatException e ) {
301+ LOGGER .warn ("Unable to parse version string: {}" , newVersionTitle , e );
295302 }
296303 return Double .NaN ;
297304 }
0 commit comments