Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions paper-api/src/main/java/org/bukkit/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -2094,10 +2094,8 @@ default boolean setSpawnLocation(int x, int y, int z) {
*
* @param time The new absolute time to set this world to
* @see #setTime(long) Sets the relative time of this world
* @deprecated all overworlds share the same world clock by default now
* @throws IllegalArgumentException if this world does not have a world clock (e.g. the nether)
*/
@Deprecated // TODO world clock API with links to it
public void setFullTime(long time);

// Paper start
Expand Down
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 {
Comment thread
kennytv marked this conversation as resolved.

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
}
}
72 changes: 10 additions & 62 deletions paper-api/src/main/java/org/bukkit/event/world/TimeSkipEvent.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.bukkit.event.world;

import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand All @@ -10,60 +9,29 @@
* Called when the time skips in a world.
* <p>
* If the event is cancelled the time will not change.
*
* @see ClockTimeSkipEvent for changing of clocks that affect all worlds
*/
// TODO - snapshot - 26.1 API needed for clock!
public class TimeSkipEvent extends WorldEvent implements Cancellable {
public class TimeSkipEvent extends ClockTimeSkipEvent {
Comment thread
kennytv marked this conversation as resolved.

private static final HandlerList HANDLER_LIST = new HandlerList();

private final SkipReason skipReason;
private long skipAmount;

private boolean cancelled;
private final World world;

@ApiStatus.Internal
public TimeSkipEvent(@NotNull World world, @NotNull SkipReason skipReason, long skipAmount) {
super(world);
this.skipReason = skipReason;
this.skipAmount = skipAmount;
super(skipReason, skipAmount);
this.world = world;
}

/**
* Gets the reason why the time has skipped.
* Returns the world that time is skipped in.
*
* @return a SkipReason value detailing why the time has skipped
* @return world that time is skipped in
*/
@NotNull
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;
public World getWorld() {
return world;
}

@NotNull
Expand All @@ -76,24 +44,4 @@ public HandlerList getHandlers() {
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
}
}
Loading
Loading