All Mods Resource Packs Data Packs Shaders Modpacks Plugins
SinglePlayerSleep - Sleep Plugin

SinglePlayerSleep - Sleep Plugin

by MRsuffixx • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

UPDATE V2.3.0 IS HERE!

⚠️ This project is still under development and may contain bugs. Use carefully and report any issues.

I DO NOT INTEND TO MAKE ANY MONEY FROM THIS PROJECT. Contact: mrsuffix@olnk.tr

This plugin has no connection to the SinglePlayerSleep plugin on SpigotMC. It is merely a coincidence in name.

This plugin was created using AI and was developed solely to demonstrate that AI can write advanced code and build a functional system. You are welcome to fork and utilize it as you see fit.

🛌 SinglePlayerSleep Plugin

GitHub release GitHub license GitHub issues Modrinth Downloads Modrinth Version Java Version Minecraft Version

Hangar Downloads Hangar Stars Hangar Views

✨ A modern, lightweight Minecraft plugin to skip the night instantly in single-player worlds or with percentage-based voting — packed with rich features, visual effects, and fully configurable settings.

📥 Download from Modrinth


📜 About

SinglePlayerSleep is designed for Minecraft servers that aim to keep the immersive single-player feel, even in multiplayer mode, by allowing the night to be skipped when a single player sleeps or when a certain percentage of players vote to sleep.

Built with performance and flexibility in mind, it features configurable messages, particle & sound effects, automatic saving, AFK detection, PlaceholderAPI integration, sleep statistics, and automatic update checking.

Whether you run a small private SMP or a public server, SinglePlayerSleep seamlessly handles night skipping without requiring everyone online to sleep.


⚙️ Features

Core Features

  • ✅ Skip the night when just one player sleeps (classic mode)
  • ✅ Percentage-based sleep voting system
  • ✅ AFK player detection and exclusion from sleep count
  • ✅ Automatic GitHub update checker
  • ✅ Fully configurable delay before skipping night
  • ✅ Cooldown between sleep events to prevent spam
  • ✅ Automatic weather clearing on new day
  • ✅ PlaceholderAPI integration (%sps_*% placeholders)
  • ✅ Sleep statistics tracking (global + per-player, persisted to stats.yml)
  • ✅ Countdown before night skip (action bar + chat)
  • ✅ Per-world enable/disable (whitelist or blacklist mode)
  • ✅ Phantom timer reset on night skip (Paper-aware)

Visual & Performance

  • ✅ Particle and sound effects for visual feedback
  • ✅ Smart particle optimization based on player count
  • ✅ Config cache system for fast performance
  • ✅ Real-time sleep progress messages

Server Management

  • ✅ Auto-save worlds after night skip
  • ✅ Custom messages with color codes and placeholders
  • ✅ World-specific activation
  • ✅ Debug mode and detailed logging

🆕 What's New in v2.2.0

🐛 Critical Bug Fixes

  • Fixed getSleepingPlayers() always returning empty set — The method was returning a newly created empty collection instead of the actual sleeping players. Any code relying on this (placeholders, stats) was silently broken.
  • Fixed /sleep vote command bypassing cooldown — In percentage mode, players could bypass the sleep cooldown by using the /sleep command instead of entering a bed. Cooldown is now enforced on both paths.
  • Fixed particles spawning in wrong world — If a player changed worlds during the countdown, particles would spawn at their current location in the wrong world. Players are now verified to still be in the session's world before effects are applied.
  • Fixed CooldownManager missing from SleepCommand constructor — The cooldownManager field was declared but never assigned, causing a NullPointerException on every /sleep command execution.

🔧 High-Priority Fixes

  • Implemented PhantomListener — The listener was registered but the event handler body was completely empty, meaning phantom spawns were never actually cancelled. Logic is now correctly implemented.
  • Fixed stats not auto-saving — Stats were only written to disk on server shutdown or /sps reload. A crash would cause full stats loss. A periodic auto-save task now runs every 5 minutes.
  • Fixed SleepSession thread safety — sleepingPlayers is now backed by a concurrent collection to prevent ConcurrentModificationException during async PlaceholderAPI queries.
  • Fixed VoteModule.addVote() race condition — computeIfAbsent() and get() were two separate operations. They are now chained into a single atomic call.
  • Fixed CooldownManager thread safety — Changed from HashMap to ConcurrentHashMap to prevent race conditions from async PlaceholderAPI thread access.
  • Fixed AFK exclusion message spam — The "AFK players excluded" message was broadcasting on every single sleep attempt per session. It now sends only once per session.
  • Migrated action bar from deprecated Bungee Chat API to Adventure API — net.md_5.bungee.api usages replaced with player.sendActionBar() via Adventure API, as recommended for Paper 1.21+.
  • Fixed refreshRequirement() using raw player count — Now correctly uses getEffectiveSleepingCount() instead of sleepingPlayers.size() to account for /sleep votes in percentage mode.
  • Fixed quit/kick handler missing sleeping players — Players tracked in sleepingPlayers but kicked before sleep animation completed were not being removed. onPlayerLeave() is now called unconditionally.
  • Fixed getSession() creating empty sessions — In percentage mode, getSession(world) was called to retrieve the required count, which triggered computeIfAbsent and created an empty session even when no one had entered a bed. Now uses getSessionIfExists().
  • Fixed vote world check missing — Votes were being counted without verifying the voter is still in the same world as the sleep session.
  • Fixed default GitHub repository name — Update checker default was SinglePlayerSleep instead of SinglePlayerSleepV2, causing update checks to fail on fresh installs.

