Skip to content

Implement autosave feature#114

Closed
Copilot wants to merge 7 commits intodevelopfrom
copilot/implement-autosave-feature
Closed

Implement autosave feature#114
Copilot wants to merge 7 commits intodevelopfrom
copilot/implement-autosave-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 8, 2025

This PR implements an autosave feature that automatically saves plugin data every 5 minutes to prevent data loss in case of unexpected server shutdowns or crashes.

Changes

Autosave Feature

Added an asynchronous recurring task that periodically saves plugin data.

Implementation Details:

  • Timer-based scheduling: Uses java.util.Timer with a daemon thread to schedule the autosave task, following the same pattern used by the existing bStats Metrics integration
  • 5-minute interval: The task runs with an initial delay of 5 minutes and then repeats every 5 minutes
  • Thread-safe execution: While the Timer runs on a separate thread, the actual save operation is executed on the Bukkit main thread using Bukkit.getScheduler().runTask() to ensure thread safety
  • Proper lifecycle management:
    • Started at the end of onEnable() after all plugin initialization is complete
    • Stopped at the beginning of onDisable() with proper cleanup to prevent resource leaks
  • Plugin state checking: Verifies the plugin is still enabled before each save operation
  • Debug logging: Includes log messages for monitoring autosave activity

Code Changes:

Modified src/main/java/dansplugins/simpleskills/SimpleSkills.java:

  • Added autosaveTimer field to track the Timer instance
  • Added startAutosave() method to initialize and schedule the recurring task
  • Added stopAutosave() method to cancel the timer and clean up resources
  • Integrated autosave lifecycle into onEnable() and onDisable() methods

The implementation is minimal, focused, and follows existing code patterns in the repository.

Fixes #113

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement autosave</issue_title>
<issue_description>The data for the plugin should be saved every five minutes. An asynchronous recurring task should be scheduled for this.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #113

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add autosave functionality for data plugin Implement autosave feature with 5-minute recurring task Oct 8, 2025
Copilot AI requested a review from dmccoystephenson October 8, 2025 02:27
@dmccoystephenson dmccoystephenson marked this pull request as ready for review October 8, 2025 02:37
Copy link
Copy Markdown
Member

@dmccoystephenson dmccoystephenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Add the Ponder project as a git submodule, then create a simple CI task to install Ponder with Maven and then compile the plugin

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot Add the Ponder project as a git submodule, then create a simple CI task to install Ponder with Maven and then compile the plugin

Added Ponder as a git submodule at dependencies/Ponder and created a CI workflow (.github/workflows/build.yml) that:

  1. Checks out the repository with submodules
  2. Builds Ponder using Gradle and publishes it to the local Maven repository
  3. Compiles SimpleSkills with Maven using the locally installed Ponder dependency

Commit: aa7e2da (autosave), plus the new commit for submodule and CI workflow

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • hub.spigotmc.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m -XX:&#43;HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-7.4.2-bin/48ivgl02cpt2ed3fh9dbalvx8/gradle-7.4.2/lib/gradle-launcher-7.4.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.4.2 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Implement autosave feature with 5-minute recurring task Implement autosave feature and add CI build workflow Oct 8, 2025
Copilot AI requested a review from dmccoystephenson October 8, 2025 02:46
Copy link
Copy Markdown
Member

@dmccoystephenson dmccoystephenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot The CI check should check out the same version of Ponder that it references in pom.xml

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot The CI check should check out the same version of Ponder that it references in pom.xml

Updated the CI workflow and Ponder submodule to reference v1.0 tag (matching the version in pom.xml). The workflow now explicitly checks out v1.0 before building Ponder.

Commit: 3b63786 (latest)

Copy link
Copy Markdown
Member

@dmccoystephenson dmccoystephenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Update CI pipeline to point to tag v0.14-alpha-2 for Ponder

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot Update CI pipeline to point to tag v0.14-alpha-2 for Ponder

Updated CI pipeline to check out v0.14-alpha-2 tag for Ponder. The submodule reference points to v0.14 (the closest available tag in the repository).

Commit: 83ca31b

Copy link
Copy Markdown
Member

@dmccoystephenson dmccoystephenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Make CI pipeline and pom.xml reference v0.14 for Ponder

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot Make CI pipeline and pom.xml reference v0.14 for Ponder

Updated both CI pipeline and pom.xml to reference v0.14 for Ponder. Both files now consistently use the same version.

Commit: 398d4bb

Copy link
Copy Markdown
Member

@dmccoystephenson dmccoystephenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove CI pipeline and revert pom.xml changes

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot Remove CI pipeline and revert pom.xml changes

Removed CI pipeline files (.github/workflows/build.yml, .gitmodules, and Ponder submodule) and reverted pom.xml back to reference v1.0 for Ponder.

Commit: 3bab8c5

@dmccoystephenson dmccoystephenson changed the title Implement autosave feature and add CI build workflow Implement autosave feature Oct 8, 2025
Copilot AI requested a review from dmccoystephenson October 8, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants