2022-05-09 00:15:22 +00:00
|
|
|
package dev.plex.command.sub;
|
|
|
|
|
|
|
|
import dev.plex.Guilds;
|
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.command.annotation.CommandParameters;
|
|
|
|
import dev.plex.command.annotation.CommandPermissions;
|
|
|
|
import dev.plex.command.source.RequiredCommandSource;
|
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
2022-05-09 00:52:08 +00:00
|
|
|
@CommandParameters(name = "home", aliases = "spawn", usage = "/guild <command>", description = "Teleports to the guild home")
|
2023-09-08 22:40:39 +00:00
|
|
|
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.home")
|
2022-05-09 00:15:22 +00:00
|
|
|
public class HomeSubCommand extends PlexCommand
|
|
|
|
{
|
|
|
|
public HomeSubCommand()
|
|
|
|
{
|
|
|
|
super(false);
|
|
|
|
}
|
2023-09-08 22:40:39 +00:00
|
|
|
|
2022-05-09 00:15:22 +00:00
|
|
|
@Override
|
|
|
|
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
|
|
|
|
{
|
|
|
|
assert player != null;
|
2023-09-08 22:40:39 +00:00
|
|
|
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
|
|
|
|
{
|
2022-05-09 00:15:22 +00:00
|
|
|
if (guild.getHome() == null)
|
|
|
|
{
|
|
|
|
send(player, messageComponent("guildHomeNotFound"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
player.teleportAsync(guild.getHome().toLocation());
|
|
|
|
}, () -> send(player, messageComponent("guildNotFound")));
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|