49 lines
1.6 KiB
Java
49 lines
1.6 KiB
Java
package me.paradoxpixel.themepark.action;
|
|
|
|
import me.paradoxpixel.themepark.api.API;
|
|
import me.paradoxpixel.themepark.api.attraction.Attraction;
|
|
import me.paradoxpixel.themepark.attraction.AttractionMenu;
|
|
import me.paradoxpixel.themepark.attraction.status.StatusManager;
|
|
import me.paradoxpixel.themepark.gui.GUIAction;
|
|
import me.paradoxpixel.themepark.utils.Message;
|
|
import me.paradoxpixel.themepark.utils.Utils;
|
|
import org.bukkit.entity.Minecart;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public class TPUtils extends GUIAction {
|
|
|
|
private String id;
|
|
|
|
public TPUtils(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
@Override
|
|
public void click(Player player) {
|
|
player.closeInventory();
|
|
Attraction attraction = API.getAttraction(id);
|
|
if(attraction == null)
|
|
return;
|
|
|
|
if(attraction.getLocation() == null)
|
|
return;
|
|
|
|
if(!StatusManager.canTeleport(attraction.getStatus())) {
|
|
String message = Message.getMessage("attraction.teleport.status");
|
|
message = message.replace("{name}", attraction.getName());
|
|
message = message.replace("{status}", StatusManager.getName(attraction.getStatus()));
|
|
player.sendMessage(Utils.color(message));
|
|
return;
|
|
}
|
|
|
|
if(player.isInsideVehicle())
|
|
if(player.getVehicle() instanceof Minecart)
|
|
return;
|
|
|
|
player.teleport(attraction.getLocation());
|
|
String message = Message.getMessage("attraction.teleport.success");
|
|
message = message.replace("{name}", attraction.getName());
|
|
player.sendMessage(Utils.color(message));
|
|
}
|
|
|
|
}
|