2021-02-07 03:37:25 +01:00
|
|
|
package net.knarcraft.stargate.event;
|
|
|
|
|
2021-02-22 17:01:47 +01:00
|
|
|
import net.knarcraft.stargate.portal.Portal;
|
2021-02-07 03:37:25 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.HandlerList;
|
2021-02-12 00:26:47 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
import java.util.List;
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
/**
|
|
|
|
* This event should be called whenever a player activates a stargate
|
2021-10-13 15:45:15 +02:00
|
|
|
*
|
|
|
|
* <p>Activation of a stargate happens when a player right-clicks the sign of a stargate.
|
|
|
|
* This event can be used to overwrite the selected destination, and all destinations the player can see.</p>
|
2021-02-19 12:06:23 +01:00
|
|
|
*/
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public class StargateActivateEvent extends StargatePlayerEvent {
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-20 13:57:04 +01:00
|
|
|
private static final HandlerList handlers = new HandlerList();
|
2021-02-19 12:06:23 +01:00
|
|
|
private List<String> destinations;
|
2021-02-07 03:37:25 +01:00
|
|
|
private String destination;
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new stargate activate event
|
|
|
|
*
|
|
|
|
* @param portal <p>The activated portal</p>
|
|
|
|
* @param player <p>The player activating the portal</p>
|
|
|
|
* @param destinations <p>The destinations available to the player using the portal</p>
|
2021-10-13 15:45:15 +02:00
|
|
|
* @param destination <p>The currently selected destination</p>
|
2021-02-19 12:06:23 +01:00
|
|
|
*/
|
|
|
|
public StargateActivateEvent(Portal portal, Player player, List<String> destinations, String destination) {
|
2021-10-13 15:45:15 +02:00
|
|
|
super(portal, player);
|
2021-02-07 03:37:25 +01:00
|
|
|
|
|
|
|
this.destinations = destinations;
|
|
|
|
this.destination = destination;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
/**
|
|
|
|
* Gets the destinations available for the portal
|
|
|
|
*
|
|
|
|
* @return <p>The destinations available for the portal</p>
|
|
|
|
*/
|
|
|
|
public List<String> getDestinations() {
|
2021-02-07 03:37:25 +01:00
|
|
|
return destinations;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
/**
|
|
|
|
* Sets the destinations available to the player using the portal
|
|
|
|
*
|
|
|
|
* @param destinations <p>The new list of available destinations</p>
|
|
|
|
*/
|
|
|
|
public void setDestinations(List<String> destinations) {
|
2021-02-07 03:37:25 +01:00
|
|
|
this.destinations = destinations;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
/**
|
2021-10-13 15:45:15 +02:00
|
|
|
* Gets the selected destination
|
2021-02-19 12:06:23 +01:00
|
|
|
*
|
2021-10-13 15:45:15 +02:00
|
|
|
* @return <p>The selected destination</p>
|
2021-02-19 12:06:23 +01:00
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public String getDestination() {
|
|
|
|
return destination;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
/**
|
2021-10-13 15:45:15 +02:00
|
|
|
* Sets (changes) the selected destination
|
2021-02-19 12:06:23 +01:00
|
|
|
*
|
2021-10-13 15:45:15 +02:00
|
|
|
* @param destination <p>The new selected destination</p>
|
2021-02-19 12:06:23 +01:00
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public void setDestination(String destination) {
|
|
|
|
this.destination = destination;
|
|
|
|
}
|
|
|
|
|
2021-10-13 15:45:15 +02:00
|
|
|
/**
|
|
|
|
* Gets a handler-list containing all event handlers
|
|
|
|
*
|
|
|
|
* @return <p>A handler-list with all event handlers</p>
|
|
|
|
*/
|
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
2021-02-19 12:06:23 +01:00
|
|
|
@Override
|
|
|
|
@NotNull
|
|
|
|
public HandlerList getHandlers() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|