Skip to content

Building

Cyrusbye720 edited this page May 18, 2026 · 1 revision

๐Ÿ—๏ธ Building from Source

Prerequisites

  • Java 21+ (required for compilation)
  • Git (for cloning the repository)

Building with Gradle (Recommended)

1. Clone the Repository

git clone https://github.com/DemonZ-Development/Onlysleep.git
cd Onlysleep

2. Build the Plugin

./gradlew clean build

On Windows, use gradlew.bat clean build.

3. Find the Output

The compiled JAR will be in build/libs/:

build/libs/Onlysleep-1.0.0.jar

4. Install the Built JAR

Copy the JAR to your server's plugins/ folder and restart.


Building with Maven (Alternative)

1. Clone the Repository

git clone https://github.com/DemonZ-Development/Onlysleep.git
cd Onlysleep

2. Build the Plugin

mvn clean package

3. Find the Output

The compiled JAR will be in target/:

target/Onlysleep-1.0.0.jar

Running Tests

# Run all tests
./gradlew test

# Run specific test class
./gradlew test --tests "com.demonzdevelopment.onlysleep.config.ConfigManagerTest"

# Run with verbose output
./gradlew test --info

# Run tests without building first
./gradlew test --no-daemon

The project has 152+ unit tests covering:

  • ConfigManager (configuration loading and progress bar logic)
  • SleepManager (sleep counting, player filtering, permissions)
  • AfkTracker (AFK detection and timeout)
  • PlatformAdapter (server platform detection)
  • UpdateChecker (version comparison)
  • SleepPlaceholderExpansion (all 19+ placeholders)
  • OnlysleepIntegrationTest (end-to-end plugin lifecycle)

Build Options

Skipping Tests

./gradlew build -x test

Building with Debug Information

./gradlew clean build --info

Generating a Comprehensive Test Report

./gradlew clean test

HTML test reports are available at build/reports/tests/test/index.html.


Project Structure

Onlysleep/
โ”œโ”€โ”€ build.gradle.kts              # Gradle build configuration
โ”œโ”€โ”€ settings.gradle.kts           # Gradle settings
โ”œโ”€โ”€ pom.xml                       # Maven build configuration
โ”œโ”€โ”€ gradlew / gradlew.bat         # Gradle wrapper scripts
โ”œโ”€โ”€ CHANGELOG.md                  # Version history
โ”œโ”€โ”€ README.md                     # Main README
โ”œโ”€โ”€ MODRINTH.md                   # Modrinth description
โ”œโ”€โ”€ SPIGOT.md                     # Spigot description
โ”œโ”€โ”€ HANGAR.md                     # Hangar description
โ”œโ”€โ”€ wiki/                         # Wiki documentation
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/com/demonzdevelopment/onlysleep/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Onlysleep.java                    # Main plugin class
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config/ConfigManager.java          # Configuration
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ command/OnlysleepCommand.java      # Commands
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ listener/SleepListener.java        # Event listeners
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ manager/SleepManager.java          # Core logic
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ util/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ AfkTracker.java                # AFK detection
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ OfflinePlayerTracker.java      # Offline caching
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ PlatformAdapter.java           # Platform detection
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ SchedulerAdapter.java          # Folia compatibility
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ SleepPlaceholderExpansion.java # PAPI expansion
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ UpdateChecker.java             # Version checking
โ”‚   โ”‚   โ””โ”€โ”€ resources/
โ”‚   โ”‚       โ”œโ”€โ”€ config.yml                         # Default config
โ”‚   โ”‚       โ”œโ”€โ”€ messages.yml                       # Default messages
โ”‚   โ”‚       โ””โ”€โ”€ plugin.yml                         # Plugin metadata
โ”‚   โ””โ”€โ”€ test/
โ”‚       โ””โ”€โ”€ java/com/demonzdevelopment/onlysleep/
โ”‚           โ”œโ”€โ”€ OnlysleepIntegrationTest.java
โ”‚           โ”œโ”€โ”€ config/ConfigManagerTest.java
โ”‚           โ”œโ”€โ”€ manager/SleepManagerTest.java
โ”‚           โ””โ”€โ”€ util/
โ”‚               โ”œโ”€โ”€ AfkTrackerTest.java
โ”‚               โ”œโ”€โ”€ PlatformAdapterTest.java
โ”‚               โ”œโ”€โ”€ SleepPlaceholderExpansionTest.java
โ”‚               โ””โ”€โ”€ UpdateCheckerTest.java
โ””โ”€โ”€ .github/workflows/
    โ”œโ”€โ”€ build.yml                  # CI build workflow
    โ”œโ”€โ”€ codeql.yml                 # Security analysis
    โ””โ”€โ”€ release.yml               # Release automation

CI/CD

The project uses GitHub Actions for continuous integration:

  • build.yml โ€” Runs on every push and pull request. Builds the plugin with both Gradle and Maven, runs all tests, and caches dependencies.
  • codeql.yml โ€” Runs CodeQL security analysis on every push to main and weekly.
  • release.yml โ€” Triggered by tags matching v*. Builds the plugin, runs tests, creates a GitHub Release with the JAR artifact.

Dependencies

Build Dependencies

Dependency Purpose
Paper API (1.21.4) Bukkit/Paper server API
PlaceholderAPI Optional placeholder expansion
bStats Anonymous usage metrics
Adventure API Modern component-based chat

Test Dependencies

Dependency Purpose
JUnit 5 (Jupiter) Test framework
Mockito 5 Mocking Bukkit APIs
Mockito JUnit Jupiter Mockito integration with JUnit 5

๐ŸŒ™ Onlysleep Wiki

๐Ÿ“– Getting Started

โš™๏ธ Configuration

๐ŸŽฎ Usage

๐Ÿ”Œ Development

โ“ Help


๐Ÿ”— External Links

Clone this wiki locally