mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
feat: add new API event for TeleportWarmupCancelledEvent (#628)
* Added TeleportWarmupCancelledEvent * Changed docs * Added more JavaDocs
This commit is contained in:
1 parent
945fe0c0e0
commit
4d86f580ae
12 files changed
+397
-20
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
id 'io.github.goooler.shadow' version '8.1.7'
|
||||
id 'org.cadixdev.licenser' version '0.6.1' apply false
|
||||
id 'org.ajoberstar.grgit' version '5.2.2'
|
||||
id 'checkstyle'
|
||||
@@ -57,7 +57,7 @@ publishing {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
apply plugin: 'io.github.goooler.shadow'
|
||||
apply plugin: 'org.cadixdev.licenser'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'java'
|
||||
|
||||
@@ -33,6 +33,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.william278.huskhomes.event.ITeleportWarmupCancelledEvent.CancelReason;
|
||||
|
||||
public interface BukkitEventDispatcher extends EventDispatcher {
|
||||
|
||||
@Override
|
||||
@@ -52,6 +54,14 @@ public interface BukkitEventDispatcher extends EventDispatcher {
|
||||
return new TeleportWarmupEvent(teleport, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
default @NotNull ITeleportWarmupCancelledEvent getTeleportWarmupCancelledEvent(@NotNull TimedTeleport teleport,
|
||||
int duration,
|
||||
int cancelledAfter,
|
||||
@NotNull CancelReason cancelReason) {
|
||||
return new TeleportWarmupCancelledEvent(teleport, duration, cancelledAfter, cancelReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
default @NotNull ISendTeleportRequestEvent getSendTeleportRequestEvent(@NotNull OnlineUser sender,
|
||||
@NotNull TeleportRequest request) {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.william278.huskhomes.event.ITeleportWarmupCancelledEvent.CancelReason;
|
||||
|
||||
/**
|
||||
* An abstract dispatcher of events.
|
||||
*/
|
||||
@@ -71,6 +73,12 @@ public interface EventDispatcher {
|
||||
@NotNull
|
||||
ITeleportWarmupEvent getTeleportWarmupEvent(@NotNull TimedTeleport teleport, int duration);
|
||||
|
||||
@NotNull
|
||||
ITeleportWarmupCancelledEvent getTeleportWarmupCancelledEvent(@NotNull TimedTeleport teleport,
|
||||
int duration,
|
||||
int cancelledAfter,
|
||||
@NotNull CancelReason cancelReason);
|
||||
|
||||
@NotNull
|
||||
ISendTeleportRequestEvent getSendTeleportRequestEvent(@NotNull OnlineUser sender, @NotNull TeleportRequest request);
|
||||
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* 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,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ package net.william278.huskhomes.teleport;
|
||||
import de.themoep.minedown.adventure.MineDown;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.event.ITeleportWarmupCancelledEvent;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.util.Task;
|
||||
@@ -42,6 +43,7 @@ public class TimedTeleport extends Teleport implements Runnable, Completable {
|
||||
private final OnlineUser teleporter;
|
||||
private final Position startLocation;
|
||||
private final double startHealth;
|
||||
private final int warmupTime;
|
||||
private Task.Repeating task;
|
||||
private int timeLeft;
|
||||
|
||||
@@ -51,6 +53,7 @@ public class TimedTeleport extends Teleport implements Runnable, Completable {
|
||||
super(teleporter, executor, target, type, updateLastPosition, actions, plugin);
|
||||
this.startLocation = teleporter.getPosition();
|
||||
this.startHealth = teleporter.getHealth();
|
||||
this.warmupTime = warmupTime;
|
||||
this.timeLeft = Math.max(warmupTime, 0);
|
||||
this.teleporter = teleporter;
|
||||
}
|
||||
@@ -142,6 +145,8 @@ public class TimedTeleport extends Teleport implements Runnable, Completable {
|
||||
|
||||
// Cancel the timed teleport if the player takes damage
|
||||
if (hasTeleporterTakenDamage() && plugin.getSettings().getGeneral().isTeleportWarmupCancelOnDamage()) {
|
||||
plugin.fireEvent(plugin.getTeleportWarmupCancelledEvent(this, warmupTime,
|
||||
timeLeft, ITeleportWarmupCancelledEvent.CancelReason.PLAYER_DAMAGE), null);
|
||||
plugin.getLocales().getLocale("teleporting_cancelled_damage")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
plugin.getLocales().getLocale("teleporting_action_bar_cancelled")
|
||||
@@ -153,6 +158,8 @@ public class TimedTeleport extends Teleport implements Runnable, Completable {
|
||||
|
||||
// Cancel the timed teleport if the player moves
|
||||
if (hasTeleporterMoved() && plugin.getSettings().getGeneral().isTeleportWarmupCancelOnMove()) {
|
||||
plugin.fireEvent(plugin.getTeleportWarmupCancelledEvent(this, warmupTime,
|
||||
timeLeft, ITeleportWarmupCancelledEvent.CancelReason.PLAYER_MOVE), null);
|
||||
plugin.getLocales().getLocale("teleporting_cancelled_movement")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
plugin.getLocales().getLocale("teleporting_action_bar_cancelled")
|
||||
|
||||
+19
-18
@@ -1,24 +1,25 @@
|
||||
HuskHomes provides a number of API events your plugin can listen to when certain actions are performed. Most of these events are cancellable, letting you stop them from executing if you wish.
|
||||
|
||||
## List of API events
|
||||
| Bukkit Event class | Since | Cancellable | Description |
|
||||
|-------------------------------|:-----:|:-----------:|--------------------------------------------------------------------------|
|
||||
| `HomeCreateEvent` | 4.0 | ✅ | Called when a player sets a home |
|
||||
| `HomeListEvent` | 3.0 | ✅ | Called when a player requests to view a list of homes / public homes |
|
||||
| `HomeEditEvent` | 4.0 | ✅ | Called when a player edits a home (privacy, relocate, description, name) |
|
||||
| `HomeDeleteEvent` | 3.0 | ✅ | Called when a player deletes a home† |
|
||||
| `DeleteAllHomesEvent` | 3.2.1 | ✅ | Called when a player uses `/delhome all` to delete all their homes |
|
||||
| `WarpCreateEvent` | 4.0 | ✅ | Called when a player sets a warp |
|
||||
| `WarpListEvent` | 3.0 | ✅ | Called when a player requests to view a list of warps |
|
||||
| `WarpEditEvent` | 4.0 | ✅ | Called when a player edits a warp (relocate, description, name) |
|
||||
| `WarpDeleteEvent` | 3.0 | ✅ | Called when a player deletes a warp† |
|
||||
| `DeleteAllWarpsEvent` | 3.2.1 | ✅ | Called when a player uses `/delwarp all` to delete all warps |
|
||||
| `SendTeleportRequestEvent` | 4.1 | ✅ | Called when a player sends a teleport request (`/tpa`) |
|
||||
| `ReceiveTeleportRequestEvent` | 4.1 | ✅ | Called when a player receives a teleport request from someone |
|
||||
| `ReplyTeleportRequestEvent` | 4.1 | ✅ | Called when a player accepts or declines a teleport request |
|
||||
| `TeleportWarmupEvent` | 3.0 | ✅ | Called when a player starts a teleport warmup countdown |
|
||||
| `TeleportEvent` | 3.0 | ✅ | Called when a player is teleported‡ |
|
||||
| `TeleportBackEvent` | 4.1 | ✅ | Called when a player teleports to their last position (`/back`)‡ |
|
||||
| Bukkit Event class | Since | Cancellable | Description |
|
||||
|--------------------------------|:-----:|:-----------:|--------------------------------------------------------------------------|
|
||||
| `HomeCreateEvent` | 4.0 | ✅ | Called when a player sets a home |
|
||||
| `HomeListEvent` | 3.0 | ✅ | Called when a player requests to view a list of homes / public homes |
|
||||
| `HomeEditEvent` | 4.0 | ✅ | Called when a player edits a home (privacy, relocate, description, name) |
|
||||
| `HomeDeleteEvent` | 3.0 | ✅ | Called when a player deletes a home† |
|
||||
| `DeleteAllHomesEvent` | 3.2.1 | ✅ | Called when a player uses `/delhome all` to delete all their homes |
|
||||
| `WarpCreateEvent` | 4.0 | ✅ | Called when a player sets a warp |
|
||||
| `WarpListEvent` | 3.0 | ✅ | Called when a player requests to view a list of warps |
|
||||
| `WarpEditEvent` | 4.0 | ✅ | Called when a player edits a warp (relocate, description, name) |
|
||||
| `WarpDeleteEvent` | 3.0 | ✅ | Called when a player deletes a warp† |
|
||||
| `DeleteAllWarpsEvent` | 3.2.1 | ✅ | Called when a player uses `/delwarp all` to delete all warps |
|
||||
| `SendTeleportRequestEvent` | 4.1 | ✅ | Called when a player sends a teleport request (`/tpa`) |
|
||||
| `ReceiveTeleportRequestEvent` | 4.1 | ✅ | Called when a player receives a teleport request from someone |
|
||||
| `ReplyTeleportRequestEvent` | 4.1 | ✅ | Called when a player accepts or declines a teleport request |
|
||||
| `TeleportWarmupEvent` | 3.0 | ✅ | Called when a player starts a teleport warmup countdown |
|
||||
| `TeleportWarmupCancelledEvent` | 4.6.3 | ❌ | Called when a player cancels the teleport warmup |
|
||||
| `TeleportEvent` | 3.0 | ✅ | Called when a player is teleported‡ |
|
||||
| `TeleportBackEvent` | 4.1 | ✅ | Called when a player teleports to their last position (`/back`)‡ |
|
||||
|
||||
† If the player uses `/delhome all` or `/delwarp all` to delete all their homes or all the warps, a single `DeleteAllHomesEvent` or `DeleteAllWarpsEvent` is fired instead.
|
||||
‡ Called on the server the player *is teleported from*; not necessarily where the executor of the teleport is.
|
||||
|
||||
@@ -37,6 +37,8 @@ import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.william278.huskhomes.event.ITeleportWarmupCancelledEvent.CancelReason;
|
||||
|
||||
public interface FabricEventDispatcher extends EventDispatcher {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -68,6 +70,15 @@ public interface FabricEventDispatcher extends EventDispatcher {
|
||||
return TeleportWarmupCallback.SUPPLIER.apply(teleport, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
default ITeleportWarmupCancelledEvent getTeleportWarmupCancelledEvent(@NotNull TimedTeleport teleport,
|
||||
int duration,
|
||||
int cancelledAfter,
|
||||
@NotNull CancelReason cancelReason) {
|
||||
return TeleportWarmupCancelledCallback.SUPPLIER.apply(teleport, duration, cancelledAfter, cancelReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
default @NotNull ISendTeleportRequestEvent getSendTeleportRequestEvent(@NotNull OnlineUser sender,
|
||||
@NotNull TeleportRequest request) {
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* 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.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.william278.huskhomes.teleport.TimedTeleport;
|
||||
import net.william278.huskhomes.util.QuadFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.william278.huskhomes.event.ITeleportWarmupCancelledEvent.CancelReason;
|
||||
|
||||
|
||||
public interface TeleportWarmupCancelledCallback extends FabricEventCallback<ITeleportWarmupCancelledEvent> {
|
||||
@NotNull
|
||||
Event<TeleportWarmupCancelledCallback> EVENT = EventFactory.createArrayBacked(TeleportWarmupCancelledCallback.class,
|
||||
(listeners) -> (event) -> {
|
||||
for (TeleportWarmupCancelledCallback listener : listeners) {
|
||||
listener.invoke(event);
|
||||
}
|
||||
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
@NotNull
|
||||
QuadFunction<TimedTeleport, Integer, Integer, CancelReason, ITeleportWarmupCancelledEvent> SUPPLIER =
|
||||
(timedTeleport, duration, cancelledAfter, cancelReason) ->
|
||||
new ITeleportWarmupCancelledEvent() {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public TimedTeleport getTimedTeleport() {
|
||||
return timedTeleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarmupDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cancelledAfter() {
|
||||
return cancelledAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ITeleportWarmupCancelledEvent.CancelReason getCancelReason() {
|
||||
return cancelReason;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Event<TeleportWarmupCancelledCallback> getEvent() {
|
||||
return EVENT;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* 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.util;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface QuadFunction<T, U, V, W, R> {
|
||||
|
||||
default <X> QuadFunction<T, U, V, W, X> andThen(Function<? super R, ? extends X> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return (t, u, v, w) -> after.apply(this.apply(t, u, v, w));
|
||||
}
|
||||
|
||||
R apply(T var1, U var2, V var3, W var4);
|
||||
}
|
||||
@@ -34,6 +34,8 @@ import org.spongepowered.api.event.Event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.william278.huskhomes.event.ITeleportWarmupCancelledEvent.CancelReason;
|
||||
|
||||
public interface SpongeEventDispatcher extends EventDispatcher {
|
||||
|
||||
@Override
|
||||
@@ -52,6 +54,15 @@ public interface SpongeEventDispatcher extends EventDispatcher {
|
||||
return new SpongeTeleportWarmupEvent(teleport, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
default ITeleportWarmupCancelledEvent getTeleportWarmupCancelledEvent(@NotNull TimedTeleport teleport,
|
||||
int duration,
|
||||
int cancelledAfter,
|
||||
@NotNull CancelReason cancelReason) {
|
||||
return new SpongeTeleportWarmupCancelledEvent(teleport, duration, cancelledAfter, cancelReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
default @NotNull ISendTeleportRequestEvent getSendTeleportRequestEvent(@NotNull OnlineUser sender,
|
||||
@NotNull TeleportRequest request) {
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of HuskHomes, licensed under the Apache License 2.0.
|
||||
*
|
||||
* Copyright (c) William278 <[email protected]>
|
||||
* 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;
|
||||
import org.spongepowered.api.event.Cause;
|
||||
import org.spongepowered.api.event.Event;
|
||||
|
||||
public class SpongeTeleportWarmupCancelledEvent implements ITeleportWarmupCancelledEvent, Event {
|
||||
|
||||
private final TimedTeleport teleport;
|
||||
private final int duration;
|
||||
private final int cancelledAfter;
|
||||
private final CancelReason cancelReason;
|
||||
|
||||
public SpongeTeleportWarmupCancelledEvent(@NotNull TimedTeleport teleport, int duration,
|
||||
int cancelledAfter, @NotNull CancelReason cancelReason) {
|
||||
this.teleport = teleport;
|
||||
this.duration = duration;
|
||||
this.cancelledAfter = cancelledAfter;
|
||||
this.cancelReason = cancelReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause cause() {
|
||||
return Cause.builder()
|
||||
.append(teleport.getTeleporter())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarmupDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TimedTeleport getTimedTeleport() {
|
||||
return teleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cancelledAfter() {
|
||||
return cancelledAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CancelReason getCancelReason() {
|
||||
return cancelReason;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user