TF-EssentialsX/Essentials/src/net/ess3/api/events/UserRandomTeleportEvent.java
pop4959 76e511a774
Implement random teleport command (#3418)
Adds `/tpr` and `/settpr` commands, which respectively allow you to teleport randomly or set teleportation parameters.

Server owners are expected to set the center with `/settpr` before players can use `/tpr`. They can also set the minimum and maximum range to be teleported from the center (default 0-1000).

Also includes an event where plugins can adjust or cancel the teleport.

Closes #3154.
2020-07-06 19:53:43 +01:00

75 lines
1.6 KiB
Java

package net.ess3.api.events;
import net.ess3.api.IUser;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when the player uses the command /tpr
*/
public class UserRandomTeleportEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private IUser user;
private Location center;
private double minRange, maxRange;
private boolean cancelled = false;
public UserRandomTeleportEvent(IUser user, Location center, double minRange, double maxRange) {
super(!Bukkit.isPrimaryThread());
this.user = user;
this.center = center;
this.minRange = minRange;
this.maxRange = maxRange;
}
public IUser getUser() {
return user;
}
public Location getCenter() {
return center;
}
public void setCenter(Location center) {
this.center = center;
}
public double getMinRange() {
return minRange;
}
public void setMinRange(double minRange) {
this.minRange = minRange;
}
public double getMaxRange() {
return maxRange;
}
public void setMaxRange(double maxRange) {
this.maxRange = maxRange;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean b) {
cancelled = b;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}