作者:rebot | 分类:模组
Minecraft 版本: 1.21 1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7 1.21.8 1.21.9 1.21.10 1.21.11 26.1 26.1.1 26.1.2
平台: bukkit paper purpur spigot
标签: game-mechanics
⚠️ 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.
✨ 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.
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.
%sps_*% placeholders)stats.yml)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./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.CooldownManager missing from SleepCommand constructor — The cooldownManager field was declared but never assigned, causing a NullPointerException on every /sleep command execution.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./sps reload. A crash would cause full stats loss. A periodic auto-save task now runs every 5 minutes.SleepSession thread safety — sleepingPlayers is now backed by a concurrent collection to prevent ConcurrentModificationException during async PlaceholderAPI queries.VoteModule.addVote() race condition — computeIfAbsent() and get() were two separate operations. They are now chained into a single atomic call.CooldownManager thread safety — Changed from HashMap to ConcurrentHashMap to prevent race conditions from async PlaceholderAPI thread access.net.md_5.bungee.api usages replaced with player.sendActionBar() via Adventure API, as recommended for Paper 1.21+.refreshRequirement() using raw player count — Now correctly uses getEffectiveSleepingCount() instead of sleepingPlayers.size() to account for /sleep votes in percentage mode.sleepingPlayers but kicked before sleep animation completed were not being removed. onPlayerLeave() is now called unconditionally.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().SinglePlayerSleep instead of SinglePlayerSleepV2, causing update checks to fail on fresh installs.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.getEffectiveSleepingCount() — Replaced set-union allocation (creating a new HashSet on every call) with a simple counter loop, reducing GC pressure on busy servers.calculateRequired() called multiple times — Result is now cached in a local variable within checkSleepCondition().topSleepersCache, topContributorsCache, and lastLeaderboardRefresh are now updated atomically via a single LeaderboardSnapshot object to prevent inconsistent reads across threads.stats.yml no longer grows unbounded. A configurable stats.cleanup-days option (default: 90) purges entries for players who haven't been seen recently.Player.getWorld() is never null in the Bukkit API. Removed misleading defensive checks from VoteModule and SleepListener.isPrimaryThread() check in AfkListener — AsyncPlayerChatEvent is always async by Bukkit contract; the check was misleading.AfkModule.scheduledCheck() — sleepManager is never null at the call site.VoteModule.getVotes() unnecessary copy — Changed from Set.copyOf() (full allocation) to Collections.unmodifiableSet() (view only).PhantomModule broadcasting when no players were reset — The phantom-reset message now only broadcasts if at least one player's timer was actually reset.TimeUtil class with isNight(World) helper methodSpsCommand.java and SleepManager.java — proper imports added, simple class names used consistentlySleepListener.jar file into your server's /plugins folder.plugins/SinglePlayerSleep/config.yml as needed./sps reload to apply configuration changes.Requirements:
Optional: Install PlaceholderAPI to enable
%sps_*%placeholders.
| 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 |
| 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) |
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 |
Config file: plugins/SinglePlayerSleep/config.yml
| 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 |
| 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 |
| 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 |
| 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 |
| Key | Default | Description |
|---|---|---|
worlds.enabled |
["world"] |
World list |
worlds.mode |
whitelist |
whitelist or blacklist |
Contributions are welcome!
git checkout -b feature/my-featuregit commit -m "Add my feature"git push origin feature/my-feature# Clone and build
git clone https://github.com/MRsuffixx/SinglePlayerSleep.git
mvn clean package
# Output: target/SinglePlayerSleep-2.2.0.jar
When reporting a bug, please include: Minecraft version, plugin version, server software, config.yml, and any error logs.
Distributed under the MIT License. See LICENSE for details.
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+
请登录后举报
暂无评论,抢个沙发吧~