Module-Guilds/src/main/java/dev/plex/command/sub/HomeSubCommand.java
2024-01-20 15:10:23 -06:00

47 lines
1.6 KiB
Java

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 java.util.Collections;
import java.util.List;
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;
@CommandParameters(name = "home", aliases = "spawn", usage = "/guild <command>", description = "Teleports to the guild home")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.home")
public class HomeSubCommand extends PlexCommand
{
public HomeSubCommand()
{
super(false);
}
@Override
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
{
assert player != null;
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild ->
{
if (guild.getHome() == null)
{
send(player, messageComponent("guildHomeNotFound"));
return;
}
player.teleportAsync(guild.getHome().toLocation());
}, () -> send(player, messageComponent("guildNotFound")));
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
}