-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new API event for
TeleportWarmupCancelledEvent
(#628)
* Added TeleportWarmupCancelledEvent * Changed docs * Added more JavaDocs
- Loading branch information
Showing
12 changed files
with
397 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
75 changes: 75 additions & 0 deletions
75
bukkit/src/main/java/net/william278/huskhomes/event/TeleportWarmupCancelledEvent.java
This file contains 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,75 @@ | ||
/* | ||
* This file is part of HuskHomes, licensed under the Apache License 2.0. | ||
* | ||
* Copyright (c) William278 <will27528@gmail.com> | ||
* Copyright (c) contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.william278.huskhomes.event; | ||
|
||
import net.william278.huskhomes.teleport.TimedTeleport; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class TeleportWarmupCancelledEvent extends Event implements ITeleportWarmupCancelledEvent { | ||
|
||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
|
||
private final TimedTeleport warp; | ||
private final int duration; | ||
private final int cancelledAfter; | ||
private final CancelReason cancelReason; | ||
|
||
public TeleportWarmupCancelledEvent(@NotNull TimedTeleport warp, int duration, | ||
int cancelledAfter, @NotNull CancelReason cancelReason) { | ||
this.warp = warp; | ||
this.duration = duration; | ||
this.cancelledAfter = cancelledAfter; | ||
this.cancelReason = cancelReason; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@Override | ||
public int getWarmupDuration() { | ||
return duration; | ||
} | ||
|
||
@Override | ||
public int cancelledAfter() { | ||
return cancelledAfter; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public TimedTeleport getTimedTeleport() { | ||
return warp; | ||
} | ||
|
||
@Override | ||
public @NotNull CancelReason getCancelReason() { | ||
return cancelReason; | ||
} | ||
} |
This file contains 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
74 changes: 74 additions & 0 deletions
74
common/src/main/java/net/william278/huskhomes/event/ITeleportWarmupCancelledEvent.java
This file contains 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,74 @@ | ||
/* | ||
* This file is part of HuskHomes, licensed under the Apache License 2.0. | ||
* | ||
* Copyright (c) William278 <will27528@gmail.com> | ||
* Copyright (c) contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.william278.huskhomes.event; | ||
|
||
import net.william278.huskhomes.teleport.TimedTeleport; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Representation of an event that fires when a timed teleport warmup is cancelled. | ||
*/ | ||
public interface ITeleportWarmupCancelledEvent extends Event { | ||
|
||
/** | ||
* The duration of the timed teleport warmup in seconds. | ||
* | ||
* @return the teleport warmup duration | ||
*/ | ||
int getWarmupDuration(); | ||
|
||
/** | ||
* The time passed before the teleport warmup was cancelled in seconds. | ||
* | ||
* @return the time passed before the teleport warmup was cancelled | ||
*/ | ||
int cancelledAfter(); | ||
|
||
/** | ||
* The {@link TimedTeleport} not being executed due to the warmup being cancelled. | ||
* | ||
* @return the timed teleport that has started | ||
*/ | ||
@NotNull | ||
TimedTeleport getTimedTeleport(); | ||
|
||
/** | ||
* The reason the teleport warmup was cancelled. | ||
* | ||
* @return the reason the teleport warmup was cancelled | ||
*/ | ||
@NotNull | ||
CancelReason getCancelReason(); | ||
|
||
/** | ||
* The reason the teleport warmup was cancelled. | ||
*/ | ||
enum CancelReason { | ||
/** | ||
* The teleport warmup was cancelled due to the player moving. | ||
*/ | ||
PLAYER_MOVE, | ||
/** | ||
* The teleport warmup was cancelled due to the player taking damage. | ||
*/ | ||
PLAYER_DAMAGE, | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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.