@@ -551,6 +551,31 @@ private boolean removeLine0(final int x1, final int z1, final int x2, final int
551551 return true ;
552552 }
553553
554+ public void removeAllLines (final ResourceKey <Level > dimension ) {
555+ int tryCount = 0 ;
556+ while (tryCount ++ < MAX_RETRIES ) {
557+ if (removeAllLines0 (dimension )) {
558+ return ;
559+ }
560+ XaeroPlus .LOGGER .info ("Retrying removing all lines from {} database in dimension: {}, (attempt {}/{})" , databaseName , dimension .location (), tryCount , MAX_RETRIES );
561+ Wait .waitMs (50 );
562+ }
563+ }
564+
565+ private boolean removeAllLines0 (final ResourceKey <Level > dimension ) {
566+ try (var statement = connection .createStatement ()) {
567+ statement .executeUpdate ("DELETE FROM \" " + getTableName (dimension , LINES_TABLE ) + "\" " );
568+ } catch (SQLException e ) {
569+ XaeroPlus .LOGGER .error ("Error while removing all lines from {} database in dimension: {}" , databaseName , dimension .location (), e );
570+ if (e .getErrorCode () == SQLiteErrorCode .SQLITE_CORRUPT .code ) {
571+ XaeroPlus .LOGGER .error ("Corruption detected in {} database" , databaseName , e );
572+ recoverCorruptDatabase ();
573+ }
574+ return false ;
575+ }
576+ return true ;
577+ }
578+
554579 public void removeHighlight (final int x , final int z , final ResourceKey <Level > dimension ) {
555580 int tryCount = 0 ;
556581 while (tryCount ++ < MAX_RETRIES ) {
@@ -618,6 +643,31 @@ private boolean removeHighlights0(final LongCollection toRemove, final ResourceK
618643 return true ;
619644 }
620645
646+ public void removeAllHighlights (final ResourceKey <Level > dimension ) {
647+ int tryCount = 0 ;
648+ while (tryCount ++ < 3 ) {
649+ if (removeAllHighlights0 (dimension )) {
650+ return ;
651+ }
652+ XaeroPlus .LOGGER .info ("Retrying removing all highlights from {} database in dimension: {} (attempt {}/{})" , databaseName , dimension .location (), tryCount , 3 );
653+ Wait .waitMs (50 );
654+ }
655+ }
656+
657+ private boolean removeAllHighlights0 (final ResourceKey <Level > dimension ) {
658+ try (var statement = connection .createStatement ()) {
659+ statement .executeUpdate ("DELETE FROM \" " + getTableName (dimension , HIGHLIGHTS_TABLE ) + "\" " );
660+ } catch (SQLException e ) {
661+ XaeroPlus .LOGGER .error ("Error while removing all highlights from {} database in dimension: {}" , databaseName , dimension .location (), e );
662+ if (e .getErrorCode () == SQLiteErrorCode .SQLITE_CORRUPT .code ) {
663+ XaeroPlus .LOGGER .error ("Corruption detected in {} database" , databaseName , e );
664+ recoverCorruptDatabase ();
665+ }
666+ return false ;
667+ }
668+ return true ;
669+ }
670+
621671 public void removeText (final int x , final int z , final ResourceKey <Level > dimension ) {
622672 int tryCount = 0 ;
623673 while (tryCount ++ < MAX_RETRIES ) {
@@ -643,6 +693,31 @@ private boolean removeText0(final int x, final int z, final ResourceKey<Level> d
643693 return true ;
644694 }
645695
696+ public void removeAllTexts (final ResourceKey <Level > dimension ) {
697+ int tryCount = 0 ;
698+ while (tryCount ++ < MAX_RETRIES ) {
699+ if (removeAllTexts0 (dimension )) {
700+ return ;
701+ }
702+ XaeroPlus .LOGGER .info ("Retrying removing all texts from {} database in dimension: {}, (attempt {}/{})" , databaseName , dimension .location (), tryCount , MAX_RETRIES );
703+ Wait .waitMs (50 );
704+ }
705+ }
706+
707+ private boolean removeAllTexts0 (final ResourceKey <Level > dimension ) {
708+ try (var statement = connection .createStatement ()) {
709+ statement .executeUpdate ("DELETE FROM \" " + getTableName (dimension , TEXTS_TABLE ) + "\" " );
710+ } catch (SQLException e ) {
711+ XaeroPlus .LOGGER .error ("Error while removing all texts from {} database in dimension: {}" , databaseName , dimension .location (), e );
712+ if (e .getErrorCode () == SQLiteErrorCode .SQLITE_CORRUPT .code ) {
713+ XaeroPlus .LOGGER .error ("Corruption detected in {} database" , databaseName , e );
714+ recoverCorruptDatabase ();
715+ }
716+ return false ;
717+ }
718+ return true ;
719+ }
720+
646721 @ Override
647722 public void close () {
648723 try {
0 commit comments