⚡ Performance & Medium Fixes

  • Introduced TimeUtil class — Magic numbers 12541 (sunset) and 23458 (sunrise) were hardcoded across SleepSession.java, SleepManager.java, and PlaceholderHook.java. These are now named constants (SUNSET_TICKS, SUNRISE_TICKS) in a shared TimeUtil class.
  • Optimized getEffectiveSleepingCount() — Replaced set-union allocation (creating a new HashSet on every call) with a simple counter loop, reducing GC pressure on busy servers.
  • Fixed calculateRequired() called multiple times — Result is now cached in a local variable within checkSleepCondition().
  • Unified leaderboard cache updates — topSleepersCache, topContributorsCache, and lastLeaderboardRefresh are now updated atomically via a single LeaderboardSnapshot object to prevent inconsistent reads across threads.
  • Fixed empty world session memory leak — Sleep sessions now clean themselves up when a world becomes empty, preventing unbounded session map growth on servers with many temporary worlds.
  • Added stats cleanup for old player data — stats.yml no longer grows unbounded. A configurable stats.cleanup-days option (default: 90) purges entries for players who haven't been seen recently.
  • Removed redundant null checks — Player.getWorld() is never null in the Bukkit API. Removed misleading defensive checks from VoteModule and SleepListener.
  • Removed redundant isPrimaryThread() check in AfkListener — AsyncPlayerChatEvent is always async by Bukkit contract; the check was misleading.
  • Removed redundant null check in AfkModule.scheduledCheck() — sleepManager is never null at the call site.
  • Fixed VoteModule.getVotes() unnecessary copy — Changed from Set.copyOf() (full allocation) to Collections.unmodifiableSet() (view only).
  • Fixed PhantomModule broadcasting when no players were reset — The phantom-reset message now only broadcasts if at least one player's timer was actually reset.

🎨 Code Quality

  • Added TimeUtil class with isNight(World) helper method
  • Fixed fully qualified class names in SpsCommand.java and SleepManager.java — proper imports added, simple class names used consistently
  • Removed unnecessary null checks on Bukkit events — Bukkit never fires null events; defensive checks removed from SleepListener

📂 Installation

  1. Download the latest release from Releases or Modrinth.
  2. Place the .jar file into your server's /plugins folder.
  3. Restart or reload your server.
  4. Edit plugins/SinglePlayerSleep/config.yml as needed.
  5. Use /sps reload to apply configuration changes.

Requirements:

  • Minecraft 1.21.1+
  • Java 21+
  • Paper (recommended) or Spigot

Optional: Install PlaceholderAPI to enable %sps_*% placeholders.


🛠️ Commands

Command Description Permission
/sleep Vote to skip the night (percentage mode) singleplayersleep.sleep
/sps reload Reload config and reset sessions singleplayersleep.admin
/sps stats [player] View global or per-player sleep stats singleplayersleep.admin
/sps afk Toggle your AFK status manually singleplayersleep.admin
/sps version Show plugin info and update status singleplayersleep.admin
/sps debug Toggle debug logging singleplayersleep.admin

🔑 Permissions

Permission Default Description
singleplayersleep.sleep true Use /sleep
singleplayersleep.admin op Use /sps and admin features
singleplayersleep.bypasscooldown op Bypass sleep cooldown
singleplayersleep.bypassafk op Never marked as AFK
singleplayersleep.stats true View statistics (reserved)

📊 PlaceholderAPI

Requires PlaceholderAPI installed. Expansion identifier: sps

Placeholder Description
%sps_sleeping% Current sleeping players in the viewer's world
%sps_required% Required sleepers in the viewer's world
%sps_is_night% true/false — is it currently night
%sps_is_processing% true/false — is night skip in progress
%sps_cooldown% Remaining cooldown in seconds
%sps_is_afk% true/false — is the player AFK
%sps_nights_skipped% Total nights skipped (global)
%sps_player_times_slept% Times this player has slept
%sps_mode% single or percentage
%sps_percentage% Required percentage

