-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix per-world and per-player time #13814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
paper-api/src/main/java/org/bukkit/event/world/ClockTimeSkipEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| package org.bukkit.event.world; | ||
|
|
||
| import org.bukkit.event.Cancellable; | ||
| import org.bukkit.event.Event; | ||
| import org.bukkit.event.HandlerList; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| /** | ||
| * Called when the time skips for a world clock. | ||
| * <p> | ||
| * If the event is cancelled the time will not change. | ||
| */ | ||
| // TODO - snapshot - 26.1 clock | ||
| @ApiStatus.Experimental | ||
| @NullMarked | ||
| public class ClockTimeSkipEvent extends Event implements Cancellable { | ||
|
|
||
| private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
|
|
||
| private final SkipReason skipReason; | ||
| private long skipAmount; | ||
|
|
||
| private boolean cancelled; | ||
|
|
||
| @ApiStatus.Internal | ||
| public ClockTimeSkipEvent(final SkipReason skipReason, final long skipAmount) { | ||
| this.skipReason = skipReason; | ||
| this.skipAmount = skipAmount; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the reason why the time has skipped. | ||
| * | ||
| * @return a SkipReason value detailing why the time has skipped | ||
| */ | ||
| public SkipReason getSkipReason() { | ||
| return this.skipReason; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the amount of time that was skipped. | ||
| * | ||
| * @return Amount of time skipped | ||
| */ | ||
| public long getSkipAmount() { | ||
| return this.skipAmount; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the amount of time to skip. | ||
| * | ||
| * @param skipAmount Amount of time to skip | ||
| */ | ||
| public void setSkipAmount(long skipAmount) { | ||
| this.skipAmount = skipAmount; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isCancelled() { | ||
| return this.cancelled; | ||
| } | ||
|
|
||
| @Override | ||
| public void setCancelled(boolean cancel) { | ||
| this.cancelled = cancel; | ||
| } | ||
|
|
||
| @Override | ||
| public HandlerList getHandlers() { | ||
| return HANDLER_LIST; | ||
| } | ||
|
|
||
| public static HandlerList getHandlerList() { | ||
| return HANDLER_LIST; | ||
| } | ||
|
|
||
| /** | ||
| * An enum specifying the reason the time skipped. | ||
| */ | ||
| public enum SkipReason { | ||
|
|
||
| /** | ||
| * When time is changed using the vanilla /time command. | ||
| */ | ||
| COMMAND, | ||
| /** | ||
| * When time is changed by a plugin. | ||
| */ | ||
| CUSTOM, | ||
| /** | ||
| * When time is changed by all players sleeping in their beds and the | ||
| * night skips. | ||
| */ | ||
| NIGHT_SKIP | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.