🧩 Configuration Overview

Config file: plugins/SinglePlayerSleep/config.yml

Sleep Behavior

Key Default Description
sleep.mode single single or percentage
sleep.percentage 50 Required % of non-AFK players
sleep.delay-ticks 100 Delay before night skip (20 = 1 second)
sleep.cooldown-seconds 60 Cooldown between sleep sessions
sleep.clear-weather true Clear rain/thunder after skip
sleep.auto-save true Call world.save() after skip

AFK System

Key Default Description
afk.enabled true Enable AFK tracking
afk.timeout-seconds 300 Inactivity before AFK
afk.exclude-from-count true Exclude AFK players from required count
afk.check-interval-ticks 200 How often AFK checks run

Countdown

Key Default Description
countdown.enabled true Enable countdown before skip
countdown.duration-seconds 5 Countdown length
countdown.show-actionbar true Show countdown in action bar
countdown.show-chat false Also post countdown to chat
countdown.sound-on-each-tick true Play tick sound each second

Statistics

Key Default Description
stats.enabled true Enable stats tracking
stats.persist true Save stats to stats.yml
stats.track-per-player true Track per-player stats
stats.cleanup-days 90 Purge stats for players unseen this many days

World Filtering

Key Default Description
worlds.enabled ["world"] World list
worlds.mode whitelist whitelist or blacklist

🤝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m "Add my feature"
  4. Push: git push origin feature/my-feature
  5. Open a Pull Request
# Clone and build
git clone https://github.com/MRsuffixx/SinglePlayerSleep.git
mvn clean package
# Output: target/SinglePlayerSleep-2.2.0.jar

📞 Support

When reporting a bug, please include: Minecraft version, plugin version, server software, config.yml, and any error logs.


🗺️ Roadmap

  • [ ] Bossbar progress indicator
  • [ ] MySQL/SQLite database support for statistics
  • [ ] Multi-language support
  • [ ] Discord webhook integration
  • [ ] Per-world configuration overrides

📃 License

Distributed under the MIT License. See LICENSE for details.


🏆 Credits

Author: MRsuffix — Current Version: 2.2.0 — Minecraft: 1.21.1+

🧡 Built with love for the Minecraft community.

Current Version: 2.2.0
Last Updated: April 2026
Minecraft Compatibility: 26.1+

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
26.1.x 1.21.x 1.20.x
Bukkit Paper Purpur Spigot
18h ago 1
26.1.x 1.21.x
Bukkit Paper Purpur Spigot
18h ago 1
1.21.x
Bukkit Paper Spigot
18h ago 1
1.21
Paper
18h ago 1
1.21.x 1.20.x
Bukkit Paper Purpur Spigot
18h ago 1
1.20
Bukkit Paper Purpur Spigot
18h ago 1
1.21.x 1.20.x
Bukkit Paper Purpur Spigot
18h ago 1
# Changelog

## [Unreleased] - 2026-04-09

### Fixed

#### 🔴 Critical
  • SleepSession.getSleepingPlayers() now returns the actual sleeping players set instead of a new empty set
  • /sleep vote command now correctly checks cooldown in percentage mode
  • Particles no longer spawn in wrong world when player changes worlds during countdown

#### 🟠 High
  • Removed empty PhantomListener event handler that registered but did nothing
  • Hardcoded night time values (12541, 23458) replaced with named constants SUNSET_TICKS and SUNRISE_TICKS
  • Update checker default repository corrected from SinglePlayerSleep to SinglePlayerSleepV2
  • CooldownManager now uses ConcurrentHashMap to prevent race conditions with async PlaceholderAPI calls
  • VoteModule.addVote() race condition fixed by chaining computeIfAbsent() and add() into a single atomic call
  • Action bar messages migrated from deprecated Bungee Chat API to Adventure API
  • AFK exclusion message no longer spams chat on every sleep attempt; now sent once per session
  • refreshRequirement() now uses getEffectiveSleepingCount() instead of raw sleepingPlayers.size()
  • Players removed from sleep tracking correctly on quit/kick regardless of isSleeping() state

#### 🟡 Medium
  • Leaderboard cache (topSleepersCache, topContributorsCache, lastLeaderboardRefresh) now updated atomically via a single LeaderboardSnapshot object
  • Night time boundary checks documented with inline comments
  • Redundant null check on sleepManager parameter removed from AfkModule.scheduledCheck()

#### 🔵 Low
  • sleepingPlayers changed from ConcurrentHashMap.newKeySet() to HashSet (all access is on main thread)
  • Redundant replaceAll("[^0-9]", "") regex removed from SleepRule.parseInt()

#### ⚪ Style
  • MessageUtil field in SleepManager now uses simple class name instead of fully qualified name

#### 🌏 And more error and feature fixed.
NEW VERSION
# SinglePlayerSleep v1.2.1 - Auto-Update Config 🛠️

This update focuses on quality-of-life improvements for server owners updating from older versions.

## 🌟 What's New

### 🔄 Intelligent Config Auto-Update
Upgrading from v1.1.0 to v1.2.0+? You no longer need to regenerate your config file!
  • The plugin now **automatically adds missing configuration settings** (like BossBar and Smooth Sleep options) to your existing [config.yml](file:///c:/Users/mrsuf/IdeaProjects/singleplayersleep/src/main/resources/config.yml).
  • Your previous settings are strictly preserved.
  • New features default to enabled so you can enjoy them instantly.


## 📋 Changelog
  • [Feature]** Implemented auto-update logic for [config.yml](file:///c:/Users/mrsuf/IdeaProjects/singleplayersleep/src/main/resources/config.yml).
  • [Improvement]** Existing configurations will now automatically receive new keys for bossbar, smooth-sleep, and new messages.


# SinglePlayerSleep v1.2.0 - Smooth Sleep & Logic Fixes 🛌✨

This update brings significant improvements to the sleeping experience, visual feedback, and core logic stability.

## 🌟 Highlights

### ⚡ Smooth Sleep (Time Acceleration)
Gone are the days of the sun instantly snapping to the horizon! The transition to morning is now **smooth and animated**, with time accelerating rapidly until daybreak. This provides a much more immersive experience.
  • Configurable via smooth-sleep.enabled and speed.*

### 🛑 Sleep Cancellation ("Sleep Scam" Fix)
We've fixed a major logic loop where night would still skip even if a player left their bed.
  • New Logic**: If you leave your bed before the night skip timer completes (or if the percentage drops below requirement), the skip is **cancelled immediately**.
  • Added a "Player woke up" message to notify the server.

### 📊 BossBar Progress
Players now get clear visual feedback when someone is sleeping.
  • A **BossBar** appears at the top of the screen showing: "Sleeping... (X%)".
  • Fully customizable title, color, and style.

### 🔧 1.21 Support
  • Updated internal API usage to fully support **Minecraft 1.21 - 1.21.11**.
  • Fixed particle names to match modern API standards (ENCHANT, HAPPY_VILLAGER, etc.).


## 📋 Changelog
  • [Feature]** Added Smooth Sleep time acceleration.
  • [Feature]** Added BossBar for sleep progress.
  • [Fix]** Fixed night skipping even if player leaves bed.
  • [Fix]** Updated particle names for 1.21 compatibility.
  • [Config]** Added bossbar and smooth-sleep configuration sections.
  • [Config]** Added player-woke-up message.
  • [Tech]** Updated project to Java 21 and Paper API 1.21.

## ⚙️ Configuration Changes
Add these to your [config.yml](file:///c:/Users/mrsuf/IdeaProjects/singleplayersleep/src/main/resources/config.yml) to use the new features:

``yaml
bossbar:
enabled: true
title: "&e&lSleeping... &f({percentage}%)"
color: BLUE
style: SOLID

smooth-sleep:
enabled: true
speed: 100

messages:
player-woke-up: "&e{player} woke up! Night skip cancelled."
``



# 🎉 SinglePlayerSleep v1.1.0 - Major Update!

## 🆕 New Features

### 🎯 Percentage-Based Sleep System
  • Choose between single-player mode or percentage voting
  • Configure how many players must sleep (e.g., 50%)
  • Real-time progress messages: "3/5 players sleeping..."

### 😴 AFK Detection
  • Automatically detects inactive players (5 min timeout)
  • AFK players excluded from sleep count
  • Prevents AFK players from blocking night skip

### 🔄 Auto Update Checker
  • Checks GitHub for new versions on startup
  • Console notifications with download links
  • Can be disabled in config

### ⚡ Performance Boost
  • Config Cache System**: 30-50% faster config access
  • Smart Particle Optimization**: Auto-scales based on player count
  • TPS Improvement**: 40-60% better performance on large servers

## 🐛 Bug Fixes
  • Fixed plugin.yml main class path
  • Added null safety checks
  • Resolved config duplicate field issues
  • Improved overall stability

## 📥 Download

## 📋 Requirements
  • Minecraft 1.21.10+
  • Java 21+
  • Spigot/Paper

## 🔧 Quick Config Example
``yaml
percentage-mode: true
sleep-percentage: 50
afk-detection:
enabled: true
ignore-afk-players: true
effects:
particles:
optimize: true
``

[1.0.0] SinglePlayerSleep by MRsuffixx on Oct 15, 2026
Download
It's a first version
SinglePlayerSleep - Sleep Plugin Icon
Download SinglePlayerSleep - Sleep Plugin
Select game version
Select platform